Class DCField

java.lang.Object
com.nt.udc.ndk.node.DCField
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
ByteField, BytesField, DoubleField, FloatField, IntField, IPField, ListField, LongField, MacField, MapField, MillisField, NullField, ObjectField, SecondsField, ShortField, StringField

public abstract class DCField extends Object implements Serializable, Cloneable
This is the abstract class for all DCField objects. DCField objects have a binary format as well, for the most part used when writing out to disk or for storage in a byte array. The following is an illustration of the current binary format of a given DCField object: Byte 0 1 2 3 --------------------------------- Word 1: ID ID ID ID Word 2: Type Len Len Len Word 3: Value Value Value Value . . Word n: Value Value Value Value Please note that the length, as it is stored in binary form, is the length of the WHOLE attribute, including the header. (i.e., NOT just the length of the value!) However, the length, as stored in the "LENGTH" constants of the various fields, is the length of the value. A "LENGTH" constant of -1 denotes a variable length.
See Also:
  • Field Details

  • Constructor Details

    • DCField

      public DCField()
    • DCField

      public DCField(FieldKey key)
  • Method Details

    • getByteValue

      public byte getByteValue() throws ClassCastException
      Throws:
      ClassCastException
    • getDateValue

      public Date getDateValue() throws ClassCastException
      Throws:
      ClassCastException
    • getDoubleValue

      public double getDoubleValue() throws ClassCastException
      Throws:
      ClassCastException
    • getFloatValue

      public float getFloatValue() throws ClassCastException
      Throws:
      ClassCastException
    • getIntValue

      public int getIntValue() throws ClassCastException
      Throws:
      ClassCastException
    • getLongValue

      public long getLongValue() throws ClassCastException
      Throws:
      ClassCastException
    • getShortValue

      public short getShortValue() throws ClassCastException
      Throws:
      ClassCastException
    • getStringValue

      public String getStringValue() throws ClassCastException
      Throws:
      ClassCastException
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • makeAttrfromStream

      @Deprecated public static DCField makeAttrfromStream(DataInputStream dis)
      Deprecated.
      Method to make a DCField from the given stream
    • makeAttrfromBytes

      @Deprecated public static DCField makeAttrfromBytes(byte[] attrBytes, int offset)
      Deprecated.
      Method to make an DCField from an array of bytes
    • makeAttrfromBytes

      @Deprecated public static DCField makeAttrfromBytes(int id, int type, byte[] valueBytes)
      Deprecated.
      Method to make an DCField from an array of bytes
    • create

      public static DCField create(int type, FieldKey key)
    • getDCField

      public static DCField getDCField(FieldKey id, int type, String value)
    • getDCField

      public static DCField getDCField(FieldKey key, int type, byte[] value)
    • getDCField

      public static DCField getDCField(FieldKey id, int type, String s, String operation, String original_value)
    • makeAttrfromBytes

      @Deprecated public static DCField makeAttrfromBytes(String id, int type, byte[] valueBytes)
      Deprecated.
      Use makeAttrfromBytes(Fielkey,...)
    • makeAttrfromBytes

      public static DCField makeAttrfromBytes(FieldKey id, int type, byte[] valueBytes)
    • dup

      public DCField dup(FieldKey newKey)
      Given an existing field and a name key name, return a new field with the same type and value as the original, but with the new key.
      Parameters:
      newKey - The key for the new field
      Returns:
      A new Field with the old value, and new key.
    • isVarLength

      @Deprecated public static final boolean isVarLength(int type)
      Deprecated.
      Indicates whether the given type is a variable length type
      Returns:
      true, if type is variable length (of type String)
    • getStaticAttrLength

      @Deprecated public static final int getStaticAttrLength(int type)
      Deprecated.
      types.
      This method returns the byte size for static-length Field
    • init

      protected void init(int sid, byte[] inValues)
      Set the id and value members to the values provided
    • init

      protected void init(String sid, byte[] inValues)
      Set the id and value members to the values provided
    • init

      protected void init(FieldKey sid, byte[] inValues)
    • getBytes

      @Deprecated public byte[] getBytes()
      Deprecated.
      Streams the entire field into a byte array
      Returns:
      byte array that was generated from this field
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getKey

      public final FieldKey getKey()
    • setKey

      public final void setKey(FieldKey key)
    • getID

      public String getID()
      Returns:
      the ID for this DCField object
    • setID

      @Deprecated public void setID(int newID)
      Deprecated.
      Sets the ID for this DCField object
      Parameters:
      newID - the id for this DCField object
    • setID

      @Deprecated public void setID(String newID)
      Deprecated.
      Sets the ID for this DCField object
      Parameters:
      newID - the id for this DCField object
    • getType

      public int getType()
      Returns:
      the type for this DCField object
    • setType

      protected void setType(int t)
      Sets the type for this DCField object
      Parameters:
      t - the type for this DCField object.
    • isEmpty

      public boolean isEmpty()
    • getLength

      @Deprecated public int getLength()
      Deprecated.
      Use isEmpty to determine if field is empty
      Returns:
      the length of this DCField's byte array
    • getBytesValue

      public byte[] getBytesValue()
      Returns:
      a byte array containing the value of this DCField
    • setValue

      public void setValue(byte[] valueBytes) throws NDKException
      Sets the value of this DCField to what is contained in valueBytes

      NOTE: Caveat Machinator (Engineer beware)
      At this time, there is no validation of the byte array passed in to this method. The developer should ensure that the bytes used to create this DCField object are appropriate for the specific data type. For example, a byte[] consisting of 7 bytes should not be used to create an IntField object.

      Throws:
      NDKException
    • equals

      public boolean equals(DCField oa)
      Compares the value of this DCField with oa
      Returns:
      true, if the type and length of this NARField are the same as those for oa
    • equalsValue

      public boolean equalsValue(DCField comparisonField)
    • writeValueToStream

      public int writeValueToStream(OutputStream out) throws IOException
      Throws:
      IOException
    • readValueFromStream

      public void readValueFromStream(InputStream in) throws IOException
      Throws:
      IOException