|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.management.snmp.BerDecoder
public class BerDecoder
The BerDecoder
class is used for decoding
BER-encoded data.
A BerDecoder
needs to be set up with the byte string containing
the encoding. It maintains a current position in the byte string.
Methods allows to fetch integer, string, OID, etc., from the current
position. After a fetch the current position is moved forward.
A fetch throws a BerException
if the encoding is not of the
expected type.
Field Summary | |
---|---|
static int |
BooleanTag
|
static int |
IntegerTag
|
static int |
NullTag
|
static int |
OctetStringTag
|
static int |
OidTag
|
static int |
SequenceTag
|
Constructor Summary | |
---|---|
BerDecoder(byte[] b)
Constructs a new decoder and attaches it to the specified byte string. |
Method Summary | |
---|---|
boolean |
cannotCloseSequence()
Return true if the end of the current sequence is not reached. |
void |
closeSequence()
Close a sequence. |
byte[] |
fetchAny()
Fetch an ANY value. |
byte[] |
fetchAny(int tag)
Fetch an ANY value with a specific tag. |
int |
fetchInteger()
Fetch an integer. |
int |
fetchInteger(int tag)
Fetch an integer with the specified tag. |
long |
fetchIntegerAsLong()
Fetch an integer and return a long value. |
long |
fetchIntegerAsLong(int tag)
Fetch an integer with the specified tag and return a long value. |
void |
fetchNull()
Fetch a NULL value. |
void |
fetchNull(int tag)
Fetch a NULL value with a specified tag. |
byte[] |
fetchOctetString()
Fetch an octet string. |
byte[] |
fetchOctetString(int tag)
Fetch an octet string with a specified tag. |
long[] |
fetchOid()
Fetch an object identifier. |
long[] |
fetchOid(int tag)
Fetch an object identifier with a specified tag. |
int |
getTag()
Get the tag of the data at the current position. |
void |
openSequence()
Fetch a sequence header. |
void |
openSequence(int tag)
Fetch a sequence header with a specific tag. |
void |
reset()
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int BooleanTag
public static final int IntegerTag
public static final int OctetStringTag
public static final int NullTag
public static final int OidTag
public static final int SequenceTag
Constructor Detail |
---|
public BerDecoder(byte[] b)
b
- The byte string containing the encoded data.Method Detail |
---|
public void reset()
public int fetchInteger() throws BerException
BerException
- Current position does not point to an integer.public int fetchInteger(int tag) throws BerException
tag
- The expected tag.
BerException
- Current position does not point to an integer
or the tag is not the expected one.public long fetchIntegerAsLong() throws BerException
BerException
- Current position does not point to an integer.public long fetchIntegerAsLong(int tag) throws BerException
tag
- The expected tag.
BerException
- Current position does not point to an integer
or the tag is not the expected one.public byte[] fetchOctetString() throws BerException
BerException
- Current position does not point to an octet string.public byte[] fetchOctetString(int tag) throws BerException
tag
- The expected tag.
BerException
- Current position does not point to an octet string
or the tag is not the expected one.public long[] fetchOid() throws BerException
BerException
public long[] fetchOid(int tag) throws BerException
tag
- The expected tag.
BerException
- Current position does not point to an oid
or the tag is not the expected one.public void fetchNull() throws BerException
NULL
value.
BerException
- Current position does not point to NULL
value.public void fetchNull(int tag) throws BerException
NULL
value with a specified tag.
tag
- The expected tag.
BerException
- Current position does not point to
NULL
value or the tag is not the expected one.public byte[] fetchAny() throws BerException
ANY
value. In fact, this method does not decode anything
it simply returns the next TLV as an array of bytes.
BerException
- The next TLV is really badly encoded...public byte[] fetchAny(int tag) throws BerException
ANY
value with a specific tag.
tag
- The expected tag.
BerException
- The next TLV is really badly encoded...public void openSequence() throws BerException
BerException
- Current position does not point to a sequence header.public void openSequence(int tag) throws BerException
tag
- The expected tag.
BerException
- Current position does not point to a sequence header
or the tag is not the expected one.public void closeSequence() throws BerException
BerException
- The sequence is not expected to finish here.public boolean cannotCloseSequence()
true
if the end of the current sequence is not reached.
When this method returns false
, closeSequence
can (and must) be
invoked.
true
if there is still some data in the sequence.public int getTag() throws BerException
BerException
public String toString()
toString
in class Object
|
Open Source build 02 opendmk-1.0-b02 2007.10.01_19:17:46_MEST |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |