Package com.nt.udc.ndk.node
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
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
protected int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
protected byte[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
static DCField
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.boolean
Compares the value of this DCField withoa
boolean
equalsValue
(DCField comparisonField) byte[]
getBytes()
Deprecated.byte[]
byte
static DCField
getDCField
(FieldKey key, int type, byte[] value) static DCField
getDCField
(FieldKey id, int type, String value) static DCField
getDCField
(FieldKey id, int type, String s, String operation, String original_value) double
float
getID()
int
final FieldKey
getKey()
int
Deprecated.Use isEmpty to determine if field is emptylong
short
static final int
getStaticAttrLength
(int type) Deprecated.types.int
getType()
protected void
init
(int sid, byte[] inValues) Set the id and value members to the values providedprotected void
protected void
Set the id and value members to the values providedboolean
isEmpty()
static final boolean
isVarLength
(int type) Deprecated.static DCField
makeAttrfromBytes
(byte[] attrBytes, int offset) Deprecated.static DCField
makeAttrfromBytes
(int id, int type, byte[] valueBytes) Deprecated.static DCField
makeAttrfromBytes
(FieldKey id, int type, byte[] valueBytes) static DCField
makeAttrfromBytes
(String id, int type, byte[] valueBytes) Deprecated.Use makeAttrfromBytes(Fielkey,...)static DCField
Deprecated.void
void
setID
(int newID) Deprecated.void
Deprecated.final void
protected void
setType
(int t) Sets the type for this DCField objectvoid
setValue
(byte[] valueBytes) Sets the value of this DCField to what is contained invalueBytes
toString()
int
-
Field Details
-
STRING
public static final int STRING- See Also:
-
INTEGER
public static final int INTEGER- See Also:
-
LONG
public static final int LONG- See Also:
-
TIMEINSECONDS
public static final int TIMEINSECONDS- See Also:
-
IP
public static final int IP- See Also:
-
TIMEINMILLIS
public static final int TIMEINMILLIS- See Also:
-
MAC
public static final int MAC- See Also:
-
UINT128
public static final int UINT128- See Also:
-
BYTE
public static final int BYTE- See Also:
-
SHORT
public static final int SHORT- See Also:
-
IPV6
public static final int IPV6- See Also:
-
FLOAT
public static final int FLOAT- See Also:
-
DOUBLE
public static final int DOUBLE- See Also:
-
BYTES
public static final int BYTES- See Also:
-
OBJECT
public static final int OBJECT- See Also:
-
LIST
public static final int LIST- See Also:
-
NULL
public static final int NULL- See Also:
-
MAP
public static final int MAP- See Also:
-
ATTR_HEADER_SIZE
public static final int ATTR_HEADER_SIZE- See Also:
-
value
protected byte[] value -
datatype
protected int datatype
-
-
Constructor Details
-
DCField
public DCField() -
DCField
-
-
Method Details
-
getByteValue
- Throws:
ClassCastException
-
getDateValue
- Throws:
ClassCastException
-
getDoubleValue
- Throws:
ClassCastException
-
getFloatValue
- Throws:
ClassCastException
-
getIntValue
- Throws:
ClassCastException
-
getLongValue
- Throws:
ClassCastException
-
getShortValue
- Throws:
ClassCastException
-
getStringValue
- Throws:
ClassCastException
-
clone
-
makeAttrfromStream
Deprecated.Method to make a DCField from the given stream -
makeAttrfromBytes
Deprecated.Method to make an DCField from an array of bytes -
makeAttrfromBytes
Deprecated.Method to make an DCField from an array of bytes -
create
-
getDCField
-
getDCField
-
getDCField
-
makeAttrfromBytes
Deprecated.Use makeAttrfromBytes(Fielkey,...) -
makeAttrfromBytes
-
dup
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.Indicates whether the given type is a variable length type- Returns:
true
, iftype
is variable length (of type String)
-
getStaticAttrLength
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
Set the id and value members to the values provided -
init
-
getBytes
Deprecated.Streams the entire field into a byte array- Returns:
- byte array that was generated from this field
-
toString
-
getKey
-
setKey
-
getID
- Returns:
- the ID for this DCField object
-
setID
Deprecated.Sets the ID for this DCField object- Parameters:
newID
- the id for this DCField object
-
setID
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.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
Sets the value of this DCField to what is contained invalueBytes
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
Compares the value of this DCField withoa
- Returns:
true
, if the type and length of this NARField are the same as those foroa
-
equalsValue
-
writeValueToStream
- Throws:
IOException
-
readValueFromStream
- Throws:
IOException
-