@Override public E createChildElement(E parent, String tag, Map<String, String> attributes) { return getDelegate().createChildElement(parent, tag, attributes); }
@Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { doc.createChildElement( doc.getDocumentElement(), "x", Collections.<String, String>emptyMap()); } });
@Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { doc.createChildElement( doc.getDocumentElement(), "x", Collections.<String, String>emptyMap()); } });
@Override public <N, E extends N, T extends N> Object exec(MutableDocument<N, E, T> doc) { return doc.createChildElement(doc.getDocumentElement(), "foreign", Attributes.EMPTY_MAP); } });
@Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { doc.createChildElement(doc.getDocumentElement(), DocumentBasedManifest.MANIFEST_TOP_TAG, Collections.<String, String>emptyMap()); } });
@Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { doc.createChildElement(doc.getDocumentElement(), DocumentBasedManifest.MANIFEST_TOP_TAG, Collections.<String, String>emptyMap()); } });
@Override public <N, E extends N, T extends N> Object exec(MutableDocument<N, E, T> doc) { return doc.createChildElement(doc.getDocumentElement(), "foreign", Attributes.EMPTY_MAP); } });
/** Insert bad WantedEvaluation data. */ private static <N, E extends N, T extends N> void insertInvalidEvaluation( MutableDocument<N, E, T> doc) { Map<String, String> attributes = CollectionUtils.newHashMap(); attributes.put(DocumentBasedAbuseStore.AGENT_ATTR, "invalid agent"); attributes.put(DocumentBasedAbuseStore.CERTAINTY_ATTR, "0.0"); attributes.put(DocumentBasedAbuseStore.TIMESTAMP_ATTR, "1234"); attributes.put(DocumentBasedAbuseStore.COMMENT_ATTR, "no comment"); attributes.put(DocumentBasedAbuseStore.WANTED_ATTR, "true"); doc.createChildElement(doc.getDocumentElement(), DocumentBasedAbuseStore.WANTED_EVAL_TAG, attributes); }
/** Insert bad WantedEvaluation data. */ private static <N, E extends N, T extends N> void insertInvalidEvaluation( MutableDocument<N, E, T> doc) { Map<String, String> attributes = CollectionUtils.newHashMap(); attributes.put(DocumentBasedAbuseStore.AGENT_ATTR, "invalid agent"); attributes.put(DocumentBasedAbuseStore.CERTAINTY_ATTR, "0.0"); attributes.put(DocumentBasedAbuseStore.TIMESTAMP_ATTR, "1234"); attributes.put(DocumentBasedAbuseStore.COMMENT_ATTR, "no comment"); attributes.put(DocumentBasedAbuseStore.WANTED_ATTR, "true"); doc.createChildElement(doc.getDocumentElement(), DocumentBasedAbuseStore.WANTED_EVAL_TAG, attributes); }
/** * Appends a line to the given line container * * @param doc * @param lineContainer * @param content optional content for the new line, may be null * @param attributes optional attributes, may be null. * @return the line token representing the start of the new line */ public static <N, E extends N, T extends N> E appendLine(final MutableDocument<N, E, T> doc, E lineContainer, XmlStringBuilder content, Attributes attributes) { E line = doc.createChildElement(lineContainer, LINE_TAGNAME, attributes); if (content != null && content.getLength() > 0) { doc.insertXml(Point.<N>end(lineContainer), content); } return line; }
@Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { N rootThreadNode = doc.getFirstChild(doc.getDocumentElement()); E rootThread = doc.asElement(rootThreadNode); doc.createChildElement(rootThread, "blip", Collections.singletonMap( "id", idGenerator.newBlipId())); } });
@Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { N rootThreadNode = doc.getFirstChild(doc.getDocumentElement()); E rootThread = doc.asElement(rootThreadNode); doc.createChildElement(rootThread, "blip", Collections.singletonMap( "id", idGenerator.newBlipId())); } });
public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { E anchor = Point.elementAfter(doc, doc.locate(location)); E anchorParent = doc.getParentElement(anchor); doc.createChildElement(anchorParent, doc.getTagName(anchor), doc.getAttributes(anchor)); } });
public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { E anchor = Point.elementAfter(doc, doc.locate(location)); E anchorParent = doc.getParentElement(anchor); doc.createChildElement(anchorParent, doc.getTagName(anchor), doc.getAttributes(anchor)); } });
public void testCorrectBoundaryPoint() { // immitate the structore of line containers with a local paragraph TestDocumentContext<Node, Element, Text> cxt = createAnnotationContext(); MutableDocument<Node, Element, Text> doc = cxt.document(); Element lc = doc.createChildElement(doc.getDocumentElement(), "body", Attributes.EMPTY_MAP); Element l = doc.createChildElement(lc, "line", Attributes.EMPTY_MAP); Element label = doc.createChildElement(lc, "label", Attributes.EMPTY_MAP); doc.insertText(Point.end((Node)label), "test"); // set up local content, moving the label into it Element local = cxt.annotatableContent().transparentCreate( "l:l", Attributes.EMPTY_MAP, lc, null); PersistentContent.makeHard(cxt.annotatableContent(), local); cxt.annotatableContent().transparentMove(local, l.getNextSibling(), local, null); try { doc.setAnnotation(3, 9, "a", "1"); timerService.tick(100); } catch (Exception e) { fail("Annotation painting threw exception - " + e.getMessage()); } }
public void testCorrectBoundaryPoint() { // immitate the structore of line containers with a local paragraph TestDocumentContext<Node, Element, Text> cxt = createAnnotationContext(); MutableDocument<Node, Element, Text> doc = cxt.document(); Element lc = doc.createChildElement(doc.getDocumentElement(), "body", Attributes.EMPTY_MAP); Element l = doc.createChildElement(lc, "line", Attributes.EMPTY_MAP); Element label = doc.createChildElement(lc, "label", Attributes.EMPTY_MAP); doc.insertText(Point.end((Node)label), "test"); // set up local content, moving the label into it Element local = cxt.annotatableContent().transparentCreate( "l:l", Attributes.EMPTY_MAP, lc, null); PersistentContent.makeHard(cxt.annotatableContent(), local); cxt.annotatableContent().transparentMove(local, l.getNextSibling(), local, null); try { doc.setAnnotation(3, 9, "a", "1"); timerService.tick(100); } catch (Exception e) { fail("Annotation painting threw exception - " + e.getMessage()); } }
public void testNodeAtEnd() { TestDocumentContext<Node, Element, Text> cxt = createAnnotationContext(); MutableDocument<Node, Element, Text> doc = cxt.document(); Element e = doc.createChildElement(doc.getDocumentElement(), "p", Attributes.EMPTY_MAP); doc.insertText(Point.<Node>inElement(e, null), "Hi"); doc.setAnnotation(3, 4, "x", "1"); timerService.tick(100); ReadableDocument<Node, Element, Text> fullDoc = cxt.getFullRawDoc(); Element boundary = fullDoc.asElement(fullDoc.getLastChild(e)); assertNotNull(boundary); assertEquals("l:b", boundary.getTagName()); doc.setAnnotation(3, 4, "x", null); timerService.tick(100); boundary = fullDoc.asElement(fullDoc.getLastChild(e)); assertNull(boundary); }
public void testNodeAtEnd() { TestDocumentContext<Node, Element, Text> cxt = createAnnotationContext(); MutableDocument<Node, Element, Text> doc = cxt.document(); Element e = doc.createChildElement(doc.getDocumentElement(), "p", Attributes.EMPTY_MAP); doc.insertText(Point.<Node>inElement(e, null), "Hi"); doc.setAnnotation(3, 4, "x", "1"); timerService.tick(100); ReadableDocument<Node, Element, Text> fullDoc = cxt.getFullRawDoc(); Element boundary = fullDoc.asElement(fullDoc.getLastChild(e)); assertNotNull(boundary); assertEquals("l:b", boundary.getTagName()); doc.setAnnotation(3, 4, "x", null); timerService.tick(100); boundary = fullDoc.asElement(fullDoc.getLastChild(e)); assertNull(boundary); }
/** Tests bug 1839733 */ public void testNestedPaintNodes() { TestDocumentContext<Node, Element, Text> cxt = createAnnotationContext(); MutableDocument<Node, Element, Text> doc = cxt.document(); Element e = doc.createChildElement(doc.getDocumentElement(), "p", Attributes.EMPTY_MAP); doc.insertText(doc.locate(1), "A"); doc.insertText(doc.locate(2), "B"); doc.setAnnotation(2, 3, "a", "1"); timerService.tick(100); checkXml("<p>A<l:p a=\"1\">B</l:p></p>", XmlStringBuilder.innerXml(cxt.getFullRawDoc())); doc.insertText(doc.locate(3), "C"); doc.setAnnotation(3, 4, "b", "2"); timerService.tick(100); checkXml("<p>A<l:p a=\"1\">B</l:p><l:p a=\"1\" b=\"2\">C</l:p></p>", XmlStringBuilder.innerXml(cxt.getFullRawDoc())); doc.insertText(doc.locate(4), "D"); doc.setAnnotation(4, 5, "a", null); timerService.tick(100); checkXml("<p>A<l:p a=\"1\">B</l:p><l:p a=\"1\" b=\"2\">C</l:p><l:p b=\"2\">D</l:p></p>", XmlStringBuilder.innerXml(cxt.getFullRawDoc())); doc.insertText(doc.locate(5), "E"); doc.setAnnotation(5, 6, "b", null); timerService.tick(100); checkXml("<p>A<l:p a=\"1\">B</l:p><l:p a=\"1\" b=\"2\">C</l:p><l:p b=\"2\">D</l:p>E</p>", XmlStringBuilder.innerXml(cxt.getFullRawDoc())); }
/** Tests bug 1839733 */ public void testNestedPaintNodes() { TestDocumentContext<Node, Element, Text> cxt = createAnnotationContext(); MutableDocument<Node, Element, Text> doc = cxt.document(); Element e = doc.createChildElement(doc.getDocumentElement(), "p", Attributes.EMPTY_MAP); doc.insertText(doc.locate(1), "A"); doc.insertText(doc.locate(2), "B"); doc.setAnnotation(2, 3, "a", "1"); timerService.tick(100); checkXml("<p>A<l:p a=\"1\">B</l:p></p>", XmlStringBuilder.innerXml(cxt.getFullRawDoc())); doc.insertText(doc.locate(3), "C"); doc.setAnnotation(3, 4, "b", "2"); timerService.tick(100); checkXml("<p>A<l:p a=\"1\">B</l:p><l:p a=\"1\" b=\"2\">C</l:p></p>", XmlStringBuilder.innerXml(cxt.getFullRawDoc())); doc.insertText(doc.locate(4), "D"); doc.setAnnotation(4, 5, "a", null); timerService.tick(100); checkXml("<p>A<l:p a=\"1\">B</l:p><l:p a=\"1\" b=\"2\">C</l:p><l:p b=\"2\">D</l:p></p>", XmlStringBuilder.innerXml(cxt.getFullRawDoc())); doc.insertText(doc.locate(5), "E"); doc.setAnnotation(5, 6, "b", null); timerService.tick(100); checkXml("<p>A<l:p a=\"1\">B</l:p><l:p a=\"1\" b=\"2\">C</l:p><l:p b=\"2\">D</l:p>E</p>", XmlStringBuilder.innerXml(cxt.getFullRawDoc())); }