Class BERIntegral

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    BEREnumerated, BERInteger

    public abstract class BERIntegral
    extends BERElement
    This is the base class for integral types such as Integer and Enumerated.
     ENCODING RULE:
       Primitive Definite length.
       tag = << depends on type >>
       length = (short or long form)
       one or more contents octets hold integral value
       value in two's complement
    
     Example 1:  (Integer - zero)
       02 01 00
     Example 2:  (Enumerated - 1)
       0A 01 01
     Example 3:  (Integer - 300, short form)
       02 02 01 2C
     Example 4:  (Integer - 300, long form)
       02 84 00 00 01 2C
     
    Version:
    1.0 seeAlso CCITT X.209
    See Also:
    Serialized Form
    • Constructor Detail

      • BERIntegral

        public BERIntegral​(int value)
        Constructs an integral type with a value.
        Parameters:
        value - integer value
      • BERIntegral

        public BERIntegral​(java.io.InputStream stream,
                           int[] bytes_read)
                    throws java.io.IOException
        Constructs an integral element from an input stream.
        Parameters:
        stream - source
        bytes_read - array of 1 int; value incremented by number of bytes read from stream
        Throws:
        java.io.IOException - failed to construct
    • Method Detail

      • write

        public void write​(java.io.OutputStream stream)
                   throws java.io.IOException
        Writes BER to stream.
        Specified by:
        write in class BERElement
        Parameters:
        stream - output stream
        Throws:
        java.io.IOException - on failure to write
      • getValue

        public int getValue()
        Gets the integral value.
        Returns:
        element value.
      • getType

        public abstract int getType()
        Gets the element type.
        Specified by:
        getType in class BERElement
        Returns:
        element type.
      • toString

        public abstract java.lang.String toString()
        Gets the string representation.
        Specified by:
        toString in class BERElement
        Returns:
        string representation of tag.