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

Class oclc.ber.DataDir

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

public class DataDir
extends ASN1
DataDir is a class for manipulating tree structures and for putting data into and getting data out of tree structures.

Example: Create a DBI Begin Session request and get the session id from the response. This example assumes methods to send requests and get responses from a DBI Server.

BerString ber_record;
DataDir dir, subdir;
int sessid;
//
dir = new DataDir(DBI.DBI_IN, ASN1.APPLICATION); // create DataDir
subdir = dir.daddTag(DBI.BEGINS, ASN1.CONTEXT);  // make it a Begin Session
subdir.daddChar(DBI.BS_USERID, ASN1.CONTEXT, "ralph"); // add userid
ber_record = new BerString(dir);	         // make BER record
//
send_request(ber_record);
ber_record = get_response();
//
dir = new DataDir(ber_record);
subdir = dir.child();		// skip over DBI_OUT node
subdir = subdir.child();	// skip over BEGINS node
while (subdir != null)		// find node with tag==SESSID
{
    if (subdir.fldid() == DBI.SESSID)
    {
        sessid = subdir.dgetNum();
        break;
    }
    subdir = subdir.next();	// point to sibling of this node
}
Version:
%W% %G%
Author:
Jenny Colvard
See Also:
ASN1

Constructor Index

 o DataDir(BerString)
Builds a DataDir tree structure for a BER record.
 o DataDir(DataDir, int, byte)
Create a non-leaf node that will be a child of the specified parent.
 o DataDir(int, byte)
Create a DataDir node with the specified fldid and asn1class.

Method Index

 o asmRec(BerString)
Assembles a BER record from a DataDir into a BerString object.
 o asn1class()
Accessor method for asn1class for this DataDir.
 o child()
Accessor method for child of this DataDir.
 o clone()
Clone the DataDir and all it's children and siblings.
 o count()
Accessor method for count for this DataDir.
 o daddBits(int, byte, String)
Add a leaf node which contains a BITSTRING to a directory.
 o daddChar(int, byte, byte[])
Add a leaf node to the directory with byte[] data.
 o daddChar(int, byte, String)
Add a leaf node to the directory with String data.
 o daddDir(DataDir)
Attach one directory to another.
 o daddNum(int, byte, int)
Add a leaf node to the directory with INTEGER data.
 o daddObj(DataDirObject)
Remove the reference to any data and create a reference to the specified DataDirObject.
 o daddObj(int, byte, DataDirObject)
Add a leaf node to the directory with DataDirObject data.
 o daddoid(int, byte, String)
Add a leaf node to a directory which contains an OID.
 o daddTag(int, byte)
Add a non-leaf node to a directory.
 o data()
Accessor method for data for this DataDir.
 o ddelDir()
Remove a node and its children from a directory.
 o dgetBits()
Get a BITSTRING from a leaf node.
 o dgetChar()
Get a String from a leaf node.
 o dgetNum()
Get an INTEGER from a leaf node.
 o dgetoid()
Get a human readable OID from a leaf node.
 o dinsTag(int, byte)
Insert a new tag before an existing dir and all its siblings.
 o dreplaceNum(int)
Replace the data contents with an INTEGER value.
 o dtagFound(int, byte)
Checks for existence of a particular node in a directory.
 o fldid()
Accessor method for fldid for this DataDir.
 o form()
Accessor method for form for this DataDir.
 o next()
Accessor method for next sibling of this DataDir.
 o object()
Accessor method for DataDirObject for this DataDir.
 o parent()
Accessor method for parent of this DataDir.
 o prev()
Accessor method for previous sibling of this DataDir.
 o recLen()
Returns the length of the BER record that would be created from the directory.
 o toString()
Produce a formatted hex dump of a directory.

Constructors

 o DataDir
  public DataDir(int fldid,
                 byte asn1class)
Create a DataDir node with the specified fldid and asn1class.
Parameters:
fldid - tag to be assigned to new node
asn1class - class to be assigned to new node
 o DataDir
  public DataDir(DataDir parent_dir,
                 int fldid,
                 byte asn1class)
Create a non-leaf node that will be a child of the specified parent.
Parameters:
fldid - tag to be assigned to new node
asn1class - class to be assigned to new node
 o DataDir
  public DataDir(BerString record)
Builds a DataDir tree structure for a BER record.
Parameters:
record - BER record

Methods

 o child
  public final DataDir child()
Accessor method for child of this DataDir.
 o parent
  public final DataDir parent()
Accessor method for parent of this DataDir.
 o next
  public final DataDir next()
Accessor method for next sibling of this DataDir.
 o prev
  public final DataDir prev()
Accessor method for previous sibling of this DataDir.
 o object
  public final DataDirObject object()
Accessor method for DataDirObject for this DataDir.
 o data
  public final byte[] data()
Accessor method for data for this DataDir.
 o fldid
  public final int fldid()
Accessor method for fldid for this DataDir.
 o asn1class
  public final byte asn1class()
Accessor method for asn1class for this DataDir.
 o form
  public final byte form()
Accessor method for form for this DataDir.
 o count
  public final int count()
Accessor method for count for this DataDir. If the DataDir is PRIMITIVE, then the count is the length of the data, object or number. If the DataDir is CONSTRUCTED, then the count is the number of children belonging to this DataDir.
 o toString
  public final String toString()
Produce a formatted hex dump of a directory.
Returns:
String
Overrides:
toString in class Object
 o daddTag
  public DataDir daddTag(int fldid,
                         byte asn1class)
Add a non-leaf node to a directory.
Parameters:
fldid - tag to be assigned to new node
asn1class - class to be assigned to new node
 o dinsTag
  public DataDir dinsTag(int fldid,
                         byte asn1class)
Insert a new tag before an existing dir and all its siblings.
Parameters:
fldid - tag to be assigned to new node
asn1class - class to be assigned to new node
 o asmRec
  public final void asmRec(BerString record)
Assembles a BER record from a DataDir into a BerString object. NOTE: recLen() must be called immediately before calling asmRec(). recLen() sets information in the DataDir that is critical for the function of asmRec(). recLen() also returns the length needed to construct the BerString object.
Parameters:
record - object to hold BER record
 o daddObj
  public void daddObj(DataDirObject obj)
Remove the reference to any data and create a reference to the specified DataDirObject. This is useful when the DataDir was constructed from a BerString. The caller can create an object from the byte array in the original DataDir and then replace the byte array with a reference to the desired object.
Parameters:
obj - object reference to added to DataDir
 o daddObj
  public DataDir daddObj(int fldid,
                         byte asn1class,
                         DataDirObject obj)
Add a leaf node to the directory with DataDirObject data.
Parameters:
fldid - tag to be assigned to new node
asn1class - class to be assigned to new node
obj - object reference
 o daddChar
  public final DataDir daddChar(int fldid,
                                byte asn1class,
                                String input_data)
Add a leaf node to the directory with String data. The data will be converted to a byte array.
Parameters:
fldid - tag to be assigned to new node
asn1class - class to be assigned to new node
input_data - String reference
 o daddChar
  public final DataDir daddChar(int fldid,
                                byte asn1class,
                                byte input_data[])
Add a leaf node to the directory with byte[] data.
Parameters:
fldid - tag to be assigned to new node
asn1class - class to be assigned to new node
intput_data - byte[]
 o daddNum
  public final DataDir daddNum(int fldid,
                               byte asn1class,
                               int num)
Add a leaf node to the directory with INTEGER data.
Parameters:
fldid - tag to be assigned to new node
asn1class - class to be assigned to new node
num - INTEGER
 o dreplaceNum
  public final DataDir dreplaceNum(int num)
Replace the data contents with an INTEGER value.
Parameters:
num - INTEGER
 o daddBits
  public final DataDir daddBits(int fldid,
                                byte asn1class,
                                String bits)
Add a leaf node which contains a BITSTRING to a directory. NOTE: Any of the characters '1', 'y', 'Y', 't' or 'T' get a 1 in the encoded bitstring. Any other characters get a 0.
Parameters:
fldid - tag to be assigned to new node
asn1class - class to be assigned to new node
bits - String containing array of bits.
 o daddoid
  public final DataDir daddoid(int fldid,
                               byte asn1class,
                               String cstring)
Add a leaf node to a directory which contains an OID.
Parameters:
fldid - tag to be assigned to new node
asn1class - class to be assigned to new node
cstring - String containing human readable OID
 o recLen
  public final int recLen()
Returns the length of the BER record that would be created from the directory.
Returns:
length of record that would be created by asmRec().
 o dgetChar
  public final String dgetChar()
Get a String from a leaf node.
Returns:
String
 o dgetNum
  public final int dgetNum()
Get an INTEGER from a leaf node.
Returns:
value of INTEGER data. Undefined if not a leaf node or if leaf node doesn't contain INTEGER data.
 o dgetoid
  public final String dgetoid()
Get a human readable OID from a leaf node.
Returns:
A String with human readable OID
 o dgetBits
  public final String dgetBits()
Get a BITSTRING from a leaf node.
Returns:
A String with 'y' for 1 bits and 'n' for 0 bits.
 o daddDir
  public final DataDir daddDir(DataDir newdir)
Attach one directory to another.
Parameters:
newdir - directory to be added
 o ddelDir
  public final boolean ddelDir()
Remove a node and its children from a directory.
 o dtagFound
  public final boolean dtagFound(int fldid,
                                 byte asn1class)
Checks for existence of a particular node in a directory.
Parameters:
fldid - tag of node to be found
asn1class - class of node to be found
Returns:
true if found, false if not found
 o clone
  public final Object clone()
Clone the DataDir and all it's children and siblings. It will clone all data referenced by the DataDirs.
Returns:
cloned DataDir
Overrides:
clone in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index