Class DataObject


  • public class DataObject
    extends java.lang.Object
    Container class holding data about to send to the smart meter or received by the smart meter

    Either stores a Number, List of DataObjects, a byte array, BitString or a subtype CosemDateFormat.

    • Method Detail

      • newArrayData

        public static DataObject newArrayData​(java.util.List<DataObject> array)
        Constructs a array data.

        COSEM Type DataObject.Type.ARRAY

        Parameters:
        array - The array of values
        Returns:
        The data
        Throws:
        java.lang.IllegalArgumentException - If a sub element of array has another data type than the first
      • newBoolData

        public static DataObject newBoolData​(boolean bool)
        Constructs a bool data.

        COSEM Type DataObject.Type.BOOLEAN

        Parameters:
        bool - The structure of values
        Returns:
        The data
      • newBitStringData

        public static DataObject newBitStringData​(BitString bitString)
                                           throws java.lang.IllegalArgumentException
        Constructs a bit string data.

        COSEM Type DataObject.Type.BIT_STRING

        Parameters:
        bitString - The BitString object holding the bit string
        Returns:
        The data
        Throws:
        java.lang.IllegalArgumentException
      • newInteger32Data

        public static DataObject newInteger32Data​(int int32)
        Constructs a int 32 data.

        COSEM Type DataObject.Type.DOUBLE_LONG

        Parameters:
        int32 - he number to store
        Returns:
        The data
      • newUInteger32Data

        public static DataObject newUInteger32Data​(long uIn32)
        Constructs a unsigned int 32 data.

        COSEM Type DataObject.Type.DOUBLE_LONG_UNSIGNED

        Parameters:
        uIn32 - he number to store
        Returns:
        The data
        Throws:
        java.lang.IllegalArgumentException - if uInt32 is > 2^(32)-1 or negative
      • newOctetStringData

        public static DataObject newOctetStringData​(byte[] string)
        Constructs a byte array data.

        COSEM Type DataObject.Type.OCTET_STRING

        Parameters:
        string - The byte array to store
        Returns:
        The data
      • newVisibleStringData

        public static DataObject newVisibleStringData​(byte[] string)
        Constructs a string, encoded as byte array data.

        COSEM Type DataObject.Type.VISIBLE_STRING

        Parameters:
        string - The byte string to store
        Returns:
        The data
      • newUtf8StringData

        public static DataObject newUtf8StringData​(byte[] string)
        Constructs a UTF-8 string, encoded as byte array data.

        COSEM Type DataObject.Type.UTF8_STRING

        Parameters:
        string - The byte string to store
        Returns:
        The data
      • newBcdData

        public static DataObject newBcdData​(byte bcd)
                                     throws java.lang.IllegalArgumentException
        Constructs a 2 digit BCD number data

        COSEM Type DataObject.Type.BCD

        Parameters:
        bcd - The BCD number to store
        Returns:
        The data
        Throws:
        java.lang.IllegalArgumentException
      • newInteger8Data

        public static DataObject newInteger8Data​(byte int8)
                                          throws java.lang.IllegalArgumentException
        Constructs a int 8 data

        COSEM Type DataObject.Type.INTEGER

        Parameters:
        int8 - The number to store
        Returns:
        The data
        Throws:
        java.lang.IllegalArgumentException
      • newUInteger8Data

        public static DataObject newUInteger8Data​(short uInt8)
                                           throws java.lang.IllegalArgumentException
        Constructs a unsigned int 8 data

        COSEM Type DataObject.Type.UNSIGNED

        Parameters:
        uInt8 - The number to store
        Returns:
        The data
        Throws:
        java.lang.IllegalArgumentException - if uInt8 > 2^(8)-1 or negative
      • newInteger16Data

        public static DataObject newInteger16Data​(short int16)
        Constructs a int 16 data

        COSEM Type DataObject.Type.LONG_INTEGER

        Parameters:
        int16 - The number to store
        Returns:
        The data
      • newUInteger16Data

        public static DataObject newUInteger16Data​(int uInt16)
        Constructs a unsigned int 16 data.

        COSEM Type DataObject.Type.LONG_UNSIGNED

        Parameters:
        uInt16 - The number to store
        Returns:
        The data
        Throws:
        java.lang.IllegalArgumentException - If newVal > 2^(16)-1 or negative
      • newInteger64Data

        public static DataObject newInteger64Data​(long int64)
        Constructs a int 64 data.

        COSEM Type DataObject.Type.LONG64

        Parameters:
        int64 - The number to store
        Returns:
        The data
      • newUInteger64Data

        public static DataObject newUInteger64Data​(long uInt64)
        Constructs a unsigned int 64 data

        COSEM Type DataObject.Type.LONG64_UNSIGNED

        Parameters:
        uInt64 - The number to store
        Returns:
        The data
        Throws:
        java.lang.IllegalArgumentException - if uInt64 is negative
      • newEnumerateData

        public static DataObject newEnumerateData​(int enumVal)
        Constructs a enum data.

        COSEM Type DataObject.Type.ENUMERATE

        Parameters:
        enumVal - The enum value to store
        Returns:
        The data
        Throws:
        java.lang.IllegalArgumentException - if newVal is > 2^(8)-1 or negative
      • newFloat32Data

        public static DataObject newFloat32Data​(float float32)
        Constructs a 32 bit floating point number data.

        COSEM Type DataObject.Type.FLOAT32

        Parameters:
        float32 - The number to store
        Returns:
        The data
      • newFloat64Data

        public static DataObject newFloat64Data​(double float64)
        Constructs a 64 bit floating point number data.

        COSEM Type DataObject.Type.FLOAT64

        Parameters:
        float64 - The number to store
        Returns:
        The data
      • newDateTimeData

        public static DataObject newDateTimeData​(CosemDateTime dateTime)
        Constructs a calendar datum holding date and time

        COSEM Type DataObject.Type.DATE_TIME

        Parameters:
        dateTime - The date and time to store
        Returns:
        The data
      • newDateData

        public static DataObject newDateData​(CosemDate date)
        Constructs a calendar datum holding a date

        COSEM Type DataObject.Type.DATE

        Parameters:
        date - The date store
        Returns:
        The data
      • newTimeData

        public static DataObject newTimeData​(CosemTime time)
        Constructs a calendar datum holding a time

        COSEM Type DataObject.Type.TIME

        Parameters:
        time - The time store
        Returns:
        The data
      • getValue

        public <T> T getValue()
                       throws java.lang.ClassCastException
        Returns the value.
        Type Parameters:
        T - the type in which the raw data should be cast.
        Returns:
        the typed value.
        Throws:
        java.lang.ClassCastException - when the value doesn't match the assigned type.
        See Also:
        getType()
      • getRawValue

        public java.lang.Object getRawValue()
        Returns the raw object-value.
        Returns:
        the raw object-value.
      • isBitString

        public boolean isBitString()
        Is used to determine if the data contains a BitString object.
        Returns:
        true if it contains a BitString object.
      • isNumber

        public boolean isNumber()
        Checks if the data of this container is a number
        Returns:
        true data is a number.
      • isBoolean

        public boolean isBoolean()
        Checks if the data of this container is a boolean.
        Returns:
        true if the data is a boolean.
      • isNull

        public boolean isNull()
        Checks if the data of this container is null.
        Returns:
        true if the data is null.
      • toString

        public java.lang.String toString()
        Returns a string representation of the DataObject.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the string representation of the object.