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
-
offset
-
-
record
-
-
BerString(byte[])
-
-
BerString(DataDir)
- Build a ber_record from a directory.
-
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.
-
BerString(InputStream)
- Read a ber_record from the InputStream.
-
asn1Len()
- Find the length of a BER record.
-
getLen()
- Get a length directly from a BER record.
-
getTag()
- Get a tag directly from a BER record.
-
IsCompleteBER(int, int[])
- Determine if a complete BER record has been received.
-
putChar(byte[], int)
- Put an array of bytes in to a BER record.
-
putLen(int)
- Put a length directly into a BER record.
-
putNumber(int)
- Put a number into a BER record.
-
putTag(int, byte, byte)
- Put a tag directly into a BER record.
-
record()
- Accessor method for byte[] record.
-
setOffset(int)
- Allows caller to reset offset to beginning of record.
-
toString()
- Creates String representation of BER record.
-
toString(int)
- Creates String representation of BER record.
record
protected byte record[]
offset
protected int offset
BerString
public BerString(byte record[])
BerString
public BerString(DataDir dir)
- Build a ber_record from a directory.
- Parameters:
- dir - directory
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
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
record
public byte[] record()
- Accessor method for byte[] record.
setOffset
public void setOffset(int offset)
- Allows caller to reset offset to beginning of record.
toString
public final String toString()
- Creates String representation of BER record.
- Overrides:
- toString in class Object
toString
public final String toString(int length)
- Creates String representation of BER record.
- Parameters:
- length - Truncate output to this length.
asn1Len
public final int asn1Len()
- Find the length of a BER record.
- Returns:
- length
getTag
public final int getTag()
- Get a tag directly from a BER record.
- Returns:
- tag
getLen
public final int getLen()
- Get a length directly from a BER record.
- Returns:
- length of BER record
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
putLen
public final void putLen(int len)
- Put a length directly into a BER record.
- Parameters:
- length - length to put into record
putNumber
public final void putNumber(int number)
- Put a number into a BER record.
- Parameters:
- number - number to put
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
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