/** * See {@link #registerHandler(DERPath, ParseHandler)}. * * @param path to register * @param handler to associate with the path */ public void registerHandler(final String path, final ParseHandler handler) { registerHandler(new DERPath(path), handler); }
/** * See {@link #registerHandler(DERPath, ParseHandler)}. * * @param path to register * @param handler to associate with the path */ public void registerHandler(final String path, final ParseHandler handler) { registerHandler(new DERPath(path), handler); }
/** * See {@link #registerHandler(DERPath, ParseHandler)}. * * @param path to register * @param handler to associate with the path */ public void registerHandler(final String path, final ParseHandler handler) { registerHandler(new DERPath(path), handler); }
/** @throws Exception On test failure. */ @Test(groups = {"asn1"}) public void testEquals() throws Exception { Assert.assertTrue(new DERPath("/SEQ[0]/OCTSTR[1]").equals(new DERPath("/SEQ[0]/OCTSTR[1]"))); Assert.assertFalse(new DERPath("/SEQ[0]/OCTSTR[1]").equals(new DERPath("/SEQ[0]/OCTSTR[2]"))); Assert.assertFalse(new DERPath("/SEQ[0]/OCTSTR[1]").equals(new DERPath("/SEQ/OCTSTR[2]"))); }
/** * @param testPath to test * @param expected to test * * @throws Exception On test failure. */ @Test(groups = {"asn1"}, dataProvider = "paths") public void testEquals(final String testPath, final String expected) throws Exception { Assert.assertTrue(new DERPath(testPath).equals(new DERPath(expected))); } }
/** * Add the given tag at the specified index to all permutations of the current parser path and increases the number of * permutations as necessary to satisfy the following relation: * * <pre>size = 2^n</pre> * * <p>where n is the path length.</p> * * @param tag to add to path. * @param index of tag relative to parent. */ private void addTag(final DERTag tag, final int index) { if (permutations.isEmpty()) { permutations.add(new DERPath().pushNode(tag.name())); permutations.add(new DERPath().pushNode(tag.name(), index)); } else { final Collection<DERPath> generation = new ArrayDeque<>(permutations.size()); for (DERPath p : permutations) { generation.add(new DERPath(p).pushNode(tag.name())); p.pushNode(tag.name(), index); } permutations.addAll(generation); } }
/** * Add the given tag at the specified index to all permutations of the current parser path and increases the number of * permutations as necessary to satisfy the following relation: * * <pre>size = 2^n</pre> * * <p>where n is the path length.</p> * * @param tag to add to path. * @param index of tag relative to parent. */ private void addTag(final DERTag tag, final int index) { if (permutations.isEmpty()) { permutations.add(new DERPath().pushNode(tag.name())); permutations.add(new DERPath().pushNode(tag.name(), index)); } else { final Collection<DERPath> generation = new ArrayDeque<>(permutations.size()); for (DERPath p : permutations) { generation.add(new DERPath(p).pushNode(tag.name())); p.pushNode(tag.name(), index); } permutations.addAll(generation); } }
/** * @param testPath to test * @param expected to test * * @throws Exception On test failure. */ @Test(groups = {"asn1"}, dataProvider = "paths") public void testToString(final String testPath, final String expected) throws Exception { Assert.assertEquals(new DERPath(testPath).toString(), expected); }
/** * Add the given tag at the specified index to all permutations of the current parser path and increases the number of * permutations as necessary to satisfy the following relation: * * <pre>size = 2^n</pre> * * <p>where n is the path length.</p> * * @param tag to add to path. * @param index of tag relative to parent. */ private void addTag(final DERTag tag, final int index) { if (permutations.isEmpty()) { permutations.add(new DERPath().pushNode(tag.name())); permutations.add(new DERPath().pushNode(tag.name(), index)); } else { final Collection<DERPath> generation = new ArrayDeque<>(permutations.size()); for (DERPath p : permutations) { generation.add(new DERPath(p).pushNode(tag.name())); p.pushNode(tag.name(), index); } permutations.addAll(generation); } }
/** @throws Exception On test failure. */ @Test(groups = {"asn1"}) public void testHashcode() throws Exception { Assert.assertEquals(new DERPath("/SEQ[0]/OCTSTR[1]").hashCode(), new DERPath("/SEQ[0]/OCTSTR[1]").hashCode()); Assert.assertFalse(new DERPath("/SEQ[0]/OCTSTR[1]").hashCode() == new DERPath("/SEQ[0]/OCTSTR[2]").hashCode()); Assert.assertFalse(new DERPath("/SEQ[0]/OCTSTR[1]").hashCode() == new DERPath("/SEQ/OCTSTR[2]").hashCode()); }
/** @throws Exception On test failure. */ @Test(groups = {"asn1"}) public void testPushPop() throws Exception { final DERPath path = new DERPath("/SEQ"); path.pushNode("OCTSTR"); Assert.assertEquals(path.toString(), "/SEQ/OCTSTR"); Assert.assertEquals(path.popNode(), "OCTSTR"); path.pushNode("INT", 1); Assert.assertEquals(path.toString(), "/SEQ/INT[1]"); Assert.assertEquals(path.popNode(), "INT[1]"); Assert.assertEquals(path.popNode(), "SEQ"); Assert.assertNull(path.popNode()); Assert.assertNull(path.popNode()); }