cryptix.asn1.lang
Class SimpleNode

java.lang.Object
  extended bycryptix.asn1.lang.SimpleNode
All Implemented Interfaces:
ASNObject, Node
Direct Known 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


Field Summary
protected  ASNObject[] children
           
protected  java.lang.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  java.lang.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  java.lang.Object value
          Java object representing the current value of this ASN.1 object when applicable.
 
Constructor Summary
SimpleNode(int i)
           
SimpleNode(Parser p, int i)
           
 
Method Summary
 java.lang.Object accept(ParserVisitor visitor, java.lang.Object data)
          Accepts a visitor.
 java.lang.Object childrenAccept(ParserVisitor visitor, java.lang.Object data)
          Accepts the visitor.
 void dump()
          Dumps this object's specification to System.out.
 void dump(java.lang.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(java.lang.String aName)
          Returns a child component of an ASN.1 construct given its full name.
 java.lang.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.
 java.lang.String getName()
           
 ASNObject getParent()
           
 Parser getParser()
           
 Tag getTag()
          Returns a reference to an instance of this ASN.1 object's Tag.
 java.lang.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.
 java.lang.Object jjtAccept(ParserVisitor visitor, java.lang.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(java.lang.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(java.lang.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(java.lang.Object value)
          Sets the value of this component to a native Java instance.
 java.lang.String toString()
          You can override these two methods in subclasses of SimpleNode to customize the way the node appears when the tree is dumped.
 java.lang.String toString(java.lang.String prefix)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected ASNObject parent

children

protected ASNObject[] children

id

protected int id

parser

protected Parser parser

name

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


tag

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


optional

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


value

protected java.lang.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.

See Also:
ASNObject.setValue(java.lang.Object)

defaultValue

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

Constructor Detail

SimpleNode

public SimpleNode(int i)

SimpleNode

public SimpleNode(Parser p,
                  int i)
Method Detail

getInstance

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


jjtOpen

public void jjtOpen()
Description copied from interface: Node
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

jjtClose

public void jjtClose()
Description copied from interface: Node
This method is called after all the child nodes have been added.

Specified by:
jjtClose in interface Node

jjtSetParent

public void jjtSetParent(Node n)
Description copied from interface: Node
This pair of methods are used to inform the node of its parent.

Specified by:
jjtSetParent in interface Node

jjtGetParent

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

getParent

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

jjtAddChild

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

Specified by:
jjtAddChild in interface Node

jjtGetChild

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

Specified by:
jjtGetChild in interface Node

getChild

public ASNObject getChild(int i)

getChildren

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

jjtGetNumChildren

public int jjtGetNumChildren()
Description copied from interface: Node
Return the number of children the node has.

Specified by:
jjtGetNumChildren in interface Node

jjtAccept

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

Specified by:
jjtAccept in interface Node
Throws:
java.io.IOException

childrenAccept

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

Throws:
java.io.IOException

toString

public java.lang.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 java.lang.String toString(java.lang.String prefix)

getParser

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

getID

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

setName

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


getName

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

getComponent

public ASNObject getComponent(java.lang.String aName)
Description copied from interface: ASNObject
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.

setTag

public void setTag(Tag tag)
Description copied from interface: ASNObject
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

getTag

public Tag getTag()
Description copied from interface: ASNObject
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

isOptional

public boolean isOptional()
Description copied from interface: ASNObject
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.

setOptional

public void setOptional(boolean flag)
Description copied from interface: ASNObject
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

setValue

public void setValue(java.lang.Object value)
Description copied from interface: ASNObject
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

getValue

public java.lang.Object getValue()
Description copied from interface: ASNObject
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.
See Also:
ASNObject.setValue(java.lang.Object)

setDefaultValue

public void setDefaultValue(java.lang.Object defaultValue)
Description copied from interface: ASNObject
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.

getDefaultValue

public java.lang.Object getDefaultValue()
Description copied from interface: ASNObject
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

dump

public void dump()
Description copied from interface: ASNObject
Dumps this object's specification to System.out.

Specified by:
dump in interface ASNObject

dump

public void dump(java.lang.String prefix)
Description copied from interface: ASNObject
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.

accept

public java.lang.Object accept(ParserVisitor visitor,
                               java.lang.Object data)
                        throws java.io.IOException
Description copied from interface: ASNObject
Accepts a visitor.

Specified by:
accept in interface ASNObject
Parameters:
visitor - An instance that implements the ParserVisitor interface.
Throws:
java.io.IOException - If an exception occurs during the application of the Visitor method.
See Also:
ParserVisitor