com.sun.management.snmp
Class SnmpString

java.lang.Object
  extended by com.sun.management.snmp.SnmpValue
      extended by com.sun.management.snmp.SnmpString
All Implemented Interfaces:
SnmpDataTypeEnums, Serializable, Cloneable
Direct Known Subclasses:
SnmpOpaque, SnmpStringFixed

public class SnmpString
extends SnmpValue

Represents an SNMP string.

Since:
Java DMK 5.1
See Also:
Serialized Form

Field Summary
protected  byte[] value
          This is the bytes array of the string value.
 
Fields inherited from interface com.sun.management.snmp.SnmpDataTypeEnums
ApplFlag, BitStringTag, BooleanTag, Counter64Tag, CounterTag, CtxtFlag, errEndOfMibViewTag, errNoSuchInstanceTag, errNoSuchObjectTag, GaugeTag, IntegerTag, IpAddressTag, NsapTag, NullTag, ObjectIdentiferTag, ObjectIdentifierTag, OctetStringTag, OpaqueTag, SequenceTag, TableTag, TimeticksTag, UintegerTag, UnknownSyntaxTag
 
Constructor Summary
SnmpString()
          Constructs a new empty SnmpString.
SnmpString(byte[] v)
          Constructs a new SnmpString from the specified bytes array.
SnmpString(Byte[] v)
          Constructs a new SnmpString from the specified Bytes array.
SnmpString(InetAddress address)
          Constructs a new SnmpString from the specified InetAddress .
SnmpString(String v)
          Constructs a new SnmpString from the specified String value.
 
Method Summary
static void appendToOid(SnmpOid source, SnmpOid dest)
          Appends an SnmpOid representing an SnmpString to another OID.
static String BinToChar(String bin)
          Converts the specified binary string into a character string.
 byte[] byteValue()
          Returns the bytes array of this SnmpString.
 Object clone()
          Clones the SnmpString object, making a copy of its data.
 SnmpValue duplicate()
          Performs a clone action.
 String getTypeName()
          Returns a textual description of the type object.
static String HexToChar(String hex)
          Converts the specified hexadecimal string into a character string.
 InetAddress inetAddressValue()
          Converts the string value to its InetAddress form.
static int nextOid(long[] index, int start)
          Scans an index OID, skips the string value and returns the position of the next value.
 Byte[] toByte()
          Converts the string value to its array of Bytes form.
 SnmpOid toOid()
          Converts the string value to its SnmpOid form.
static SnmpOid toOid(long[] index, int start)
          Extracts the string from an index OID and returns its value converted as an SnmpOid.
 String toString()
          Converts the string value to its String form.
 
Methods inherited from class com.sun.management.snmp.SnmpValue
isEndOfMibViewValue, isNoSuchInstanceValue, isNoSuchObjectValue, toAsn1String
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected byte[] value
This is the bytes array of the string value.

Constructor Detail

SnmpString

public SnmpString()
Constructs a new empty SnmpString.


SnmpString

public SnmpString(byte[] v)
Constructs a new SnmpString from the specified bytes array.

Parameters:
v - The bytes composing the string value.

SnmpString

public SnmpString(Byte[] v)
Constructs a new SnmpString from the specified Bytes array.

Parameters:
v - The Bytes composing the string value.

SnmpString

public SnmpString(String v)
Constructs a new SnmpString from the specified String value.

Parameters:
v - The initialization value.

SnmpString

public SnmpString(InetAddress address)
Constructs a new SnmpString from the specified InetAddress .

Parameters:
address - The InetAddress .
Method Detail

inetAddressValue

public InetAddress inetAddressValue()
                             throws UnknownHostException
Converts the string value to its InetAddress form.

Returns:
an InetAddress defined by the string value.
Throws:
UnknownHostException - If string value is not a legal address format.

BinToChar

public static String BinToChar(String bin)
Converts the specified binary string into a character string.

Parameters:
bin - The binary string value to convert.
Returns:
The character string representation.

HexToChar

public static String HexToChar(String hex)
Converts the specified hexadecimal string into a character string.

Parameters:
hex - The hexadecimal string value to convert.
Returns:
The character string representation.

byteValue

public byte[] byteValue()
Returns the bytes array of this SnmpString.

Returns:
The value.

toByte

public Byte[] toByte()
Converts the string value to its array of Bytes form.

Returns:
The array of Bytes representation of the value.

toString

public String toString()
Converts the string value to its String form.

Overrides:
toString in class Object
Returns:
The String representation of the value.

toOid

public SnmpOid toOid()
Converts the string value to its SnmpOid form.

Specified by:
toOid in class SnmpValue
Returns:
The OID representation of the value.

toOid

public static SnmpOid toOid(long[] index,
                            int start)
                     throws SnmpStatusException
Extracts the string from an index OID and returns its value converted as an SnmpOid.

Parameters:
index - The index array.
start - The position in the index array.
Returns:
The OID representing the string value.
Throws:
SnmpStatusException - There is no string value available at the start position.

nextOid

public static int nextOid(long[] index,
                          int start)
                   throws SnmpStatusException
Scans an index OID, skips the string value and returns the position of the next value.

Parameters:
index - The index array.
start - The position in the index array.
Returns:
The position of the next value.
Throws:
SnmpStatusException - There is no string value available at the start position.

appendToOid

public static void appendToOid(SnmpOid source,
                               SnmpOid dest)
Appends an SnmpOid representing an SnmpString to another OID.

Parameters:
source - An OID representing an SnmpString value.
dest - Where source should be appended.

duplicate

public final SnmpValue duplicate()
Performs a clone action. This provides a workaround for the SnmpValue interface.

Specified by:
duplicate in class SnmpValue
Returns:
The SnmpValue clone.

clone

public Object clone()
Clones the SnmpString object, making a copy of its data.

Overrides:
clone in class Object
Returns:
The object clone.

getTypeName

public String getTypeName()
Returns a textual description of the type object.

Specified by:
getTypeName in class SnmpValue
Returns:
ASN.1 textual description.

Open Source build 02
opendmk-1.0-b02 2007.10.01_19:17:46_MEST

Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.