public class NAR extends java.lang.Object implements DCFieldContainer, java.io.Serializable, java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
static int |
BYTE_ARRAY_TYPE |
static int |
BYTE_TYPE |
static int |
DOUBLE_TYPE |
static int |
FLOAT_TYPE |
static int |
INT_TYPE |
static int |
IP_TYPE |
static int |
LIST_TYPE |
static int |
LONG_TYPE |
static int |
MAC_TYPE |
static int |
MAP_TYPE |
static int |
NULL_TYPE |
static int |
OBJECT_TYPE |
static int |
SHORT_TYPE |
static int |
STRING_TYPE |
static int |
TIMEINMILLIS_TYPE |
static int |
TIMEINSECONDS_TYPE |
static int |
UINT128_TYPE |
Constructor and Description |
---|
NAR() |
NAR(byte[] bytes)
Creates an NAR, where the NAR is completely in byte form.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(DCField attr)
Deprecated.
Use Use setField(DCField)
|
void |
addAttribute(int id,
byte value)
Deprecated.
Use setField(DCField)
|
void |
addAttribute(int id,
int value)
Deprecated.
Use setField(DCField)
|
void |
addAttribute(int id,
int type,
byte[] value)
Deprecated.
Use setField(DCField)
|
void |
addAttribute(int id,
int type,
java.lang.String s)
Deprecated.
use Use setField(DCField)
|
void |
addAttribute(int id,
long value)
Deprecated.
Use setField(DCField)
|
void |
addAttribute(int id,
short value)
Deprecated.
Use setField(DCField)
|
void |
addAttribute(int id,
java.lang.String value)
Deprecated.
Use setField(DCField)
|
void |
addMillisAttribute(int id,
long time)
Deprecated.
Use setField(DCField)
|
void |
addSecondsAttribute(int id,
int time)
Deprecated.
Use setField(DCField)
|
java.lang.Object |
clone()
Creates a copy of this NAR.
|
void |
clone(NAR newnar)
Copies this into the given NAR.
|
boolean |
containsAttr(int id)
Deprecated.
use containsField(FieldKey)
|
boolean |
containsField(FieldKey id) |
java.lang.String |
convertNarToFormattedString() |
java.lang.String |
convertNarToString() |
java.lang.String |
convertNarToString(com.nt.udc.datadictparser.DataDictionary dd)
Deprecated.
|
void |
disposeByteArray() |
boolean |
fieldExist(FieldKey key)
A proper implementation of fieldExist().
|
static NAR |
fromBytes(byte[] b) |
DCField[] |
getAllAttributes()
The method to getAttr all DCFields
|
byte |
getAttrAsByte(int id)
Gets the byte value of the attribute associated with the specified id.
|
byte[] |
getAttrAsBytes(int id)
Deprecated.
|
java.util.Date |
getAttrAsDate(int id)
Deprecated.
use getField(FieldKey)
|
double |
getAttrAsDouble(int id)
Deprecated.
use getField(FieldKey)
|
float |
getAttrAsFloat(int id)
Deprecated.
use getField(FieldKey)
|
int |
getAttrAsInt(int id)
Deprecated.
use getField(FieldKey)
|
ListField |
getAttrAsList(int id)
Deprecated.
|
long |
getAttrAsLong(int id)
Deprecated.
use getField(FieldKey)
|
long |
getAttrAsMillis(int id)
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT
represented by the attribute associated with the specified id.
|
java.lang.Object |
getAttrAsObject(int id)
Deprecated.
|
short |
getAttrAsShort(int id)
Deprecated.
use getField(FieldKey)
|
java.lang.String |
getAttrAsString(int id)
Deprecated.
use getField(FieldKey)
|
java.util.Date |
getAttrAsTime(int id)
Gets the
Time value of the attribute associated with the
specified id. |
DCField |
getAttribute(int id)
Deprecated.
use getField(FieldKey)
|
DCField |
getAttribute(java.lang.String id)
Deprecated.
use getField(FieldKey)
|
byte[] |
getAttributeValueBytes(FieldKey key)
Returns the attribute's value in bytes.
|
byte[] |
getAttributeValueBytes(int id)
Deprecated.
|
byte[] |
getAttributeValueBytes(java.lang.String id)
Deprecated.
|
int |
getAttrType(int id)
Deprecated.
|
int |
getAttrType(java.lang.String id)
Gets the type of the attribute associated with the specified id.
|
DCField |
getField(FieldKey id) |
DCField |
getField(int id)
Deprecated.
Should use getAttribute(String)
|
DCField |
getField(java.lang.String id)
Deprecated.
Should use getAttribute(String)
|
byte[] |
getFieldValue(FieldKey key) |
byte[] |
getFieldValue(int id)
Deprecated.
|
byte[] |
getFieldValue(java.lang.String id)
Deprecated.
|
int |
getLength() |
int |
getNumAttrs()
The method to getAttr the number of attributes
|
int |
getType(int id) |
int |
getType(java.lang.String id)
Returns the type of the given field.
|
byte |
lookupByte(int attrId)
Deprecated.
|
byte |
lookupByte(java.lang.String attrId)
Deprecated.
|
void |
lookupDataBytes(int attrId,
byte[] barr,
int barrOffset)
Deprecated.
|
void |
lookupDataBytes(java.lang.String attrId,
byte[] barr,
int barrOffset)
Deprecated.
|
int |
lookupDataLength(int attrId)
Deprecated.
|
int |
lookupDataLength(java.lang.String attrId)
Deprecated.
|
int |
lookupDataType(int attrId)
Deprecated.
|
int |
lookupDataType(java.lang.String attrId)
Deprecated.
Should use getAttrType instead
|
double |
lookupDouble(int attrId)
Deprecated.
|
double |
lookupDouble(java.lang.String attrId)
Deprecated.
|
float |
lookupFloat(int attrId)
Deprecated.
|
float |
lookupFloat(java.lang.String attrId)
Deprecated.
|
int |
lookupInt(int attrId)
Deprecated.
|
int |
lookupInt(java.lang.String attrId)
Deprecated.
|
long |
lookupLong(int attrId)
Deprecated.
|
long |
lookupLong(java.lang.String attrId)
Deprecated.
|
short |
lookupShort(int attrId)
Deprecated.
|
short |
lookupShort(java.lang.String attrId)
Deprecated.
|
java.lang.String |
lookupString(int attrId)
Deprecated.
|
java.lang.String |
lookupString(java.lang.String attrId)
Deprecated.
|
void |
prepareByteArray()
Something for Multithreaded AP (and EP in the future) to use.
|
boolean |
readByteArray(byte[] barray) |
boolean |
readObject(java.io.InputStream in) |
DCField |
remove(int id)
Deprecated.
use remove(FieldKey)
|
DCField |
remove(java.lang.String id)
Deprecated.
use remove(FieldKey)
|
DCField |
removeAttribute(int id)
Deprecated.
use removeField(FieldKey)
|
DCField |
removeAttribute(java.lang.String id)
Deprecated.
use removeField(FieldKey)
|
DCField |
removeField(FieldKey key) |
void |
setField(DCField field)
Sets a field from its DCField form
|
void |
setField(FieldKey attrId,
int type,
byte[] value) |
void |
setField(int id,
int type,
byte[] value)
Deprecated.
use setField(DCField)
|
void |
setField(java.lang.String fieldId,
int type,
byte[] value)
Sets a field, with the given ID, type and value.
|
void |
shiftAttribute(int oldId,
int newId)
Deprecated.
|
int |
size() |
byte[] |
toByteArray()
Returns a copy of the NAR's byte array.
|
java.lang.String |
toFormattedString() |
java.lang.String |
toFormattedString(com.nt.udc.datadictparser.DataDictionary dd) |
static NAR[] |
toRecArray(byte[] b) |
void |
toStream(java.io.OutputStream oStream)
The method outputs an NAR to the output stream
|
java.lang.String |
toString()
Converts the data contained in this object to a String
|
java.lang.String |
toString(com.nt.udc.datadictparser.DataDictionary dd) |
void |
update(FieldKey key,
DCField value) |
byte[] |
writeByteArray() |
int |
writeObject(java.io.OutputStream out) |
public static final int NULL_TYPE
public static final int BYTE_TYPE
public static final int SHORT_TYPE
public static final int INT_TYPE
public static final int FLOAT_TYPE
public static final int LONG_TYPE
public static final int DOUBLE_TYPE
public static final int BYTE_ARRAY_TYPE
public static final int STRING_TYPE
public static final int TIMEINSECONDS_TYPE
public static final int IP_TYPE
public static final int TIMEINMILLIS_TYPE
public static final int MAC_TYPE
public static final int UINT128_TYPE
public static final int OBJECT_TYPE
public static final int LIST_TYPE
public static final int MAP_TYPE
public NAR()
public NAR(byte[] bytes)
bytes
- bytes of the NARpublic void clone(NAR newnar)
newnar
- Empty, or NAR being updatedpublic java.lang.Object clone()
clone
in interface DCFieldContainer
clone
in class java.lang.Object
public void toStream(java.io.OutputStream oStream) throws java.io.IOException
oStream
- output stream to write the NAR tojava.io.IOException
public final byte[] toByteArray()
toByteArray
in interface DCFieldContainer
public final void addAttribute(int id, byte value)
public final void addAttribute(int id, short value)
public final void addAttribute(int id, int value)
public final void addAttribute(int id, long value)
public final void addAttribute(int id, java.lang.String value)
public void addMillisAttribute(int id, long time)
TIMEINMILLIS
attribute to the NAR.
If there is an attribute already associated with id, its value is replaced.id
- the id of the attributetime
- the time in milliseconds value of the attributepublic void addSecondsAttribute(int id, int time)
TIMEINSECONDS
attribute to the NAR.
If there is an attribute already associated with id, its value is replaced.id
- the id of the attributetime
- the time in seconds value of the attributepublic final void addAttribute(int id, int type, java.lang.String s)
public final void addAttribute(int id, int type, byte[] value)
public final void addAttribute(DCField attr)
public void shiftAttribute(int oldId, int newId)
oldId
- Old attribute IDnewId
- New attribute IDpublic DCField removeAttribute(int id)
id
- id of the attributepublic DCField removeAttribute(java.lang.String id)
id
- id of the attributepublic DCField remove(int id)
id
- public DCField remove(java.lang.String id)
id
- public DCField getAttribute(int id)
id
- id of the attributepublic DCField getAttribute(java.lang.String id)
id
- id of the attributepublic DCField[] getAllAttributes()
public byte[] getAttributeValueBytes(java.lang.String id)
id
- id of the attributepublic byte[] getAttributeValueBytes(FieldKey key)
public byte[] getAttributeValueBytes(int id)
id
- public boolean containsAttr(int id)
id
- the id of the attributetrue
if an attribute with the given id exists
in this NAR; false
otherwisepublic boolean containsField(FieldKey id)
public int getAttrType(java.lang.String id)
id
- the id of the attributepublic int getAttrType(int id)
id
- public int getNumAttrs()
public java.lang.String toString(com.nt.udc.datadictparser.DataDictionary dd)
public java.lang.String toString()
DCFieldContainer
toString
in interface DCFieldContainer
toString
in class java.lang.Object
public java.lang.String toFormattedString(com.nt.udc.datadictparser.DataDictionary dd)
public java.lang.String toFormattedString()
public int size()
public java.lang.String convertNarToString(com.nt.udc.datadictparser.DataDictionary dd)
public java.lang.String convertNarToFormattedString()
public java.lang.String convertNarToString()
public byte getAttrAsByte(int id) throws java.lang.NoSuchFieldException, UnsupportedTypeException
BYTE
attribute types.id
- the id of the attributejava.lang.NoSuchFieldException
- Thrown when the given id is not found.UnsupportedTypeException
- Thrown when the type of the id
cannot be converted to the return
type.public byte[] getAttrAsBytes(int id)
BYTES
attribute types.id
- the id of the attributepublic short getAttrAsShort(int id) throws java.lang.NoSuchFieldException, UnsupportedTypeException
SHORT
,
BYTE
, and two byte STRING
attribute types.id
- the id of the attributejava.lang.NoSuchFieldException
- Thrown when the given id is not found.UnsupportedTypeException
- Thrown when the type of the id
cannot be converted to the return
type.public int getAttrAsInt(int id) throws java.lang.NoSuchFieldException, UnsupportedTypeException
INTEGER
, BYTE
,
SHORT
, IP
, TIMEINSECONDS
and four byte STRING
attribute types.id
- the id of the attributejava.lang.NoSuchFieldException
- Thrown when the given id is not found.UnsupportedTypeException
- Thrown when the type of the id
cannot be converted to the return
type.public long getAttrAsLong(int id) throws java.lang.NoSuchFieldException, UnsupportedTypeException
LONG
, BYTE
,
SHORT
, INTEGER
, TIMEINSECONDS
IP
, FLOAT
, TIMEINMILLIS
,
MAC
, DOUBLE
and eight byte STRING
attribute types.id
- the id of the attributejava.lang.NoSuchFieldException
- Thrown when the given id is not found.UnsupportedTypeException
- Thrown when the type of the id
cannot be converted to the return
type.public float getAttrAsFloat(int id) throws java.lang.NoSuchFieldException, UnsupportedTypeException
FLOAT
, BYTE
,
SHORT
, INTEGER
, TIMEINSECONDS
and four byte STRING
attribute types.id
- the id of the attributejava.lang.NoSuchFieldException
- Thrown when the given id is not found.UnsupportedTypeException
- Thrown when the type of the id
cannot be converted to the return
type.public double getAttrAsDouble(int id) throws java.lang.NoSuchFieldException, UnsupportedTypeException
DOUBLE
, BYTE
,
SHORT
, INTEGER
, TIMEINSECONDS
,
FLOAT
, TIMEINMILLIS
, LONG
and eight byte STRING
attribute types.id
- the id of the attributejava.lang.NoSuchFieldException
- Thrown when the given id is not found.UnsupportedTypeException
- Thrown when the type of the id
cannot be converted to the return
type.public java.util.Date getAttrAsDate(int id) throws java.lang.NoSuchFieldException, UnsupportedTypeException
Date
value of the attribute associated with the
specified id.
This method should only be used for BYTE
, SHORT
,
INTEGER
, TIMEINSECONDS
, FLOAT
,
LONG
, TIMEINMILLIS
, DOUBLE
and
eight byte STRING
attribute types.id
- the id of the attributeDate
value of the attribute associatedi
with the specified idjava.lang.NoSuchFieldException
- Thrown when the given id is not found.UnsupportedTypeException
- Thrown when the type of the id
cannot be converted to the return
type.public java.lang.String getAttrAsString(int id) throws java.lang.NoSuchFieldException, UnsupportedTypeException, java.io.IOException, java.lang.ClassNotFoundException
id
- the id of the attributejava.lang.NoSuchFieldException
- Thrown when the given id is not found.UnsupportedTypeException
- Thrown when the type of the id
cannot be converted to the return
type.java.io.IOException
java.lang.ClassNotFoundException
public long getAttrAsMillis(int id) throws java.lang.NoSuchFieldException, UnsupportedTypeException
BYTE
, SHORT
,
INTEGER
, TIMEINSECONDS
, FLOAT
,
LONG
, TIMEINMILLIS
, DOUBLE
and
eight byte STRING
attribute types.id
- the id of the attributejava.lang.NoSuchFieldException
- Thrown when the given id is not found.UnsupportedTypeException
- Thrown when the type of the id
cannot be converted to the return
type.public java.util.Date getAttrAsTime(int id) throws java.lang.NoSuchFieldException, UnsupportedTypeException
Time
value of the attribute associated with the
specified id.
This method should only be used for BYTE
, SHORT
,
INTEGER
, TIMEINSECONDS
, FLOAT
,
LONG
, TIMEINMILLIS
, DOUBLE
and
eight byte STRING
attribute types.id
- the id of the attributeTime
value of the attribute associated
with the specified idjava.lang.NoSuchFieldException
- Thrown when the given id is not found.UnsupportedTypeException
- Thrown when the type of the id
cannot be converted to the return
type.public java.lang.Object getAttrAsObject(int id) throws java.lang.NoSuchFieldException, UnsupportedTypeException
OBJECT
attribute types.id
- the id of the attributejava.lang.NoSuchFieldException
UnsupportedTypeException
public ListField getAttrAsList(int id)
LIST
attribute types.id
- the id of the attributepublic DCField getField(int id)
id
- field id, in integer formatpublic DCField getField(java.lang.String id)
getField
in interface DCFieldContainer
id
- field id, in String formatpublic DCField getField(FieldKey id)
getField
in interface DCFieldContainer
public byte[] getFieldValue(java.lang.String id)
getFieldValue
in interface DCFieldContainer
id
- field id, in String formatpublic byte[] getFieldValue(int id)
id
- public byte[] getFieldValue(FieldKey key)
getFieldValue
in interface DCFieldContainer
public int getType(java.lang.String id)
getType
in interface DCFieldContainer
id
- field idpublic int getType(int id)
public void setField(java.lang.String fieldId, int type, byte[] value)
setField
in interface DCFieldContainer
fieldId
- field ID, in String formtype
- field type, as an integervalue
- field value, in byte[] formpublic void setField(FieldKey attrId, int type, byte[] value)
setField
in interface DCFieldContainer
public void setField(DCField field)
setField
in interface DCFieldContainer
field
- field, in DCField formpublic void setField(int id, int type, byte[] value)
setField
in interface DCFieldContainer
id
- field ID, in integer formtype
- field type, as an integervalue
- field value, in byte[] formpublic int lookupDataType(java.lang.String attrId) throws NonExistentAttributeException
attrId
- Identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.public int lookupDataLength(java.lang.String attrId) throws NonExistentAttributeException
attrId
- Identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.public void lookupDataBytes(java.lang.String attrId, byte[] barr, int barrOffset) throws NonExistentAttributeException
attrId
- Identifier of the desired fieldbarr
- byte array to store the looked up databarrOffset
- offset into the barr array where data will be storedNonExistentAttributeException
- if there is no attribute with the given attribute id.public byte lookupByte(java.lang.String attrId) throws NonExistentAttributeException, InvalidAttributeTypeException
attrId
- Identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.InvalidAttributeTypeException
- if the attribute stored with the given attribute id is not a byte.public int lookupInt(java.lang.String attrId) throws NonExistentAttributeException, InvalidAttributeTypeException
attrId
- Identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.InvalidAttributeTypeException
- if the attribute stored with the given attribute id is not a int.public short lookupShort(java.lang.String attrId) throws NonExistentAttributeException, InvalidAttributeTypeException
attrId
- Identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.InvalidAttributeTypeException
- if the attribute stored with the given attribute id is not a short.public long lookupLong(java.lang.String attrId) throws NonExistentAttributeException, InvalidAttributeTypeException
attrId
- Identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.InvalidAttributeTypeException
- if the attribute stored with the given attribute id is not a long.public float lookupFloat(java.lang.String attrId) throws NonExistentAttributeException, InvalidAttributeTypeException
attrId
- Identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.InvalidAttributeTypeException
- if the attribute stored with the given attribute id is not a float.public double lookupDouble(java.lang.String attrId) throws NonExistentAttributeException, InvalidAttributeTypeException
attrId
- Identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.InvalidAttributeTypeException
- if the attribute stored with the given attribute id is not a double.public java.lang.String lookupString(java.lang.String attrId) throws NonExistentAttributeException, InvalidAttributeTypeException
attrId
- Identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.InvalidAttributeTypeException
- if the attribute stored with the given attribute id is not a String.public int lookupDataType(int attrId)
attrId
- String identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.public int lookupDataLength(int attrId)
attrId
- String identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.public void lookupDataBytes(int attrId, byte[] barr, int barrOffset)
attrId
- String identifier of the desired fieldbarr
- byte array to store the looked up databarrOffset
- offset into the barr array where data will be storedNonExistentAttributeException
- if there is no attribute with the given attribute id.public byte lookupByte(int attrId)
attrId
- String identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.InvalidAttributeTypeException
- if the attribute stored with the given attribute id is not a byte.public int lookupInt(int attrId)
attrId
- String identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.InvalidAttributeTypeException
- if the attribute stored with the given attribute id is not a int.public short lookupShort(int attrId)
attrId
- String identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.InvalidAttributeTypeException
- if the attribute stored with the given attribute id is not a short.public long lookupLong(int attrId)
attrId
- String identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.InvalidAttributeTypeException
- if the attribute stored with the given attribute id is not a long.public float lookupFloat(int attrId)
attrId
- String identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.InvalidAttributeTypeException
- if the attribute stored with the given attribute id is not a float.public double lookupDouble(int attrId)
attrId
- String identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.InvalidAttributeTypeException
- if the attribute stored with the given attribute id is not a double.public java.lang.String lookupString(int attrId)
attrId
- String identifier of the desired fieldNonExistentAttributeException
- if there is no attribute with the given attribute id.InvalidAttributeTypeException
- if the attribute stored with the given attribute id is not a String.public byte[] writeByteArray()
public int writeObject(java.io.OutputStream out) throws java.io.IOException
out
- java.io.IOException
public boolean readByteArray(byte[] barray)
public boolean readObject(java.io.InputStream in) throws java.io.IOException
in
- java.io.IOException
public static NAR[] toRecArray(byte[] b)
public static NAR fromBytes(byte[] b)
public int getLength()
public void prepareByteArray()
public void disposeByteArray()
public boolean fieldExist(FieldKey key)