cryptix.asn1.lang

Class SimpleNode

Implemented Interfaces:
ASNObject, Node
Known Direct Subclasses:
ASNAny, ASNBitString, ASNBoolean, ASNInteger, ASNNull, ASNObjectIdentifier, ASNOctetString, ASNPrintableString, ASNSequence, ASNSequenceOf, ASNSet, ASNSetOf, ASNSpecification, ASNTaggedType, ASNTime, ASNType, ASNTypeAlias

public class SimpleNode
extends java.lang.Object
implements ASNObject

Originally generated by jjTree (part of the JavaCC tool), this Class acts as the concrete implementation of a cryptix.asn1.lang.Node or an cryptix.asn1.lang.ASNObject in a jjtree output structure.

Copyright ©1997, 1998, 1999 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.1 $

Author:
Raif S. Naffah

Field Summary

protected ASNObject[]
children
protected Object
defaultValue
The Java object representing the default value for this ASN.1 object if such value is defined in the specification.
protected int
id
protected String
name
Name associated with this ASN.1 object.
protected boolean
optional
True if the ASN.1 object is optional, false otherwise.
protected ASNObject
parent
protected Parser
parser
protected Tag
tag
Tag associated with this ASN.1 object.
protected Object
value
Java object representing the current value of this ASN.1 object when applicable.

Constructor Summary

SimpleNode(Parser p, int i)
SimpleNode(int i)

Method Summary

Object
accept(ParserVisitor visitor, Object data)
Accepts a visitor.
Object
childrenAccept(ParserVisitor visitor, Object data)
Accepts the visitor.
void
dump()
Dumps this object's specification to System.out.
void
dump(String prefix)
Dumps this object's specification to System.out prefixing each line with the given string.
ASNObject
getChild(int i)
ASNObject[]
getChildren()
ASNObject
getComponent(String aName)
Returns a child component of an ASN.1 construct given its full name.
Object
getDefaultValue()
Similar to getValue() but operates on the default value of this ASN.1 object if such a value is/was defined in the specifications.
int
getID()
static SimpleNode
getInstance(Parser p, Tag tag)
Returns a new instance given a UNIVERSAL ASN.1 tag instance; null otherwise.
String
getName()
ASNObject
getParent()
Parser
getParser()
Tag
getTag()
Returns a reference to an instance of this ASN.1 object's Tag.
Object
getValue()
Returns the Java Object containing the current value of this ASN.1 object.
boolean
isOptional()
Returns true if this ASN.1 object is optional, false otherwise.
Object
jjtAccept(ParserVisitor visitor, Object data)
Accepts the visitor.
void
jjtAddChild(Node n, int i)
This method tells the node to add its argument to the node's list of children.
void
jjtClose()
This method is called after all the child nodes have been added.
Node
jjtGetChild(int i)
This method returns a child node.
int
jjtGetNumChildren()
Return the number of children the node has.
Node
jjtGetParent()
void
jjtOpen()
This method is called after the node has been made the current node.
void
jjtSetParent(Node n)
This pair of methods are used to inform the node of its parent.
void
setDefaultValue(Object defaultValue)
Similar to setValue() but operates on the default value of this ASN.1 object if such a value is/was defined in the specifications.
void
setName(String name)
Sets the name of this instance.
void
setOptional(boolean flag)
Sets the optional flag for this ASN.1 object to the designated value.
void
setTag(Tag tag)
Sets the tag of this ASN.1 object to be the designated instance.
void
setValue(Object value)
Sets the value of this component to a native Java instance.
String
toString()
You can override these two methods in subclasses of SimpleNode to customize the way the node appears when the tree is dumped.
String
toString(String prefix)

Field Details

children

protected ASNObject[] children

defaultValue

protected Object defaultValue
The Java object representing the default value for this ASN.1 object if such value is defined in the specification.

id

protected int id

name

protected String name
Name associated with this ASN.1 object.

optional

protected boolean optional
True if the ASN.1 object is optional, false otherwise.

parent

protected ASNObject parent

parser

protected Parser parser

tag

protected Tag tag
Tag associated with this ASN.1 object.

value

protected Object value
Java object representing the current value of this ASN.1 object when applicable. For the Java types used to represent these values see cryptix.asn1.lang.ASNObject.

Constructor Details

SimpleNode

public SimpleNode(Parser p,
                  int i)

SimpleNode

public SimpleNode(int i)

Method Details

accept

public Object accept(ParserVisitor visitor,
                     Object data)
            throws java.io.IOException
Accepts a visitor.
Specified by:
accept in interface ASNObject
Parameters:
visitor - An instance that implements the ParserVisitor interface.
See Also:
ParserVisitor

childrenAccept

public Object childrenAccept(ParserVisitor visitor,
                             Object data)
            throws java.io.IOException
Accepts the visitor.

dump

public void dump()
Dumps this object's specification to System.out.
Specified by:
dump in interface ASNObject

dump

public void dump(String prefix)
Dumps this object's specification to System.out prefixing each line with the given string.
Specified by:
dump in interface ASNObject
Parameters:
prefix - A string that will prefix each new line of the output.

getChild

