Package net.aifusion.asn
Class AsnNode
java.lang.Object
net.aifusion.asn.AsnNode
- Direct Known Subclasses:
AsnModule
AST Node for ASN.1 parsing. Contains a name and/or a value
- Author:
- Sharad Singhal
-
Constructor Summary
ConstructorDescriptionAsnNode
(AsnProduction production) Create a node for a productionAsnNode
(AsnProduction production, List<Token> tokens) Create a parser node with a list of tokensAsnNode
(AsnProduction production, Token token) Create a new parser node with a given token (name)AsnNode
(AsnProduction production, Token token, boolean isClassField) Create a parser node with a given nameAsnNode
(AsnProduction production, Token nameToken, Token valueToken) Create a new parser node with a given token pair -
Method Summary
Modifier and TypeMethodDescriptionAdd a child node to this nodeGet the ASN.1 value, if anygetChild
(int index) Get a given childGet the children of this nodeGet the full name of the nodegetName()
Get the name (value of token[0]) at this nodeGet the name token from this nodeGet the production at this nodegetValue()
Get the value (value of token[1]) at this nodeGet the value token from this node.boolean
Check if this node has any childrenboolean
Check if this node represents a built-in typelocate
(AsnProduction production, String name) Locate a node corresponding to a given name and production starting at this nodelocateType
(String name) Locate the node corresponding to the type for a given namevoid
reduce
(AsnNode searchRoot, PrintStream f) Add values to this subtree for defined constantstoString()
Return a string value for this node.
-
Constructor Details
-
AsnNode
Create a node for a production- Parameters:
production
- production associated with this node
-
AsnNode
Create a new parser node with a given token (name)- Parameters:
production
- production associated with this nodetoken
- - Token at this node
-
AsnNode
Create a parser node with a given name- Parameters:
production
- - production at this nodetoken
- - name token at this nodeisClassField
- - true if this node is an ObjectClass field, false otherwise
-
AsnNode
Create a new parser node with a given token pair- Parameters:
production
- - AstProductionnameToken
- - name tokenvalueToken
- - value token
-
AsnNode
Create a parser node with a list of tokens- Parameters:
production
- - productiontokens
- - associated tokens
-
-
Method Details
-
addChild
Add a child node to this node- Parameters:
child
- - child node- Returns:
- the child node
-
getChildren
Get the children of this node- Returns:
- - children for this node
-
getChild
Get a given child- Parameters:
index
- - index of the child- Returns:
- - child at given index
-
hasChildren
public boolean hasChildren()Check if this node has any children- Returns:
- - true if this node has children, false otherwise
-
getProduction
Get the production at this node- Returns:
- - production at this node
-
getName
Get the name (value of token[0]) at this node- Returns:
- name of the node
-
getNameToken
Get the name token from this node- Returns:
- - token at element 0, if any. Null if none present
-
getValue
Get the value (value of token[1]) at this node- Returns:
- value of the node
-
getAsnValue
Get the ASN.1 value, if any- Returns:
- asn value, if the node reduces to a constant value. Null otherwise
-
getValueToken
Get the value token from this node.- Returns:
- - token at element 1, if any. Null if none present
-
getFullName
Get the full name of the node- Returns:
- full name of the node
-
locateType
Locate the node corresponding to the type for a given name- Parameters:
name
- - string containing the name of the node- Returns:
- - node defining the corresponding type, null if none found
-
isBuiltInType
public boolean isBuiltInType()Check if this node represents a built-in type- Returns:
- - true if the name of the node is a built-in type, false otherwise
-
locate
Locate a node corresponding to a given name and production starting at this node- Parameters:
production
- - production to matchname
- - name to match- Returns:
- - Corresponding node. Null if none found
-
toString
-
toString
Return a string value for this node. Subclasses should override this rather than toString()- Parameters:
indent
- - indent used before the value of this node- Returns:
- - string containing the ASN.1 definition at this node
-
search
-
reduce
Add values to this subtree for defined constants- Parameters:
searchRoot
- - root of the tree (for locating referenced constants)f
- - print stream to dump the tree
-