|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.opennms.bb.dp.events.EventParamValue
This class is built to encapsulate parameter value from the event stream. Each parameter value encapsulates a type, encoding, and actual value. The value's class can be determined by the type. The encoding rules all for types, like SnmpOpaque, to be encoded as text even if they contain binary data.
Field Summary | |
private static char[] |
BASE64_CHARS
The base64 encoding map. |
private static char |
BASE64_PAD
The base64 padding character |
private static byte[] |
BASE64_VALUES
|
private int |
m_encoding
The textual encoding that should be used with this encapsulated object. |
private int |
m_type
The type of the encapsulated object. |
private Object |
m_value
The encapsulated object for this parameter. |
static int |
TYPE_INT
Defines the value as a 32-bit integer value. |
static String[] |
TYPE_NAMES
This member defines all the appropriate names for the defined types. |
static int |
TYPE_SNMP_COUNTER32
Defines the encasulated value as an instance of an SnmpCopunter32 object. |
static int |
TYPE_SNMP_COUNTER64
Defines the encasulated value as an instance of an SnmpCounter64 object. |
static int |
TYPE_SNMP_GAUGE32
Defines the encasulated value as an instance of an SnmpGauge32 object. |
static int |
TYPE_SNMP_INT32
Defines a 32-bit SNMP integer value. |
static int |
TYPE_SNMP_IPADDRESS
Defines the encasulated value as an instance of an SnmpIpAddress object. |
static int |
TYPE_SNMP_NULL
Defines the encasulated value as an instance of an SnmpNull object. |
static int |
TYPE_SNMP_OBJECT_IDENTIFIER
Defines the encapsulated value as an instance of an SnmpObjectId object. |
static int |
TYPE_SNMP_OCTET_STRING
Defines the encapsulated value as an SnmpOctetString instance. |
static int |
TYPE_SNMP_OPAQUE
Defines the encasulated value as an instance of an SnmpOpaque object. |
static int |
TYPE_SNMP_TIMETICKS
Defines the encasulated value as an instance of an SnmpTimeTicks object. |
static int |
TYPE_STRING
This is the default type for a parameter value from the Event DTD. |
static int |
XML_ENCODING_BASE64
The value should be encoded using a base64 encoding method. |
static String[] |
XML_ENCODING_NAMES
The attribute values for the encoding type as they appear in the Event DTD. |
static int |
XML_ENCODING_TEXT
The value should be encoded using a plain textual string in the XML Document. |
Constructor Summary | |
EventParamValue()
Builds a new instance of an encapsulated parameter from an event stream. |
|
EventParamValue(int type,
int encoding,
Object value)
Constructs a new instance of an encapsulated value. |
|
EventParamValue(int type,
Object value)
Constructs a new parameter instance with the specified type and encapsulated object. |
|
EventParamValue(Object value)
Constructs a new parameter instance with the specified type and encapsulated object. |
Method Summary | |
static byte[] |
decodeBase64(char[] data)
Decodes a character array into the corresponding byte array. |
static char[] |
encodeBase64(byte[] data)
Encodes the passed byte array using the base64 rules. |
static char[] |
filterBase64(char[] data)
Filters an existing buffer that was encoded using base64 to only the appropriate characters. |
int |
getEncoding()
Returns the encoding to be used when written to an XML event stream. |
int |
getType()
Returns the type for the encapsulated object. |
Object |
getValue()
Returns the encapsualted value. |
(package private) void |
serializeToXML(PrintStream ps)
Writes self to event stream |
void |
set(int type,
int encoding,
Object value)
Sets the object instance to an encapsulated value. |
void |
set(int type,
Object value)
Sets the object instance to the specified type and encapsulated object. |
void |
setEncoding(int encoding)
Sets the encoding to be used when written to an XML event stream. |
void |
setType(int type)
Sets the encapsulated type. |
void |
setValue(Object value)
Sets the encapsulate value. |
String |
toString()
Converts the value of the instance to a string representation in the correct encoding system. |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final int TYPE_STRING
This is the default type for a parameter value from the Event DTD. The basic value is represented by a java.lang.String object.
public static final int TYPE_INT
Defines the value as a 32-bit integer value. The type returned by the call to get value will be a java.lang.Integer object.
public static final int TYPE_SNMP_INT32
Defines a 32-bit SNMP integer value. A SnmpInt32 object is the instance encapsulated by the parameter instance.
public static final int TYPE_SNMP_OCTET_STRING
Defines the encapsulated value as an SnmpOctetString instance.
public static final int TYPE_SNMP_NULL
Defines the encasulated value as an instance of an SnmpNull object.
public static final int TYPE_SNMP_OBJECT_IDENTIFIER
Defines the encapsulated value as an instance of an SnmpObjectId object.
public static final int TYPE_SNMP_IPADDRESS
Defines the encasulated value as an instance of an SnmpIpAddress object.
public static final int TYPE_SNMP_COUNTER32
Defines the encasulated value as an instance of an SnmpCopunter32 object.
public static final int TYPE_SNMP_GAUGE32
Defines the encasulated value as an instance of an SnmpGauge32 object.
public static final int TYPE_SNMP_TIMETICKS
Defines the encasulated value as an instance of an SnmpTimeTicks object.
public static final int TYPE_SNMP_OPAQUE
Defines the encasulated value as an instance of an SnmpOpaque object.
public static final int TYPE_SNMP_COUNTER64
Defines the encasulated value as an instance of an SnmpCounter64 object.
public static final String[] TYPE_NAMES
This member defines all the appropriate names for the defined types. These string values match the names as they appear in the Event DTD for an encoded parameter value.
public static final int XML_ENCODING_TEXT
The value should be encoded using a plain textual string in the XML Document.
public static final int XML_ENCODING_BASE64
The value should be encoded using a base64 encoding method.
public static final String[] XML_ENCODING_NAMES
The attribute values for the encoding type as they appear in the Event DTD.
private static final char[] BASE64_CHARS
The base64 encoding map. Using 6-bit values it is possible to map 24-bits into 4 characters. If there are not sufficent amount of bits to makeup six then it is padded with BASE64_PAD.
private static final byte[] BASE64_VALUES
private static final char BASE64_PAD
private int m_type
private int m_encoding
private Object m_value
Constructor Detail |
public EventParamValue()
Builds a new instance of an encapsulated parameter from an event stream. The default instance contains an encapsulated empty string, type == TYPE_STRING, and encoding == XML_ENCODING_TEXT.
public EventParamValue(Object value)
Constructs a new parameter instance with the specified type and encapsulated object. The encoding type is infered from the passed type.
value
- The value to encapsulate.public EventParamValue(int type, Object value)
Constructs a new parameter instance with the specified type and encapsulated object. The encoding type is infered from the passed type.
type
- The type of the encapsulate value.value
- The value to encapsulate.public EventParamValue(int type, int encoding, Object value)
type
- The type of the encapsulate object.encoding
- The encoding to use with XML.value
- The value to encapsulate.Method Detail |
void serializeToXML(PrintStream ps)
public int getType()
public void setType(int type)
type
- The new type for the instance.public int getEncoding()
public void setEncoding(int encoding)
encoding
- The new encoding format.public Object getValue()
public void setValue(Object value)
value
- The new value for the instance.public void set(int type, Object value)
Sets the object instance to the specified type and encapsulated object. The encoding type is infered from the passed type.
type
- The type of the encapsulate value.value
- The value to encapsulate.public void set(int type, int encoding, Object value)
type
- The type of the encapsulate object.encoding
- The encoding to use with XML.value
- The value to encapsulate.public static char[] encodeBase64(byte[] data)
Encodes the passed byte array using the base64 rules. The base64 encoding schema is performed by grouping the bytes in to 6-bit quantities and then encoding them.
For more information see RFC1341 for the format used for base64 encoding.
data
- The input byte arraypublic static byte[] decodeBase64(char[] data)
Decodes a character array into the corresponding byte array. The buffer must be an intergral number of 4 character. I.E. size mod 4 is equal to zero or an exception will be thrown. Likewise, if there is an invalid character in the input array then an exception will be thrown.
data
- The data stream to be filtered.IllegalArgumentException
- Thrown if an invalid
buffer that cannot be decoded is passed.public static char[] filterBase64(char[] data)
Filters an existing buffer that was encoded using base64 to only the appropriate characters. This is useful for removing whitespace, character returns, and other chaff if it is in the string before passing it to the decoding routine.
If a correct buffer cannot be build (size % 4 != 0) then an exception will be thrown.
data
- The data stream to be filtered.IllegalArgumentException
- Thrown if an invalid
buffer that cannot be filtered is passed.public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |