abstract class ChecksumLayer extends ChecksumLayerBase
A checksum layer computes a numeric value from a region of the data stream.
The term checksum is used generically here to subsume all sorts of CRCs, check digits, data hash, and digest calculations.
This abstract base is suitable only for checksums computed over small sections of data. It is not for large data streams or whole large files. The entire region of data the checksum is being computed over will be pulled into a byte buffer in memory.
The resulting checksum is the return value of the #compute method.
This result is delivered into a DFDL variable for use by the DFDL schema. This DFDL variable can have any name such as 'crc', 'digest', or 'dataHash'.
The derived implementation class must also define a getter method based on the name of the DFDL variable which
will be assigned with the checksum value.
For example if the checksum is actually a specific digest/hash calculation and the DFDL variable is named
digest, then this getter must be defined:
    int getLayerVariableResult_digest() {
      return this.digest; // usually returns a data member
    
}
This will be called automatically to retrieve the integer value that was returned from the compute method,
and the DFDL variable named digest will be assigned that value.The derived class implementing a checksum layer must call
    setLength(len); // sets the length in bytes
to specify the length of the data region in bytes. Normally this would be called from the layer's implementation of
the setLayerVariableParameters method:
    void setLayerVariableParameters(...) {
        ...
        setLength(len); // len is a constant,
                        // or is computed from a parameter variable
        ...
    
}
See the documentation of the Layer class for a description of how DFDL variables are passed to the arguments
of the setLayerVariableParameters method.See Layer for more details about layers generally as most of its documentation is
relevant to this derived abstract base class as well.
- Alphabetic
- By Inheritance
- ChecksumLayer
- ChecksumLayerBase
- Layer
- SimpleNamedLoadableService
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
-   abstract  def compute(isUnparse: Boolean, byteBuffer: ByteBuffer): IntOverride to compute the checksum of a buffer of data. Override to compute the checksum of a buffer of data. - isUnparse
- true if the direction is unparsing. Used because in some cases the computed checksum must be written into the byte buffer in a specific location. 
- byteBuffer
- the bytes over which the checksum is to be computed. This byte buffer can be modified, (for example so as to embed the computed checksum in the middle of the data somewhere). The resulting modified bytes become the data that is read by the DFDL parsing and written when unparsing. 
- returns
- the checksum value as an Int (32-bit signed integer) 
 - Definition Classes
- ChecksumLayer → ChecksumLayerBase
 
Concrete Value Members
-   final  def !=(arg0: Any): Boolean- Definition Classes
- AnyRef → Any
 
-   final  def ##: Int- Definition Classes
- AnyRef → Any
 
-   final  def ==(arg0: Any): Boolean- Definition Classes
- AnyRef → Any
 
-   final  def asInstanceOf[T0]: T0- Definition Classes
- Any
 
-    def clone(): AnyRef- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
 
-   final  def eq(arg0: AnyRef): Boolean- Definition Classes
- AnyRef
 
-    def equals(arg0: AnyRef): Boolean- Definition Classes
- AnyRef → Any
 
-    def finalize(): Unit- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
 
-   final  def getChecksum: Int- Attributes
- protected
- Definition Classes
- ChecksumLayerBase
 
-   final  def getClass(): Class[_ <: AnyRef]- Definition Classes
- AnyRef → Any
- Annotations
- @native()
 
-   final  def getLayerRuntime(): LayerRuntimeFor framework use. For framework use. Called by the execution framework to obtain the context for reporting errors. - Definition Classes
- Layer
 
-   final  def getLength: Int- Definition Classes
- ChecksumLayerBase
 
-   final  def getProcessingErrorExceptions(): List[Class[_ <: Exception]]For framework use. For framework use. - Definition Classes
- Layer
 
-    def hashCode(): Int- Definition Classes
- AnyRef → Any
- Annotations
- @native()
 
-   final  def isInstanceOf[T0]: Boolean- Definition Classes
- Any
 
-   final  def localName(): StringFor framework use. For framework use. - Definition Classes
- Layer
 
-   final  def name(): StringFor framework use. For framework use. This method and the string it returns are required by the SPI loader. - returns
- A unique indentifier for the kind of layer. Contains both local and namespace components of the layer's complete name. 
 - Definition Classes
- Layer → SimpleNamedLoadableService
 
-   final  def namespace(): StringFor framework use. For framework use. - Definition Classes
- Layer
 
-   final  def ne(arg0: AnyRef): Boolean- Definition Classes
- AnyRef
 
-   final  def notify(): Unit- Definition Classes
- AnyRef
- Annotations
- @native()
 
-   final  def notifyAll(): Unit- Definition Classes
- AnyRef
- Annotations
- @native()
 
-    def processingError(cause: Throwable): UnitUse to report a processing error. Use to report a processing error. When parsing a processing error can cause backtracking so that the parse can often recover from the error. When unparsing a processing error is fatal. - cause
- a throwable object that describes the error 
 - Definition Classes
- Layer
 
-    def processingError(msg: String): UnitUse to report a processing error. Use to report a processing error. When parsing a processing error can cause backtracking so that the parse can often recover from the error. When unparsing a processing error is fatal. - msg
- describes the error 
 - Definition Classes
- Layer
 
