Class oclc.ber.BerString
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class oclc.ber.BerString

java.lang.Object
   |
   +----oclc.ber.ASN1
           |
           +----oclc.ber.BerString

public class BerString
extends ASN1
BerString is a class for BER encoded strings.

Here is an example to read a BER record from System.in, build a DataDir tree over the BER record and write a formatted version of the DataDir tree to System.out.

BerString berRec = new BerString(System.in);
DataDir dir = new DataDir(berRec);
System.out.println(dir.toString()); 
Version:
@(#)BerString.java 1.10 06/27/96
Author:
Jenny Colvard
See Also:
ASN1, BufferedBerStream

Variable Index

 o offset
 o record

Constructor Index

 o BerString(byte[])
 o BerString(DataDir)
Build a ber_record from a directory.
 o BerString(DataDir, int, int)
Build a ber_record from a directory and leave space in the buffer for other data to be provided by the application.
 o BerString(InputStream)
Read a ber_record from the InputStream.

Method Index

 o asn1Len()
Find the length of a BER record.
 o getLen()
Get a length directly from a BER record.
 o getTag()
Get a tag directly from a BER record.
 o IsCompleteBER(int, int[])
Determine if a complete BER record has been received.
 o putChar(byte[], int)
Put an array of bytes in to a BER record.
 o putLen(int)
Put a length directly into a BER record.
 o putNumber(int)
Put a number into a BER record.
 o putTag(int, byte, byte)
Put a tag directly into a BER record.
 o record()
Accessor method for byte[] record.
 o setOffset(int)
Allows caller to reset offset to beginning of record.
 o toString()
Creates String representation of BER record.
 o toString(int)
Creates String representation of BER record.

Variables

 o record
  protected byte record[]
 o offset
  protected int offset

Constructors

 o BerString
  public BerString(byte record[])
 o BerString
  public BerString(DataDir dir)
Build a ber_record from a directory.
Parameters:
dir - directory
 o BerString
  public BerString(DataDir dir,
                   int extraLength,
                   int offset)
Build a ber_record from a directory and leave space in the buffer for other data to be provided by the application. This is a tricky one but it's very useful. The BER record is often only part of a record being built for inclusion in a package to be given to telecom and the BER record gets headers and trailers. If you use 'new BerString(DataDir)', it will allocate space for the record and build the record and then you'll have to move the BER record over to the area where your telecom message is being built. Ralph hates moving data unnecessarily. A preferable method is to leave room in the BER record buffer for the header and trailer information.
int header_size = 13, trailer_size = 14;
DataDir dir; // BER record you want between header & trailer
BerString berRec = new BerString(dir, header_size + trailer_size,
	header_size);
Parameters:
dir - directory
length - additional space requested
offset - where to build the BER record in the new buffer
 o BerString
  public BerString(InputStream in) throws FileNotFoundException, IOException, EOFException
Read a ber_record from the InputStream.
Parameters:
in - InputStream
Throws: FileNotFoundException
Creation of BufferedInputStream failed
Throws: IOException
Error reading InputStream

Methods

 o record
  public byte[] record()
Accessor method for byte[] record.
 o setOffset
  public void setOffset(int offset)
Allows caller to reset offset to beginning of record.
 o toString
  public final String toString()
Creates String representation of BER record.
Overrides:
toString in class Object
 o toString
  public final String toString(int length)
Creates String representation of BER record.
Parameters:
length - Truncate output to this length.
 o asn1Len
  public final int asn1Len()
Find the length of a BER record.
Returns:
length
 o getTag
  public final int getTag()
Get a tag directly from a BER record.
Returns:
tag
 o getLen
  public final int getLen()
Get a length directly from a BER record.
Returns:
length of BER record
 o putTag
  public final void putTag(int fldid,
                           byte asn1class,
                           byte form)
Put a tag directly into a BER record.
Parameters:
fldid - fldid of tag
asn1class - class of tag
form - form of tag
 o putLen
  public final void putLen(int len)
Put a length directly into a BER record.
Parameters:
length - length to put into record
 o putNumber
  public final void putNumber(int number)
Put a number into a BER record.
Parameters:
number - number to put
 o putChar
  public final void putChar(byte chars[],
                            int length)
Put an array of bytes in to a BER record.
Parameters:
chars - array of bytes
length - number of bytes to copy into record
 o IsCompleteBER
  public final boolean IsCompleteBER(int len,
                                     int remainder[])
Determine if a complete BER record has been received.
Parameters:
len - length of BER record
remainder - number of bytes missing from record, or 0
Returns:
true or false. If false, the remainder will tell you how many bytes need to be read. This value could be 0, which means that the record has indeterminate length or that you haven't even received the length portion of the record yet. How you read the remainder of the record, in this case, will depend on the access method. Best to just read 1 byte at a time until IsCompleteBER() tells you that you are done or gives you a definite length to read. If true, remainder[0] is set to the actual length of the record.

All Packages  Class Hierarchy  This Package  Previous  Next  Index