Packages

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.

Linear Supertypes
ChecksumLayerBase, Layer, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ChecksumLayer
  2. ChecksumLayerBase
  3. Layer
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ChecksumLayer(layerName: String, layerTargetNamespace: String)

Abstract Value Members

  1. abstract def compute(isUnparse: Boolean, byteBuffer: ByteBuffer): Int

    Override 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

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getChecksum: Int
    Attributes
    protected
    Definition Classes
    ChecksumLayerBase
  10. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. final def getLayerRuntime(): LayerRuntime

    For framework use.

    For framework use.

    Called by the execution framework to obtain the context for reporting errors.

    Definition Classes
    Layer
  12. final def getLength: Int
    Definition Classes
    ChecksumLayerBase
  13. final def getProcessingErrorExceptions(): List[Class[_ <: Exception]]

    For framework use.

    For framework use.

    Definition Classes
    Layer
  14. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  15. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  16. final def localName(): String

    For framework use.

    For framework use.

    Definition Classes
    Layer
  17. final def name(): String

    For 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
  18. final def namespace(): String

    For framework use.

    For framework use.

    Definition Classes
    Layer
  19. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  21. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. def processingError(cause: Throwable): Unit

    Use 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
  23. def processingError(msg: String): Unit

    Use 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
  24. def runtimeSchemaDefinitionError(cause: Throwable): Unit

    Use 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
  25. def runtimeSchemaDefinitionError(msg: String): Unit

    Use 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
  26. final def setLayerRuntime(lr: LayerRuntime): Unit

    For 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
  27. final def setLength(len: Int): Unit
    Attributes
    protected
    Definition Classes
    ChecksumLayerBase
  28. final def setProcessingErrorException(e: Class[_ <: Exception]): Unit

    Use 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
  29. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  30. def toString(): String
    Definition Classes
    AnyRef → Any
  31. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  34. final def wrapLayerInput(jis: InputStream): InputStream

    Wraps 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
  35. final def wrapLayerOutput(jos: OutputStream): OutputStream

    Wraps 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.OutputStream by 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

Inherited from ChecksumLayerBase

Inherited from Layer

Inherited from AnyRef

Inherited from Any

Ungrouped