Module ibm.jzos

Class DatatypeFactory

  • Direct Known Subclasses:
    AssemblerDatatypeFactory, CobolDatatypeFactory

    public abstract class DatatypeFactory
    extends java.lang.Object
    An abstract class for classes which are used to construct Field objects. A running offset to the next field is maintained, along with a stack which can be used to push and pop the current Field offset. A DatatypeFactory is typically used to statically initialize static Field variables in a Java class which maps a record described by a byte array. For an example, see Format1DSCB.

    Instances of this class or its subclasses will automatically construct instances of com.ibm.jzos.fields.daa classes if the com.ibm.jzos.fields.daa package is available at runtime. See the useDaa() method for more information.

    For an example, see Format1DSCB.

    Since:
    2.1.0, 2.4.5 Data Access Accelerator support
    • Field Detail

      • USE_DAA_PROPERTY

        public static final java.lang.String USE_DAA_PROPERTY
        See Also:
        Constant Field Values
      • USE_DAA_DEFAULT

        public static final boolean USE_DAA_DEFAULT
        By default, Data Access Accelerator (DAA) will be used if the com.ibm.dataaccess (DAA) classes are available. DAA can be disabled by setting the system property com.ibm.jzos.fields.use-daa explicitly to false. If the com.ibm.dataaccess (DAA) classes are not available, then DAA will be disabled.
        Since:
        2.4.5
    • Constructor Detail

      • DatatypeFactory

        public DatatypeFactory()
    • Method Detail

      • getOffset

        public int getOffset()
        Answer the current (next) Field offset
        Returns:
        int
      • getMaximumOffset

        public int getMaximumOffset()
        Answer the maximum value of the offset
      • setOffset

        public void setOffset​(int offset)
        See Also:
        getOffset()
      • pushOffset

        public void pushOffset()
        Push the current Field offset onto an internal stack.
        See Also:
        popOffset()
      • popOffset

        public void popOffset()
        Pop the Field offset from the top of an internal stack.
        See Also:
        pushOffset()
      • incrementOffset

        public void incrementOffset​(int amount)
        Increments the current Field offset
        Parameters:
        amount - int
      • getStringEncoding

        public java.lang.String getStringEncoding()
        Gets the current String encoding used for construction of StringFields. By default, this is null, meaning that the StringField determines the encoding.
        Returns:
        String
        See Also:
        StringField.getEncoding()
      • getStringTrimDefault

        public boolean getStringTrimDefault()
        Answer the default setting for StringField trimming if not explicitly given. Default is false.
      • setStringEncoding

        public void setStringEncoding​(java.lang.String stringEncoding)
        See Also:
        getStringEncoding()
      • useDaa

        public boolean useDaa()
        Returns whether using Data Access Accelerator (DAA).

        By default, factory methods in this class (and subclasses) will return subtype implementation instances from the com.ibm.jzos.fields.daa package, which exploit the com.ibm.dataaccess (DAA) classes if available. DAA can be disabled by setting the system property com.ibm.jzos.fields.use-daa explicitly to false. If the com.ibm.dataaccess (DAA) classes are not available, then DAA exploitation will be disabled.

        Returns:
        true if using Data Access Accelerator, false otherwise.
        Since:
        2.4.5
      • setUseDaa

        public void setUseDaa​(boolean useDaa)
        Configure this DatatypeFactory whether to use Data Access Accelerator classes. Overrides the default. Note that useDaa can only be set if the com.ibm.dataaccess (DAA) classes are available.
        Parameters:
        useDaa - true if DAA classes are to be used. An IllegalStateException will be thrown if DAA classes are not available. false if DAA classes are not to be exploited.
        Throws:
        java.lang.IllegalStateException - if DAA classes are not available.
        Since:
        2.4.5
        See Also:
        useDaa()
      • getBinaryAsLongField

        public BinaryAsLongField getBinaryAsLongField​(int length,
                                                      boolean signed)
        Construct and return a BinaryAsLongField, advancing the current offset by its byte length.
        Parameters:
        length - int the length of the field in bytes
        signed - boolean true if the field is signed, false if unsigned.
        Returns:
        BinaryAsLongField
        See Also:
        BinaryAsLongField
      • getBinaryAsIntField

        public BinaryAsIntField getBinaryAsIntField​(int length,
                                                    boolean signed)
        Construct and return a BinaryAsIntField, advancing the current offset by its byte length.
        Parameters:
        length - int the length of the field in bytes
        signed - boolean true if the field is signed, false if unsigned.
        Returns:
        BinaryAsIntField
        See Also:
        BinaryAsIntField
      • getBinaryAsBigIntegerField

        public BinaryAsBigIntegerField getBinaryAsBigIntegerField​(int length,
                                                                  int scale,
                                                                  boolean signed)
        Construct and return a BinaryAsBigIntegerField, advancing the current offset by its byte length.
        Parameters:
        length - the number of bytes in the field
        scale - a negative integer specifying the power of the number
        signed - true if the value is signed
        Returns:
        BinaryAsBigIntegerField
      • getBinaryAsBigIntegerField

        public BinaryAsBigIntegerField getBinaryAsBigIntegerField​(int length,
                                                                  boolean signed)
        Construct and return a BinaryAsBigIntegerField, advancing the current offset by its byte length.
        Parameters:
        length - the number of bytes in the field
        signed - true if the value is signed
        Returns:
        BinaryAsBigIntegerField
      • getBinaryAsBigDecimalField

        public BinaryAsBigDecimalField getBinaryAsBigDecimalField​(int length,
                                                                  int scale,
                                                                  boolean signed)
        Construct and return a BinaryAsBigDecimalField, advancing the current offset by its byte length.
        Parameters:
        length - the size in bytes of the field
        scale - the number of implied decimal digits to the right of the decimal point
        signed - true if the value is signed
        Returns:
        BinaryAsLongField
      • getBinaryField

        public Field getBinaryField​(int length,
                                    boolean signed)
        Construct and return either a BinaryAsIntField, BinaryAsLongField, or BinaryAsBigIntegerField, depending on the length. Advance the current offset by its byte length.
        Parameters:
        length - int the length of the field in bytes
        signed - boolean true if the field is signed, false if unsigned.
        Returns:
        Field
        See Also:
        BinaryAsIntField, BinaryAsLongField
      • getExternalDecimalAsBigDecimalField

        public ExternalDecimalAsBigDecimalField getExternalDecimalAsBigDecimalField​(int precision,
                                                                                    int scale,
                                                                                    boolean signed)
        Construct and return a ExternalDecimalAsBigDecimalField, advancing the current offset by its byte length.
        Parameters:
        precision - the number of decimal digits of precision
        scale - the number of implied decimal digits in the fractional part of the field
        signed - boolean true if the value is signed
        Returns:
        ExternalDecimalAsBigDecimalField
        See Also:
        ExternalDecimalAsBigDecimalField(int, int, int, boolean, boolean, boolean, boolean)
      • getExternalDecimalAsBigDecimalField

        public ExternalDecimalAsBigDecimalField getExternalDecimalAsBigDecimalField​(int precision,
                                                                                    int scale,
                                                                                    boolean signed,
                                                                                    boolean signTrailing,
                                                                                    boolean signExternal,
                                                                                    boolean blankWhenZero)
        Construct and return a ExternalDecimalAsBigDecimalField, advancing the current offset by its byte length.
        Parameters:
        precision - the number of decimal digits of precision
        scale - the number of implied decimal digits in the fractional part of the field
        signed - boolean true if the value is signed
        signTrailing - true if the sign is stored at the end of the field
        signExternal - true if the sign is stored in a separate byte
        blankWhenZero - true if the field is all spaces when zero
        Returns:
        ExternalDecimalAsBigDecimalField
        See Also:
        ExternalDecimalAsBigDecimalField(int, int, int, boolean, boolean, boolean, boolean)
      • getExternalDecimalAsBigIntegerField

        public ExternalDecimalAsBigIntegerField getExternalDecimalAsBigIntegerField​(int precision,
                                                                                    int scale,
                                                                                    boolean signed,
                                                                                    boolean signTrailing,
                                                                                    boolean signExternal,
                                                                                    boolean blankWhenZero)
        Construct and return a ExternalDecimalAsBigIntegerField, advancing the current offset by its byte length.
        Parameters:
        precision - the number of decimal digits of precision
        scale - the number of implied decimal digits in the fractional part of the field
        signed - boolean true if the value is signed
        signTrailing - true if the sign is stored at the end of the field
        signExternal - true if the sign is stored in a separate byte
        blankWhenZero - true if the field is all spaces when zero
        Returns:
        ExternalDecimalAsBigIntegerField
        See Also:
        ExternalDecimalAsBigIntegerField(int, int, int, boolean, boolean, boolean, boolean)
      • getExternalDecimalAsIntField

        public ExternalDecimalAsIntField getExternalDecimalAsIntField​(int precision,
                                                                      boolean signed,
                                                                      boolean signTrailing,
                                                                      boolean signExternal,
                                                                      boolean blankWhenZero)
        Construct and return a ExternalDecimalAsIntField, advancing the current offset by its byte length.
        Parameters:
        precision - the number of decimal digits of precision
        signed - boolean true if the value is signed
        signTrailing - true if the sign is stored at the end of the field
        signExternal - true if the sign is stored in a separate byte
        blankWhenZero - true if the field is all spaces when zero
        Returns:
        ExternalDecimalAsIntField
        See Also:
        ExternalDecimalAsIntField(int, int, boolean, boolean, boolean, boolean)
      • getExternalDecimalAsLongField

        public ExternalDecimalAsLongField getExternalDecimalAsLongField​(int precision,
                                                                        boolean signed,
                                                                        boolean signTrailing,
                                                                        boolean signExternal,
                                                                        boolean blankWhenZero)
        Construct and return a ExternalDecimalAsLongField, advancing the current offset by its byte length.
        Parameters:
        precision - the number of decimal digits of precision
        signed - boolean true if the value is signed
        signTrailing - true if the sign is stored at the end of the field
        signExternal - true if the sign is stored in a separate byte
        blankWhenZero - true if the field is all spaces when zero
        Returns:
        ExternalDecimalAsLongField
        See Also:
        ExternalDecimalAsLongField(int, int, boolean, boolean, boolean, boolean)
      • getExternalDecimalField

        public Field getExternalDecimalField​(int precision,
                                             int scale,
                                             boolean signed,
                                             boolean signTailing,
                                             boolean signExternal,
                                             boolean blankWhenZero)
        Construct and return a ExternalDecimalAs<*>Field, advancing the current offset by its byte length. The actual field returned is based on the precision and scale:
        Parameters:
        precision - the number of decimal digits of precision
        scale - the number of implied decimal digits in the fractional part of the field
        signed - boolean true if the value is signed
        signTailing - true if the sign is stored at the end of the field
        signExternal - true if the sign is stored in a separate byte
        blankWhenZero - true if the field is all spaces when zero
        Returns:
        Field
        See Also:
        ExternalDecimalAsIntField, ExternalDecimalAsLongField, ExternalDecimalAsBigIntegerField, ExternalDecimalAsBigDecimalField
      • getByteArrayField

        public ByteArrayField getByteArrayField​(int length)
        Construct and return a ByteArrayField, advancing the current offset by its byte length.
        Parameters:
        length - the size of the field in bytes
        Returns:
        ByteArrayField
        See Also:
        ByteArrayField(int, int)
      • getIbmFloatField

        public IbmFloatField getIbmFloatField()
        Construct and return an IbmFloatField (COMP-1 in COBOL). Advance the current offset by its byte length.
        Returns:
        IbmFloatField
      • getIbmDoubleField

        public IbmDoubleField getIbmDoubleField()
        Construct and return an IbmDoubleField (COMP-2 in COBOL) Advance the current offset by its byte length.
        Returns:
        IbmFloatField
      • getPackedDecimalAsBigDecimalField

        public PackedDecimalAsBigDecimalField getPackedDecimalAsBigDecimalField​(int precision,
                                                                                int scale,
                                                                                boolean signed)
        Construct and return a PackedDecimalAsBigDecimalField, advancing the current offset by its byte length.
        Parameters:
        precision - the number of decimal digits of precision
        scale - the number of implied decimal digits to the right of the decimal point
        signed - boolean true if the value is signed
        Returns:
        PackedDecimalAsBigDecimalField
        See Also:
        PackedDecimalAsBigDecimalField(int, int, int, boolean)
      • getPackedDecimalAsBigIntegerField

        public PackedDecimalAsBigIntegerField getPackedDecimalAsBigIntegerField​(int precision,
                                                                                int scale,
                                                                                boolean signed)
        Construct and return a PackedDecimalAsBigIntegerField, advancing the current offset by its byte length.
        Parameters:
        precision - the number of decimal digits of precision
        scale - the number of implied decimal digits to the right of the decimal point
        signed - boolean true if the value is signed
        Returns:
        PackedDecimalAsBigIntegerField
        See Also:
        PackedDecimalAsBigIntegerField(int, int, int, boolean)
      • getPackedDecimalAsIntField

        public PackedDecimalAsIntField getPackedDecimalAsIntField​(int precision,
                                                                  boolean signed)
        Construct and return a PackedDecimalAsIntField, advancing the current offset by its byte length.
        Parameters:
        precision - the number of decimal digits of precision
        signed - boolean true if the value is signed
        Returns:
        PackedDecimalAsIntField
        See Also:
        PackedDecimalAsIntField(int, int, boolean)
      • getPackedDecimalAsLongField

        public PackedDecimalAsLongField getPackedDecimalAsLongField​(int precision,
                                                                    boolean signed)
        Construct and return a PackedDecimalAsLongField, advancing the current offset by its byte length.
        Parameters:
        precision - the number of decimal digits of precision
        signed - boolean true if the value is signed
        Returns:
        PackedDecimalAsLongField
        See Also:
        PackedDecimalAsLongField(int, int, boolean)
      • getPackedDecimalField

        public abstract Field getPackedDecimalField​(int precision,
                                                    int scale,
                                                    boolean signed)
        Construct and return a PackedDecimalAs<*>Field, depending on the length and scale requested. Advance the current offset by its byte length.
        Parameters:
        precision - the length of the field in decimal digits
        scale - the number of digits to the right of the decimal point
        signed - true if the field is signed, false if unsigned
        Returns:
        a PackedDecimalAs<*>Field.
        See Also:
        PackedDecimalAsIntField, PackedDecimalAsLongField, PackedDecimalAsBigIntegerField, PackedDecimalAsBigDecimalField
      • getStringField

        public StringField getStringField​(int length)
        Construct and return a StringField, advancing the current offset by its byte length.
        Parameters:
        length - the length of the field in bytes.
        Returns:
        StringField
      • getStringField

        public StringField getStringField​(int length,
                                          boolean trim)
        Construct and return a StringField, advancing the current offset by its byte length.
        Parameters:
        length -
        trim -
        Returns:
        StringField
        See Also:
        StringField(int, int, boolean)
      • getStringField

        public StringField getStringField​(int length,
                                          boolean trim,
                                          boolean padLeft,
                                          boolean allowTruncation,
                                          java.lang.String encoding)
        Construct and return a StringField, advancing the current offset by its byte length.
        Parameters:
        length - the length of the field in bytes.
        trim - true if the String returned from the underlying byte array is to be trimmed of leading (padLeft == true) or trailing (padLeft == false) blanks.
        padLeft - true if small values are to be left-padded with blanks
        allowTruncation - true if large Strings are to be right-truncated. If false an IllegalArgumentException will be thrown.
        encoding - the character set encoding. This is assumed to be an EBCDIC variant.
        Returns:
        StringField
      • getStringField

        public StringField getStringField​(int length,
                                          boolean trim,
                                          boolean padLeft,
                                          boolean allowTruncation)
        Construct and return a StringField, advancing the current offset by its byte length.
        Parameters:
        length - the length of the field in bytes.
        trim - true if the String returned from the underlying byte array is to be trimmed of leading (padLeft == true) or trailing (padLeft == false) blanks.
        padLeft - true if small values are to be left-padded with blanks
        allowTruncation - true if large Strings are to be right-truncated. If false an IllegalArgumentException will be thrown.
        Returns:
        StringField
      • getStringField

        public StringField getStringField​(int length,
                                          boolean trim,
                                          boolean padLeft)
        Construct and return a StringField, advancing the current offset by its byte length.
        Parameters:
        length - the length of the field in bytes.
        trim - true if the String returned from the underlying byte array is to be trimmed of leading (padLeft == true) or trailing (padLeft == false) blanks.
        padLeft - true if small values are to be left-padded with blanks
        Returns:
        StringField