-    def runtimeSchemaDefinitionError(cause: Throwable): UnitUse to report a runtime schema definition error. Use to report a runtime schema definition error. This indicates that the layer is unable to work meaningfully because of the way it is configured. The schema itself is not well defined due to the way the layer is configured. This error type is always fatal whether parsing or unparsing. See for discussion of situations where a Runtime Schema Definition Error is appropriate.- cause
- a throwable object that describes the error 
 - Definition Classes
- Layer
 
-    def runtimeSchemaDefinitionError(msg: String): UnitUse to report a runtime schema definition error. Use to report a runtime schema definition error. This indicates that the layer is unable to work meaningfully because of the way it is configured. That is, the schema itself is not well defined due to the way the layer is configured. For example suppose a layer had a DFDL variable for a parameter that is supposed to be an integer between 1 and 10, and this parameter is generally provided as a constant value. If the provided parameter variable value is 0, which is not meaningful, then a Runtime Schema Definition Error is the right error to invoke. This error type is always fatal whether parsing or unparsing. - msg
- describes the error 
 - Definition Classes
- Layer
 
-   final  def setLayerRuntime(lr: LayerRuntime): UnitFor framework use. For framework use. Called by the execution framework to give the context for reporting errors. - lr
- runtime data structure used by the framework 
 - Definition Classes
- Layer
 
-   final  def setLength(len: Int): Unit- Attributes
- protected
- Definition Classes
- ChecksumLayerBase
 
-   final  def setProcessingErrorException(e: Class[_ <: Exception]): UnitUse to add an exception class to the list of exceptions that will be automatically converted into processing errors. Use to add an exception class to the list of exceptions that will be automatically converted into processing errors. The purpose of this is to allow one to use java/scala libraries that may throw exceptions when encountering bad data. Such exceptions should be translated into processing errors, which will allow the parser to backtrack and try other alternatives which may work for that data. By calling this method the layer framework implements the try-catch logic to capture these exception types and convert them into processing errors. This avoids a great deal of try-catch logic that would otherwise be required in layer methods. When considering whether a thrown Exception is to be converted to a processing error RuntimeException classes are handled separately from Exception classes. Hence calling setProcessingErrorException(Exception.class);will NOT cause all RuntimeExceptions to also be converted into processing errors. It will, however, cause all classes derived from Exception that are NOT RuntimeExceptions to be caught and converted into Processing Errors.- e
- the exception class to be added to the list of processing error exceptions 
 - Definition Classes
- Layer
 
-   final  def synchronized[T0](arg0: => T0): T0- Definition Classes
- AnyRef
 
-    def toString(): String- Definition Classes
- AnyRef → Any
 
-   final  def wait(): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
 
-   final  def wait(arg0: Long, arg1: Int): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
 
-   final  def wait(arg0: Long): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
 
-   final  def wrapLayerInput(jis: InputStream): InputStreamWraps a layer input decoder around an input stream. Wraps a layer input decoder around an input stream. This input decoder does the real parser-time work of the layer. It implements java.io.InputStream, by reading data from the given argument input stream, and decoding it.Any exception thrown from this wrap method becomes a Schema Definition Error (fatal). The input decoder generally uses a reference to this layer instance to report errors. To have the Daffodil layer framework convert uncaught exceptions thrown by the input decoder into processing errors automatically, call the #setProcessingErrorException(Class). Other kinds of input decoder processing errors can be signaled by calling the#processingError(String)or#processingError(Throwable)methods. Input decoder schema definition errors are more rare, but if needed the#runtimeSchemaDefinitionError(String)or#runtimeSchemaDefinitionError(Throwable)methods may be called.- jis
- The input stream to be wrapped. 
- returns
- An input stream with the layer's input decoder wrapped around it. 
 - Definition Classes
- ChecksumLayerBase → Layer
 
-   final  def wrapLayerOutput(jos: OutputStream): OutputStreamWraps a layer output encoder around an output stream. Wraps a layer output encoder around an output stream. The output encoder does the real unparse-time work of the layer. It implements java.io.OutputStreamby accepting data via the usual output stream write calls, encoding this data, and writing the encoded data to the argument output stream.Any exception thrown from this wrap method becomes a Schema Definition Error (fatal). The output encoder generally uses a reference to this layer to report errors. To have the Daffodil layer framework convert uncaught exceptions thrown by the output encoder into processing errors automatically, call the #setProcessingErrorException(Class). Other kinds of output encoder processing errors can be signaled by calling the#processingError(String)or#processingError(Throwable)methods. Output encoder schema definition errors are more rare, but if needed the#runtimeSchemaDefinitionError(String)or#runtimeSchemaDefinitionError(Throwable)methods may be called.- jos
- The output stream to be wrapped. 
- returns
- An output stream with the layer wrapped around it. 
 - Definition Classes
- ChecksumLayerBase → Layer
 
This is the documentation for the Apache Daffodil Scala API.
Package structure
org.apache.daffodil.sapi - Provides the classes necessary to compile DFDL schemas, parse and unparse files using the compiled objects, and retrieve results and parsing diagnostics
org.apache.daffodil.udf - Provides the classes necessary to create User Defined Functions to extend the DFDL expression language
org.apache.daffodil.runtime1.layers.api - Provides the classes necessary to create custom Layer extensions to DFDL.