|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.snmp4j.smi.AbstractVariable
org.snmp4j.smi.OctetString
public class OctetString
The OctetString class represents the SMI type OCTET STRING.
| Field Summary |
|---|
| Fields inherited from class org.snmp4j.smi.AbstractVariable |
|---|
SMISYNTAXES_PROPERTIES |
| Constructor Summary | |
|---|---|
OctetString()
Creates a zero length octet string. |
|
OctetString(byte[] rawValue)
Creates an octet string from an byte array. |
|
OctetString(byte[] rawValue,
int offset,
int length)
Creates an octet string from an byte array. |
|
OctetString(OctetString other)
Creates an octet string from another OctetString by cloning its value. |
|
OctetString(java.lang.String stringValue)
Creates an octet string from a java string. |
|
| Method Summary | |
|---|---|
void |
append(byte b)
Appends a single byte to this octet string. |
void |
append(byte[] bytes)
Appends an array of bytes to this octet string. |
void |
append(OctetString octetString)
Appends an octet string. |
void |
append(java.lang.String string)
Appends the supplied string to this OctetString. |
void |
clear()
Sets the value of the octet string to a zero length string. |
java.lang.Object |
clone()
Clones this variable. |
int |
compareTo(java.lang.Object o)
|
void |
decodeBER(BERInputStream inputStream)
Decodes a Variable from an InputStream. |
void |
encodeBER(java.io.OutputStream outputStream)
Encodes a Variable to an OutputStream. |
boolean |
equals(java.lang.Object o)
|
static OctetString |
fromByteArray(byte[] value)
Creates an OctetString from an byte array. |
static OctetString |
fromHexString(java.lang.String hexString)
|
static OctetString |
fromHexString(java.lang.String hexString,
char delimiter)
|
static OctetString |
fromString(java.lang.String string,
char delimiter,
int radix)
|
static OctetString |
fromString(java.lang.String string,
int radix)
Creates an OctetString from a string represantation in the specified radix. |
void |
fromSubIndex(OID subIndex,
boolean impliedLength)
Sets the value of this Variable from the supplied (sub-)index. |
byte |
get(int index)
Gets the byte at the specified index. |
int |
getBERLength()
Returns the length of this Variable in bytes when encoded
according to the Basic Encoding Rules (BER). |
int |
getBERPayloadLength()
Returns the length of the payload of this BERSerializable
object in bytes when encoded according to the Basic Encoding Rules (BER). |
int |
getSyntax()
Gets the ASN.1 syntax identifier value of this SNMP variable. |
byte[] |
getValue()
|
int |
hashCode()
|
boolean |
isPrintable()
Determines whether this octet string contains non ISO control characters only. |
int |
length()
Gets the length of the byte string. |
OctetString |
mask(OctetString mask)
Returns a copy of this OctetString where each bit not set in the supplied mask zeros the corresponding bit in the returned OctetString. |
void |
set(int index,
byte b)
Sets the byte value at the specified index. |
void |
setValue(byte[] value)
Sets the value of this object from the supplied byte array. |
void |
setValue(java.lang.String value)
|
static java.util.Collection |
split(OctetString octetString,
OctetString delimOctets)
Splits an OctetString using a set of delimiter characters
similar to how a StringTokenizer would do it. |
boolean |
startsWith(OctetString prefix)
Tests if this octet string starts with the specified prefix. |
OctetString |
substring(int beginIndex,
int endIndex)
Returns a new string that is a substring of this string. |
java.lang.String |
toASCII(char placeholder)
Formats the content into a ASCII string. |
byte[] |
toByteArray()
Returns the value of this object as a byte array. |
java.lang.String |
toHexString()
|
java.lang.String |
toHexString(char separator)
|
int |
toInt()
Returns an integer representation of this variable if such a representation exists. |
long |
toLong()
Returns a long representation of this variable if such a representation exists. |
java.lang.String |
toString()
Gets a string representation of the variable. |
java.lang.String |
toString(char separator,
int radix)
|
java.lang.String |
toString(int radix)
Returns a string representation of this octet string in the radix specified. |
OID |
toSubIndex(boolean impliedLength)
Converts the value of this Variable to a (sub-)index
value. |
| Methods inherited from class org.snmp4j.smi.AbstractVariable |
|---|
createFromBER, createFromSyntax, getSyntaxFromString, getSyntaxString, getSyntaxString, isDynamic, isException |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public OctetString()
public OctetString(byte[] rawValue)
rawValue - an array of bytes.
public OctetString(byte[] rawValue,
int offset,
int length)
rawValue - an array of bytes.offset - the position (zero based) of the first byte to be copied from
rawValueinto the new OctetSring.length - the number of bytes to be copied.public OctetString(java.lang.String stringValue)
stringValue - a Java string.public OctetString(OctetString other)
other - an OctetString instance.| Method Detail |
|---|
public void append(byte b)
b - a byte value.public void append(byte[] bytes)
bytes - an array of bytes.public void append(OctetString octetString)
octetString - an OctetString to append to this octet string.public void append(java.lang.String string)
OctetString. Calling this
method is identical to append(string.getBytes()).
string - a String instance.public void clear()
public void encodeBER(java.io.OutputStream outputStream)
throws java.io.IOException
AbstractVariableVariable to an OutputStream.
encodeBER in interface BERSerializableencodeBER in class AbstractVariableoutputStream - an OutputStream.
java.io.IOException - if an error occurs while writing to the stream.
public void decodeBER(BERInputStream inputStream)
throws java.io.IOException
AbstractVariableVariable from an InputStream.
decodeBER in interface BERSerializabledecodeBER in class AbstractVariableinputStream - an InputStream containing a BER encoded byte stream.
java.io.IOException - if the stream could not be decoded by using BER rules.public int getBERLength()
AbstractVariableVariable in bytes when encoded
according to the Basic Encoding Rules (BER).
getBERLength in interface BERSerializablegetBERLength in class AbstractVariablepublic int getSyntax()
AbstractVariable
getSyntax in interface VariablegetSyntax in class AbstractVariablepublic final byte get(int index)
index - a zero-based index into the octet string.
java.lang.ArrayIndexOutOfBoundsException - if index < 0 or > length().
public final void set(int index,
byte b)
index - an index value greater or equal 0 and less than length().b - the byte value to set.public int hashCode()
hashCode in interface VariablehashCode in class AbstractVariablepublic boolean equals(java.lang.Object o)
equals in interface Variableequals in class AbstractVariablepublic int compareTo(java.lang.Object o)
compareTo in interface java.lang.ComparablecompareTo in interface VariablecompareTo in class AbstractVariable
public OctetString substring(int beginIndex,
int endIndex)
beginIndex and extends to the
character at index endIndex - 1.
Thus the length of the substring is endIndex-beginIndex.
beginIndex - the beginning index, inclusive.endIndex - the ending index, exclusive.
public boolean startsWith(OctetString prefix)
prefix - the prefix.
true if the bytes of this octet string up to the length
of prefix equal those of prefix.public boolean isPrintable()
false if this octet string contains any ISO control
characters as defined by Character.isISOControl(char)
except if these ISO control characters are all whitespace characters
as defined by Character.isWhitespace(char).public java.lang.String toString()
AbstractVariable
toString in interface VariabletoString in class AbstractVariablepublic java.lang.String toHexString()
public java.lang.String toHexString(char separator)
public static OctetString fromHexString(java.lang.String hexString)
public static OctetString fromHexString(java.lang.String hexString,
char delimiter)
public static OctetString fromString(java.lang.String string,
char delimiter,
int radix)
public static OctetString fromString(java.lang.String string,
int radix)
string - the string representation of an octet string.radix - the radix of the string represantion.
public java.lang.String toString(char separator,
int radix)
public java.lang.String toString(int radix)
round(log(256)/log(radix)) digits.
radix - the radix to use in the string representation.
public java.lang.String toASCII(char placeholder)
placeholder - a placeholder character, for example '.'.
public void setValue(java.lang.String value)
setValue in interface AssignableFromStringpublic void setValue(byte[] value)
AssignableFromByteArray
setValue in interface AssignableFromByteArrayvalue - a byte array.public byte[] getValue()
public final int length()
public java.lang.Object clone()
Variable
clone in interface Variableclone in class AbstractVariableVariable with the same value.public int getBERPayloadLength()
BERSerializable
object in bytes when encoded according to the Basic Encoding Rules (BER).
getBERPayloadLength in interface BERSerializablegetBERPayloadLength in class AbstractVariablepublic int toInt()
AbstractVariable
toInt in interface VariabletoInt in class AbstractVariablepublic long toLong()
AbstractVariable
toLong in interface VariabletoLong in class AbstractVariablepublic OctetString mask(OctetString mask)
mask - a mask where the n-th bit corresponds to the n-th bit in the returned
OctetString.
public OID toSubIndex(boolean impliedLength)
AbstractVariableVariable to a (sub-)index
value.
toSubIndex in interface VariabletoSubIndex in class AbstractVariableimpliedLength - specifies if the sub-index has an implied length. This parameter applies
to variable length variables only (e.g. OctetString and
OID). For other variables it has no effect.
public void fromSubIndex(OID subIndex,
boolean impliedLength)
AbstractVariableVariable from the supplied (sub-)index.
fromSubIndex in interface VariablefromSubIndex in class AbstractVariablesubIndex - the sub-index OID.impliedLength - specifies if the sub-index has an implied length. This parameter applies
to variable length variables only (e.g. OctetString and
OID). For other variables it has no effect.
public static final java.util.Collection split(OctetString octetString,
OctetString delimOctets)
OctetString using a set of delimiter characters
similar to how a StringTokenizer would do it.
octetString - the input string to tokenize.delimOctets - a set of delimiter octets.
public static OctetString fromByteArray(byte[] value)
OctetString from an byte array.
value - a byte array that is copied into the value of the created
OctetString or null.
null if value
is null.public byte[] toByteArray()
AssignableFromByteArray
toByteArray in interface AssignableFromByteArray
|
Copyright 2003-2009 Frank Fock and Jochen Katz (SNMP4J.org) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||