public ASNObject getChild(int i)

getChildren

public ASNObject[] getChildren()
Specified by:
getChildren in interface ASNObject

getComponent

public ASNObject getComponent(String aName)
Returns a child component of an ASN.1 construct given its full name. The name can be a sequence of strings separated by the character '.' to denote their hierarchy within the ASN.1 object; eg: for an X.509 encoded Certificate, one can get to the OID (the "algorithm") of the AlgorithmIdentifier (the "signature") included in the CertificateInfo part (the "certificateInfo") by passing the following as an argument to an X.509 ASNObject instance:
    "certificateInfo.signature.algorithm"
 
Specified by:
getComponent in interface ASNObject
Returns:
A child component of this ASN.1 object given its dotted name.

getDefaultValue

public Object getDefaultValue()
Similar to getValue() but operates on the default value of this ASN.1 object if such a value is/was defined in the specifications. If no such default value was defnied in the specifications then this method returns a null.
Specified by:
getDefaultValue in interface ASNObject

getID

public int getID()
Specified by:
getID in interface ASNObject
Returns:
The ID assigned to this ASN.1 Object by the Parser.

getInstance

public static final SimpleNode getInstance(Parser p,
                                           Tag tag)
Returns a new instance given a UNIVERSAL ASN.1 tag instance; null otherwise.

getName

public String getName()
Specified by:
getName in interface ASNObject
Returns:
The name associated with this ASN.1 object.

getParent

public ASNObject getParent()
Specified by:
getParent in interface ASNObject

getParser

public Parser getParser()
Returns:
The cryptix.asn1.lang.Parser handling this ASN.1 object.

getTag

public Tag getTag()
Returns a reference to an instance of this ASN.1 object's Tag.
Specified by:
getTag in interface ASNObject
Returns:
A reference to an instance of this ASN.1 object's Tag.
See Also:
Tag

getValue

public Object getValue()
Returns the Java Object containing the current value of this ASN.1 object. For the mapping between ASN.1 values and Java types, see the setValue() method.
Specified by:
getValue in interface ASNObject
Returns:
The value of this component as a native Java object.

isOptional

public boolean isOptional()
Returns true if this ASN.1 object is optional, false otherwise.
Specified by:
isOptional in interface ASNObject
Returns:
True if this ASN.1 object is optional, false otherwise.

jjtAccept

public Object jjtAccept(ParserVisitor visitor,
                        Object data)
            throws java.io.IOException
Accepts the visitor.
Specified by:
jjtAccept in interface Node

jjtAddChild

public void jjtAddChild(Node n,
                        int i)
This method tells the node to add its argument to the node's list of children.
Specified by:
jjtAddChild in interface Node

jjtClose

public void jjtClose()
This method is called after all the child nodes have been added.
Specified by:
jjtClose in interface Node

jjtGetChild

public Node jjtGetChild(int i)
This method returns a child node. The children are numbered from zero, left to right.
Specified by:
jjtGetChild in interface Node

jjtGetNumChildren

public int jjtGetNumChildren()
Return the number of children the node has.
Specified by:
jjtGetNumChildren in interface Node

jjtGetParent

public Node jjtGetParent()
Specified by:
jjtGetParent in interface Node

jjtOpen

public void jjtOpen()
This method is called after the node has been made the current node. It indicates that child nodes can now be added to it.
Specified by:
jjtOpen in interface Node

jjtSetParent

public void jjtSetParent(Node n)
This pair of methods are used to inform the node of its parent.
Specified by:
jjtSetParent in interface Node

setDefaultValue

public void setDefaultValue(Object defaultValue)
Similar to setValue() but operates on the default value of this ASN.1 object if such a value is/was defined in the specifications.
Specified by:
setDefaultValue in interface ASNObject
Parameters:
defaultValue - The Java object instance representing the default value of this ASN.1 object.

setName

public void setName(String name)
Sets the name of this instance.

setOptional

public void setOptional(boolean flag)
Sets the optional flag for this ASN.1 object to the designated value. param flag The new value of the optional flag.
Specified by:
setOptional in interface ASNObject

setTag

public void setTag(Tag tag)
Sets the tag of this ASN.1 object to be the designated instance. param tag A reference to an instance of Tag.
Specified by:
setTag in interface ASNObject
See Also:
Tag

setValue

public void setValue(Object value)
Sets the value of this component to a native Java instance.

The mapping between ASN.1 types and Java types is given below:

  1. BOOLEAN: java.lang.Boolean;
  2. INTEGER: java.math.BigInteger;
  3. BIT STRING: byte[];
  4. OCTET STRING: byte[];
  5. NULL: null;
  6. OID: A java.lang.String containing numeric digits and the character '.';
  7. SEQUENCE, SEQUENCE OF, SET and SET OF: cryptix.asn1.lang.ASNObject[];
  8. PrintableString: java.lang.String.
Specified by:
setValue in interface ASNObject

toString

public String toString()
You can override these two methods in subclasses of SimpleNode to customize the way the node appears when the tree is dumped. If your output uses more than one line you should override toString(String), otherwise overriding toString() is probably all you need to do.

toString

public String toString(String prefix)