|
SNMP Stack 5_1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.co.westhawk.snmp.stack.AsnObject | +--uk.co.westhawk.snmp.stack.AsnOctets
This class represents the ASN.1 Octet class.
It can be used for Octets, Ip Addresses and Opaque primitive types.
The Octets type (ASN_OCTET_STR) is used for some text convensions.
This class supports the DateAndTime, DisplayString and
InternationalDisplayString and Ipv6Address text convensions.
Note, the SNMP representation of IPv4 and IPv6 is different:
SnmpConstants.ASN_OCTET_STR
,
SnmpConstants.IPADDRESS
,
SnmpConstants.OPAQUE
Field Summary | |
static java.text.SimpleDateFormat |
CALFORMAT
The object that is used in toCalendar() to format the calendar representation of the Octets according to the DateAndTime text convension. |
static java.lang.String |
HEX_PREFIX
The hexadecimal prefix that is used when printing a hexadecimal number in toString(). |
static AsnOctetsPrintableFace |
printableObject
The default AsnOctetsPrintableFace object. |
Fields inherited from class uk.co.westhawk.snmp.stack.AsnObject |
contentsLength, debug, headerLength, isCorrect, startPos, type |
Constructor Summary | |
AsnOctets(byte[] s)
Constructor. |
|
AsnOctets(byte[] s,
byte t)
Constructor to create a specific type of AsnOctets. |
|
AsnOctets(java.util.Calendar cal)
Constructor for DateAndTime text convension. |
|
AsnOctets(char[] s)
Constructor. |
|
AsnOctets(java.net.Inet4Address iad,
byte t)
Constructor to create an ASN IPv4 Address. |
|
AsnOctets(java.net.InetAddress iad)
Constructor to create an ASN IP Address. |
|
AsnOctets(java.io.InputStream in,
int len)
Constructor. |
|
AsnOctets(java.lang.String s)
Constructor. |
Method Summary | |
boolean |
equals(java.lang.Object anObject)
Compares this Octet to the specified object. |
byte[] |
getBytes()
Returns the bytes. |
java.util.Calendar |
getCalendar()
Returns the Octets as Calendar according to the DateAndTime text convension. |
java.net.InetAddress |
getIpAddress()
Returns this Octet as an IP Address. |
java.lang.String |
getValue()
Returns the String value. |
int |
hashCode()
Returns a hash code for this Octet. |
static void |
setHexPrefix(java.lang.String newPrefix)
Sets the global hexadecimal prefix. |
static void |
setPrintable(AsnOctetsPrintableFace obj)
Sets the global AsnOctetsPrintableFace printableObject. |
java.lang.String |
toCalendar()
Returns the String representation according to the DateAndTime convension. |
java.lang.String |
toDisplayString()
Returns this Octet as a display string (text convension). |
java.lang.String |
toHex()
Returns this Octet as an hexadecimal String, without any prefix. |
java.lang.String |
toInternationalDisplayString()
Returns this Octet as an international display string (text convension). |
java.lang.String |
toInternationalDisplayString(AsnOctetsPrintableFace face)
As toInternationalDisplayString(), but this methods will use this specific, one-off AsnOctetsPrintableFace object. |
java.lang.String |
toIpAddress()
Returns this Octet as an IP Address string. |
java.lang.String |
toString()
Returns the string representation of the AsnOctets. |
java.lang.String |
toString(AsnOctetsPrintableFace face)
As toString(), but this methods will use this specific, one-off AsnOctetsPrintableFace object. |
long[] |
toSubOid(boolean length_implied)
Converts this Octet to its corresponding sub-identifiers. |
Methods inherited from class uk.co.westhawk.snmp.stack.AsnObject |
getRespType, getRespTypeString, setDebug |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static java.lang.String HEX_PREFIX
public static java.text.SimpleDateFormat CALFORMAT
getCalendar()
,
toCalendar()
,
SimpleDateFormat
public static AsnOctetsPrintableFace printableObject
setPrintable(uk.co.westhawk.snmp.stack.AsnOctetsPrintableFace)
,
DefaultAsnOctetsPrintable
Constructor Detail |
public AsnOctets(byte[] s) throws java.lang.IllegalArgumentException
s
- The byte array representing the AsnOctetsSnmpConstants.ASN_OCTET_STR
public AsnOctets(byte[] s, byte t) throws java.lang.IllegalArgumentException
s
- The byte array representing the AsnOctetst
- The type of the AsnOctetsSnmpConstants.ASN_OCTET_STR
,
SnmpConstants.IPADDRESS
,
SnmpConstants.OPAQUE
public AsnOctets(char[] s)
s
- The character array representing the AsnOctetsSnmpConstants.ASN_OCTET_STR
public AsnOctets(java.lang.String s)
s
- The string representing the AsnOctetsSnmpConstants.ASN_OCTET_STR
public AsnOctets(java.net.InetAddress iad) throws java.lang.IllegalArgumentException
iad
- The Inet AddressAsnOctets(Inet4Address, byte)
public AsnOctets(java.net.Inet4Address iad, byte t) throws java.lang.IllegalArgumentException
iad
- The IPv4 Inet Addresst
- The type of the AsnOctetsAsnOctets(InetAddress)
,
SnmpConstants.IPADDRESS
,
SnmpConstants.ASN_OCTET_STR
public AsnOctets(java.util.Calendar cal)
field octets contents range ----- ------ -------- ----- 1 1-2 year* 0..65536 2 3 month 1..12 3 4 day 1..31 4 5 hour 0..23 5 6 minutes 0..59 6 7 seconds 0..60 (use 60 for leap-second) 7 8 deci-seconds 0..9 8 9 direction from UTC '+' / '-' 9 10 hours from UTC* 0..13 10 11 minutes from UTC 0..59 SYNTAX OCTET STRING (SIZE (8 | 11))
public AsnOctets(java.io.InputStream in, int len) throws java.io.IOException
in
- The input stream from which the value should be readlen
- The length of the AsnOctetsMethod Detail |
public static void setHexPrefix(java.lang.String newPrefix)
toString()
,
toHex()
,
HEX_PREFIX
public static void setPrintable(AsnOctetsPrintableFace obj)
toString()
,
toInternationalDisplayString()
public java.lang.String getValue()
toString()
public byte[] getBytes()
public java.lang.String toString()
The string will have one of the following formats:
When the type is ASN_OCTET_STR, this method uses the AsnOctetsPrintableFace.isPrintable() to determine whether or not the string is printable. If it is printable, it will use AsnOctetsPrintableFace.toInternationalDisplayString() to transform the Octets to a String.
toString
in class AsnObject
HEX_PREFIX
,
setHexPrefix(String)
,
toHex()
,
toIpAddress()
,
AsnOctetsPrintableFace.isPrintable(byte[])
,
AsnOctetsPrintableFace.toInternationalDisplayString(byte[])
public java.lang.String toString(AsnOctetsPrintableFace face)
toString()
public java.lang.String toIpAddress()
toString()
,
getIpAddress()
,
SnmpConstants.ASN_OCTET_STR
,
SnmpConstants.IPADDRESS
public java.net.InetAddress getIpAddress() throws java.lang.RuntimeException
java.lang.RuntimeException
- Thrown when the Octets does
not represent an InetAddress or when the method internally throws
an java.net.UnknownHostExceptiontoString()
,
toIpAddress()
,
SnmpConstants.ASN_OCTET_STR
,
SnmpConstants.IPADDRESS
public java.lang.String toHex()
toString()
public java.lang.String toDisplayString()
DisplayString represents textual information taken from the NVT ASCII character set, as defined in pages 4, 10-11 of RFC 854. Any object defined using this syntax may not exceed 255 characters in length. Basicly it is US-ASCII with some changes.
toString()
public java.lang.String toInternationalDisplayString()
AsnOctetsPrintableFace.toInternationalDisplayString(byte[])
public java.lang.String toInternationalDisplayString(AsnOctetsPrintableFace face)
toInternationalDisplayString()
public java.lang.String toCalendar() throws java.lang.RuntimeException
java.lang.RuntimeException
- Thrown when the number of
Octets does not represent the DateAndTime length.CALFORMAT
public java.util.Calendar getCalendar() throws java.lang.RuntimeException
java.lang.RuntimeException
- Thrown when the number of
Octets does not represent the DateAndTime length.AsnOctets(java.util.Calendar)
public long[] toSubOid(boolean length_implied)
Use this method when building an OID when this Octet specifies a conceptual row. For example ipNetToMediaEntry, see IP-MIB or SnmpCommunityEntry, see SNMP-COMMUNITY-MIB
The variable length_implied
indicates that this MIB variable
is preceded by the IMPLIED keyword:
If the length is implied, no extra sub-identifier will be created to
indicate its length.
If the length is not implied, the first
sub-identifier will be the length of the Octet.
If this Octet is of type IPADDRESS, length_implied should be false.
The mapping of the INDEX clause is explained in SNMPv2-SMI, section 7.7.
length_implied
- Indicates if the length of this octet is
implied.AsnObjectId.add(long[])
public boolean equals(java.lang.Object anObject)
true
if and only if the argument is not
null
and is an AsnOctets
object that represents
the same sequence of octets as this Octet.
equals
in class java.lang.Object
anObject
- the object to compare this AsnOctets
against.
true
if the AsnOctets
are equal;
false
otherwise.public int hashCode()
AsnOctets
object is computed as
usings[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
int
arithmetic, where s[i]
is the
ith character of the Octet, n
is the length of
the Octet, and ^
indicates exponentiation.
(The hash value of the empty Octet is zero.)
hashCode
in class java.lang.Object
|
SNMP Stack 5_1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |