Open SiteSearch 4.1.1
Final

ORG.oclc.ber
Class ASN1

java.lang.Object
  |
  +--ORG.oclc.ber.ASN1
Direct Known Subclasses:
BerString, DataDir

public class ASN1
extends Object

ASN1 is the constant data needed for BerString and DataDir. It also contains generic routines used by both of those classes.

The BER utilities presented here are a translation of the C version of berutil written by Ralph Levan at OCLC. The documentation presented here is pretty much taken from his docummentation.

OCLC has chosen not to use an ASN.1 compiler in its ASN.1 activities. These activities include ASN.1 encoding of z39.50, DBI (an internal variant on z39.50) and ASN.1 encoding of all database records, including MARC records. Strictly speaking, OCLC does not use ASN.1 internally, other than as a language for communicating record specifications to programmers. However, all the records mentioned above are encoded using the Basic Encoding Rules and are manipulable by the BER decoders of ASN.1 compilers. We have chosen to represent the BER records internally as a tree structure of linked lists that describe the parts of the BER record. We believe that this hierarchical structure fully represents the complexity of record encodable with the BER. The nodes in this tree structure contain the BER tag, class, form and either a pointer to data or a pointer to the next node down in the hierarchy, depending on whether the form was primitive or constructed. We often use a picture of this tree structure for describing the syntax of the record being encoded, rather than using ASN.1. For instance, the DeleteResultSetRequest is described in ASN.1 as:

DeleteResultSetRequest ::=
SEQUENCE
{referenceId                  ReferenceId OPTIONAL,
deleteSetFunction        [32] IMPLICIT INTEGER
{DeleteSpecificSet (0),
deleteAllSets      (1)}
resultSetId                   ResultSetId OPTIONAL}

with appropriate definitions for the non-terminals given somewhere else. We describe the same thing with the following picture:

DeleteResultSetRequest [26]
|
[ReferenceId [2]] --- deleteSetFunction [32] --- [resultSetId [31]]
|
OCTETSTRING

with appropriate descriptions of the values that the leaves in the tree can take. We do not make any claims that this is better than ASN.1, it's just that it maps directly into the tree structure that gets mapped into and out of the BER records. What we lose by using our own internal syntax is the use of a Presentation Layer produced by someone else. This means that currently those things that could be done by the Presentation layer are done by the application. This includes integer byte ordering, characterset translation and BER encoding. While this could be a major loss, is hasn't been one so far and we haven't heard of any real Presentation layers that do all the things promised anyway.

See Also:
BerString, DataDir

Field Summary
static byte APPLICATION
           
static byte arbitrary
           
static byte BITSTRING
           
static byte BOOLEAN
           
static byte CONSTRUCTED
           
static byte CONTEXT
           
static byte ENUMERATED
           
static byte EXTERNAL
           
static byte GENERALSTRING
           
static byte INTEGER
           
static byte NULL
           
static byte OBJECTDESCRIPTOR
           
static byte OBJECTIDENTIFIER
           
static byte octet_aligned
           
static byte OCTETSTRING
           
static byte PRIMITIVE
           
static byte PRIVATE
           
static byte SEQUENCE
           
static byte SET
           
static byte single_ASN1_type
           
static byte UNIVERSAL
           
static byte VISIBLESTRING
           
 
Constructor Summary
ASN1()
           
 
Method Summary
static long getLong(byte[] record, int offset, int len)
          Get a number from a buffer
static int getNum(byte[] record, int offset, int len)
           
protected static int lenLen(int length)
          Get the length needed to represent the given length.
protected static int numLen(long num)
          Get the length needed to represent the given number.
protected static void putNum(byte[] record, int offset, long num)
          Put a number into a given buffer
protected static int tagLen(int fldid)
          Get the length needed to represent the given fldid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNIVERSAL

public static final byte UNIVERSAL

APPLICATION

public static final byte APPLICATION

CONTEXT

public static final byte CONTEXT

PRIVATE

public static final byte PRIVATE

PRIMITIVE

public static final byte PRIMITIVE

CONSTRUCTED

public static final byte CONSTRUCTED

BOOLEAN

public static final byte BOOLEAN

INTEGER

public static final byte INTEGER

BITSTRING

public static final byte BITSTRING

OCTETSTRING

public static final byte OCTETSTRING

NULL

public static final byte NULL

OBJECTIDENTIFIER

public static final byte OBJECTIDENTIFIER

OBJECTDESCRIPTOR

public static final byte OBJECTDESCRIPTOR

EXTERNAL

public static final byte EXTERNAL

ENUMERATED

public static final byte ENUMERATED

SEQUENCE

public static final byte SEQUENCE

SET

public static final byte SET

VISIBLESTRING

public static final byte VISIBLESTRING

GENERALSTRING

public static final byte GENERALSTRING

single_ASN1_type

public static final byte single_ASN1_type

octet_aligned

public static final byte octet_aligned

arbitrary

public static final byte arbitrary
Constructor Detail

ASN1

public ASN1()
Method Detail

tagLen

protected static final int tagLen(int fldid)
Get the length needed to represent the given fldid.
Parameters:
fldid - determine length needed to encode this
Returns:
length needed to encode given fldid

lenLen

protected static final int lenLen(int length)
Get the length needed to represent the given length.
Parameters:
length - determine length needed to encode this
Returns:
length needed to encode given length

numLen

protected static final int numLen(long num)
Get the length needed to represent the given number.
Parameters:
number - determine length needed to encode this
Returns:
length needed to encode given number

putNum

protected static final void putNum(byte[] record,
                                   int offset,
                                   long num)
Put a number into a given buffer
Parameters:
record - buffer to use
offset - offset into buffer
num - number to put into buffer

getLong

public static final long getLong(byte[] record,
                                 int offset,
                                 int len)
Get a number from a buffer
Parameters:
record - buffer
offset - start at this offset
len - length of the number to get

getNum

public static final int getNum(byte[] record,
                               int offset,
                               int len)

Open SiteSearch 4.1.1
Final