Package org.ldaptive.asn1
Class DERPath
- java.lang.Object
-
- org.ldaptive.asn1.DERPath
-
public class DERPath extends Object
Describes paths to individual elements of an encoded DER object that may be addressed during parsing to associate a parsed element with a handler to handle that element. Consider the following production rule for a complex type that may be DER encoded:BankAccountSet ::= SET OF { account BankAccount } BankAccount ::= SEQUENCE OF { accountNumber OCTET STRING, accountName OCTET STRING, accountType AccountType, balance REAL } AccountType ::= ENUM { checking (0), savings (1) }
Given an instance of BankAccountSet with two elements, the path to the balance of each bank account in the set is given by the following expression:
/SET/SEQ/REAL
Individual child elements can be accessed by explicitly mentioning the index of the item relative to its parent. For example, the second bank account in the set can be accessed as follows:
/SET/SEQ[1]
Node names in DER paths are constrained to the following:
- See Also:
DERParser
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
DERPath.Node
DER path node encapsulates the path name and its location among other children that share a common parent.
-
Field Summary
Fields Modifier and Type Field Description private static int
HASH_CODE_SEED
hash code seed.private static Pattern
NODE_PATTERN
General pattern for DER path nodes.private Deque<DERPath.Node>
nodeStack
Describes the path as a FIFO set of nodes.static String
PATH_SEPARATOR
Separates nodes in a path specification.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
int
getSize()
Gets the number of nodes in the path.int
hashCode()
boolean
isEmpty()
Determines whether the path contains any nodes.String
peekNode()
Examines the first node in the path without removing it.String
popNode()
Removes the last node in the path.DERPath
pushNode(String name)
Appends a node to the path.DERPath
pushNode(String name, int index)
Appends a node to the path with the given child index.(package private) static DERPath.Node
toNode(String node)
Converts a string representation of a node into aDERPath.Node
object.String
toString()
-
-
-
Field Detail
-
PATH_SEPARATOR
public static final String PATH_SEPARATOR
Separates nodes in a path specification.- See Also:
- Constant Field Values
-
NODE_PATTERN
private static final Pattern NODE_PATTERN
General pattern for DER path nodes.
-
HASH_CODE_SEED
private static final int HASH_CODE_SEED
hash code seed.- See Also:
- Constant Field Values
-
nodeStack
private final Deque<DERPath.Node> nodeStack
Describes the path as a FIFO set of nodes.
-
-
Constructor Detail
-
DERPath
public DERPath()
Creates an empty path specification.
-
DERPath
public DERPath(DERPath path)
Copy constructor.- Parameters:
path
- to read nodes from
-
DERPath
public DERPath(String pathSpec)
Creates a path specification from its string representation.- Parameters:
pathSpec
- string representation of a path, e.g. /SEQ[1]/CHOICE.
-
-
Method Detail
-
pushNode
public DERPath pushNode(String name)
Appends a node to the path.- Parameters:
name
- of the path element to add- Returns:
- This instance with new node appended.
-
pushNode
public DERPath pushNode(String name, int index)
Appends a node to the path with the given child index.- Parameters:
name
- of the path element to addindex
- child index- Returns:
- This instance with new node appended.
-
peekNode
public String peekNode()
Examines the first node in the path without removing it.- Returns:
- first node in the path or null if no nodes remain
-
popNode
public String popNode()
Removes the last node in the path.- Returns:
- last node in the path or null if no more nodes remain.
-
getSize
public int getSize()
Gets the number of nodes in the path.- Returns:
- node count.
-
isEmpty
public boolean isEmpty()
Determines whether the path contains any nodes.- Returns:
- True if path contains 0 nodes, false otherwise.
-
toNode
static DERPath.Node toNode(String node)
Converts a string representation of a node into aDERPath.Node
object.- Parameters:
node
- String representation of node.- Returns:
- Node corresponding to given string representation.
- Throws:
IllegalArgumentException
- for an invalid node name.
-
-