org.apache.asn1new.primitives
Class OctetString

java.lang.Object
  extended byorg.apache.asn1new.primitives.OctetString
All Implemented Interfaces:
java.io.Serializable

public class OctetString
extends java.lang.Object
implements java.io.Serializable

Implement the Octet String primitive type.

Author:
Apache Directory Project
See Also:
Serialized Form

Field Summary
private  byte[] bytes
          The string is stored in a byte array
private static int DEFAULT_LENGTH
          The default length of an octet string
static OctetString EMPTY_STRING
          A null OctetString
private  boolean isStreamed
          Tells if the OctetString is streamed or not
private static long serialVersionUID
           
static boolean STREAMED
          A flag to mark the OctetString as Streamed (for OctetString larger than 1024 chars)
 
Constructor Summary
OctetString(byte[] bytes)
          Creates a OctetString with a value.
OctetString(int length)
          Creates a OctetString with a specific length.
OctetString(int length, boolean isStreamed)
          Creates a streamed OctetString with a specific length.
 
Method Summary
 int getNbBytes()
           
 byte[] getValue()
          Get the data stored into the OctetString
 boolean isStreamed()
          Tells if the OctetString is streamed or not
 void setData(byte[] bytes)
          Set a new octetString in the OctetString.
 java.lang.String toString()
          Return a native String representation of the OctetString.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

EMPTY_STRING

public static final OctetString EMPTY_STRING
A null OctetString


STREAMED

public static final boolean STREAMED
A flag to mark the OctetString as Streamed (for OctetString larger than 1024 chars)

See Also:
Constant Field Values

DEFAULT_LENGTH

private static final int DEFAULT_LENGTH
The default length of an octet string

See Also:
Constant Field Values

isStreamed

private boolean isStreamed
Tells if the OctetString is streamed or not


bytes

private byte[] bytes
The string is stored in a byte array

Constructor Detail

OctetString

public OctetString(int length)
Creates a OctetString with a specific length.

Parameters:
length - The OctetString length

OctetString

public OctetString(int length,
                   boolean isStreamed)
Creates a streamed OctetString with a specific length. Actually, it's just a simple OctetString. TODO Implement streaming.

Parameters:
length - The OctetString length
isStreamed - Tells if the OctetString must be streamed or not

OctetString

public OctetString(byte[] bytes)
Creates a OctetString with a value.

Parameters:
bytes - The value to store.
Method Detail

setData

public void setData(byte[] bytes)
Set a new octetString in the OctetString. It will replace the old OctetString, and reset the current length with the new one.

Parameters:
bytes - The string to store

getValue

public byte[] getValue()
Get the data stored into the OctetString

Returns:
A byte array

toString

public java.lang.String toString()
Return a native String representation of the OctetString.

Returns:
A string representing the OctetString

isStreamed

public boolean isStreamed()
Tells if the OctetString is streamed or not

Returns:
true if the OctetString is streamed.

getNbBytes

public int getNbBytes()
Returns:
Returns the length.


Copyright © 2005-2006 . All Rights Reserved.