public class OSAR
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
OSAR()
Default constructor, no prior attributes.
|
OSAR(byte[] bytes)
Creates an OSAR, where the OSAR is completely in byte form.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(int id,
double value)
Add a double attribute to the OSAR.
|
void |
addAttribute(int id,
float value)
Add a float attribute to the OSAR.
|
void |
addAttribute(int id,
int value) |
void |
addAttribute(int id,
int type,
byte[] value)
This method adds/replaces an attribute with the value
in byte form.
|
void |
addAttribute(int id,
int type,
java.lang.String s) |
void |
addAttribute(int id,
long value) |
void |
addAttribute(int id,
short value) |
void |
addAttribute(OSARecAttr attr) |
void |
addMillisAttribute(int id,
long time)
Add a
TIMEINMILLIS attribute to the OSAR. |
void |
addSecondsAttribute(int id,
int time)
Add a
TIMEINSECONDS attribute to the OSAR. |
boolean |
containsAttr(int id)
Tests if there is an attribute with the specified id in this OSAR.
|
static OSAR |
fromBytes(byte[] buff)
The method gets an OSAR object from a byte array
|
OSARecAttr[] |
getAllAttributes()
The method to get all DCFields
|
byte |
getAttrAsByte(int id)
Gets the byte value of the attribute associated with the specified id.
|
byte[] |
getAttrAsBytes(int id)
Gets the bytes value of the attribute associated with the specified id.
|
java.sql.Date |
getAttrAsDate(int id)
Gets the
Date value of the attribute associated with the
specified id. |
double |
getAttrAsDouble(int id)
Gets the double value of the attribute associated with the specified id.
|
float |
getAttrAsFloat(int id)
Gets the float value of the attribute associated with the specified id.
|
int |
getAttrAsInt(int id)
Gets the integer value of the attribute associated with the specified id.
|
long |
getAttrAsLong(int id)
Gets the long value of the attribute associated with the specified id.
|
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)
Gets the OBJECT value of the attribute associated with the specified id.
|
short |
getAttrAsShort(int id)
Gets the short value of the attribute associated with the specified id.
|
java.lang.String |
getAttrAsString(int id)
Gets the string representation of the attribute associated with the
specified id.
|
java.sql.Time |
getAttrAsTime(int id)
Gets the
Time value of the attribute associated with the
specified id. |
java.sql.Timestamp |
getAttrAsTimestamp(int id)
Gets the
Timestamp value of the attribute associated with the
specified id. |
OSARecAttr |
getAttribute(int id)
The method to get an DCField object with tag
|
byte[] |
getAttributeValueBytes(int id)
Returns the attribute's value in bytes.
|
int |
getAttrType(int id)
Gets the type of the attribute associated with the specified id.
|
int |
getLength()
Returns the length in bytes
|
int |
getLengthInWord()
Returns the length in words
|
int |
getNumAttrs()
The method to get the number of attributes
|
OSARecAttr |
removeAttribute(int id)
This method removes an attribute with the given id.
|
void |
shiftAttribute(int oldId,
int newId)
Change an attribute's ID to a new ID.
|
byte[] |
toByteArray()
Returns a copy of the OSAR's byte array.
|
static OSAR[] |
toRecArray(byte[] bytes)
Create an array of OSARs from the byte array passed in.
|
void |
toStream(java.io.OutputStream oStream)
The method outputs an OSAR to the output stream
|
java.lang.String |
toString()
The method to return a string of the OSAR object
|
public OSAR()
public OSAR(byte[] bytes)
bytes
- bytes of the OSARpublic final byte[] toByteArray()
public static final OSAR fromBytes(byte[] buff)
buff
- bytes of the OSARpublic final void addAttribute(int id, int type, byte[] value)
id
- attribute idtype
- attribute typevalue
- byte representation of attribute's valuepublic 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, int type, java.lang.String s)
public final void addAttribute(OSARecAttr attr)
public final void addAttribute(int id, float value)
id
- the id of the attributevalue
- the float value of the attributepublic void addAttribute(int id, double value)
id
- the id of the attributevalue
- the double value of the attributepublic void addMillisAttribute(int id, long time)
TIMEINMILLIS
attribute to the OSAR.
If there is an attribute already associated with id, its value is replaced.id
- the id of the attributevalue
- the time in milliseconds value of the attributepublic void addSecondsAttribute(int id, int time)
TIMEINSECONDS
attribute to the OSAR.
If there is an attribute already associated with id, its value is replaced.id
- the id of the attributevalue
- the time in seconds value of the attributepublic void shiftAttribute(int oldId, int newId)
oldId
- Old attribute IDnewId
- New attribute IDpublic OSARecAttr removeAttribute(int id)
id
- id of the attributepublic OSARecAttr getAttribute(int id)
id
- id of the attributepublic OSARecAttr[] getAllAttributes()
public byte[] getAttributeValueBytes(int id)
id
- id of the attributepublic boolean containsAttr(int id)
id
- the id of the attributetrue
if an attribute with the given id exists
in this OSAR; false
otherwisepublic int getAttrType(int id)
id
- the id of the attributepublic int getLength()
public int getLengthInWord()
public int getNumAttrs()
public static OSAR[] toRecArray(byte[] bytes)
bytes
- bytes to create the OSAR's frompublic void toStream(java.io.OutputStream oStream) throws java.io.IOException
oStream
- output stream to write the OSAR tojava.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
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.sql.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.sql.Time 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.sql.Timestamp getAttrAsTimestamp(int id) throws java.lang.NoSuchFieldException, UnsupportedTypeException
Timestamp
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 attributeTimestamp
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)
OBJECT
attribute types.id
- the id of the attribute