@Test(groups = "asn1") public void testToNode() throws Exception { Assert.assertEquals(DERPath.toNode("SEQ").getName(), "SEQ"); Assert.assertEquals(DERPath.toNode("SEQ").getChildIndex(), -1); Assert.assertEquals(DERPath.toNode("APP(4)").getName(), "APP(4)"); Assert.assertEquals(DERPath.toNode("APP(4)").getChildIndex(), -1); Assert.assertEquals(DERPath.toNode("ENUM[0]").getName(), "ENUM"); Assert.assertEquals(DERPath.toNode("ENUM[0]").getChildIndex(), 0); Assert.assertEquals(DERPath.toNode("OCTSTR[1]").getName(), "OCTSTR"); Assert.assertEquals(DERPath.toNode("OCTSTR[1]").getChildIndex(), 1); Assert.assertEquals(DERPath.toNode("INT[3]").getName(), "INT"); Assert.assertEquals(DERPath.toNode("INT[3]").getChildIndex(), 3); Assert.assertEquals(DERPath.toNode("CTX(0)").getName(), "CTX(0)"); Assert.assertEquals(DERPath.toNode("CTX(0)").getChildIndex(), -1); }
static Node toNode(final String node) { final Matcher matcher = NODE_PATTERN.matcher(node); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid node: " + node); } final String name = matcher.group(1); final String index = matcher.group(2); if (index != null) { return new Node(name, Integer.parseInt(index)); } return new Node(name); }
DERPath { static Node toNode(final String node) { final Matcher matcher = NODE_PATTERN.matcher(node); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid node: " + node); } final String name = matcher.group(1); final String index = matcher.group(2); if (index != null) { return new Node(name, Integer.parseInt(index)); } return new Node(name); } }
DERPath { static Node toNode(final String node) { final Matcher matcher = NODE_PATTERN.matcher(node); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid node: " + node); } final String name = matcher.group(1); final String index = matcher.group(2); if (index != null) { return new Node(name, Integer.parseInt(index)); } return new Node(name); } DERPath();  DERPath(final DERPath path);  DERPath(final String pathSpec); }
DERPath { static Node toNode(final String node) { final Matcher matcher = NODE_PATTERN.matcher(node); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid node: " + node); } final String name = matcher.group(1); final String index = matcher.group(2); if (index != null) { return new Node(name, Integer.parseInt(index)); } return new Node(name); } DERPath();  DERPath(final DERPath path);  DERPath(final String pathSpec); DERPath pushNode(final String name); DERPath pushNode(final String name, final int index); String peekNode(); String popNode(); int getSize(); boolean isEmpty(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); }
DERPath { static Node toNode(final String node) { final Matcher matcher = NODE_PATTERN.matcher(node); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid node: " + node); } final String name = matcher.group(1); final String index = matcher.group(2); if (index != null) { return new Node(name, Integer.parseInt(index)); } return new Node(name); } DERPath();  DERPath(final DERPath path);  DERPath(final String pathSpec); DERPath pushNode(final String name); DERPath pushNode(final String name, final int index); String peekNode(); String popNode(); int getSize(); boolean isEmpty(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); static final String PATH_SEPARATOR; }