@Override public Annotation createInstance(Type type) { return new Annotation("", "", -1, -1); } }
/** * Annotates the contents at the matched positions. * * @param key the annotation key. * @param values the annotation values. * @return an instance of this blip references, for chaining. */ public BlipContentRefs annotate(String key, String... values) { if (values.length == 0) { values = new String[]{key}; } Annotation[] annotations = new Annotation[values.length]; for (int i = 0; i < values.length; ++i) { annotations[i] = new Annotation(key, values[i], 0, 1); } return execute(ModifyHow.ANNOTATE, null, (Object[]) annotations); }
private Blip newBlip(String blipId, List<String> childBlipIds, String parentBlipId) { return newBlip(blipId, childBlipIds, parentBlipId, Arrays.asList(new Annotation("key", "val", 2, 3))); }
private Blip newBlip(String blipId, List<String> childBlipIds, String parentBlipId) { return newBlip(blipId, childBlipIds, parentBlipId, Arrays.asList(new Annotation("key", "val", 2, 3))); }
public void testDeleteAll() { Blip blip = newBlip("\nNew title\nNew content", Arrays.asList( new Annotation("style/fontWeight", "bold", new Range(10,11)), new Annotation("conv/title", "", new Range(0,10)))); blip.all().delete(); assertEquals("\n", blip.getContent()); }
public void testDeleteAll() { Blip blip = newBlip("\nNew title\nNew content", Arrays.asList( new Annotation("style/fontWeight", "bold", new Range(10,11)), new Annotation("conv/title", "", new Range(0,10)))); blip.all().delete(); assertEquals("\n", blip.getContent()); }
public void testInsertBeforeAnnotationStartPoint() { Blip blip = newBlip("\nFoo bar.", Arrays.asList(new Annotation(ANNOTATION_KEY, "bold", 4, 9))); blip.at(4).insert("d and"); assertEquals(new Range(9, 14), blip.getAnnotations().get(ANNOTATION_KEY).get(0).getRange()); }
public void testInsertBeforeAnnotationStartPoint() { Blip blip = newBlip("\nFoo bar.", Arrays.asList(new Annotation(ANNOTATION_KEY, "bold", 4, 9))); blip.at(4).insert("d and"); assertEquals(new Range(9, 14), blip.getAnnotations().get(ANNOTATION_KEY).get(0).getRange()); }
public void testBundledAnnotations() throws Exception { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); blip.all().insert(BundledAnnotation.listOf("style", "bold"), "\nhello"); assertEquals(2, blip.getAnnotations().size()); assertEquals(new Annotation("style", "bold", 0, 6), blip.getAnnotations().get("style").get(0)); }
public void testDeleteRangeThatSpansAcrossAnnotationEndPoint() throws Exception { Blip blip = newBlip("\nFoo bar.", Arrays.asList(new Annotation(ANNOTATION_KEY, "bold", 1, 3))); // Delete "oo" blip.range(2, 4).delete(); assertEquals("\nF bar.", blip.getContent()); assertEquals(new Range(1, 2), blip.getAnnotations().get(ANNOTATION_KEY).get(0).getRange()); }
public void testReplaceSpanAnnotation() { Blip blip = newBlip("\nFoo bar.", Arrays.asList(new Annotation(ANNOTATION_KEY, "bold", 1, 4))); // Replace "oo bar." with "". blip.range(2, 9).replace(""); assertEquals("\nF", blip.getContent()); assertEquals(new Range(1, 2), blip.getAnnotations().get(ANNOTATION_KEY).get(0).getRange()); }
public void testDeleteRangeInsideAnnotation() { Blip blip = newBlip("\nFoo bar.", Arrays.asList(new Annotation(ANNOTATION_KEY, "bold", 1, 5))); // Delete "oo" blip.range(2, 4).delete(); assertEquals("\nF bar.", blip.getContent()); assertEquals(new Range(1, 3), blip.getAnnotations().get(ANNOTATION_KEY).get(0).getRange()); }
public void testDeleteRangeThatSpansAcrossAnnotationEndPoint() throws Exception { Blip blip = newBlip("\nFoo bar.", Arrays.asList(new Annotation(ANNOTATION_KEY, "bold", 1, 3))); // Delete "oo" blip.range(2, 4).delete(); assertEquals("\nF bar.", blip.getContent()); assertEquals(new Range(1, 2), blip.getAnnotations().get(ANNOTATION_KEY).get(0).getRange()); }
public void testReplaceSpanAnnotation() { Blip blip = newBlip("\nFoo bar.", Arrays.asList(new Annotation(ANNOTATION_KEY, "bold", 1, 4))); // Replace "oo bar." with "". blip.range(2, 9).replace(""); assertEquals("\nF", blip.getContent()); assertEquals(new Range(1, 2), blip.getAnnotations().get(ANNOTATION_KEY).get(0).getRange()); }
public void testBundledAnnotations() throws Exception { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); blip.all().insert(BundledAnnotation.listOf("style", "bold"), "\nhello"); assertEquals(2, blip.getAnnotations().size()); assertEquals(new Annotation("style", "bold", 0, 6), blip.getAnnotations().get("style").get(0)); }
public void testDeleteRangeInsideAnnotation() { Blip blip = newBlip("\nFoo bar.", Arrays.asList(new Annotation(ANNOTATION_KEY, "bold", 1, 5))); // Delete "oo" blip.range(2, 4).delete(); assertEquals("\nF bar.", blip.getContent()); assertEquals(new Range(1, 3), blip.getAnnotations().get(ANNOTATION_KEY).get(0).getRange()); }
public void testReplaceInsideAnnotation() { Blip blip = newBlip("\nFoo bar.", Arrays.asList(new Annotation(ANNOTATION_KEY, "bold", 1, 5))); // Replace "oo" with "ooo". blip.range(2, 4).replace("ooo"); assertEquals("\nFooo bar.", blip.getContent()); assertEquals(new Range(1, 6), blip.getAnnotations().get(ANNOTATION_KEY).get(0).getRange()); // Replace "ooo" with "o". blip.range(2, 5).replace("o"); assertEquals("\nFo bar.", blip.getContent()); assertEquals(new Range(1, 4), blip.getAnnotations().get(ANNOTATION_KEY).get(0).getRange()); }
public void testReplaceInsideAnnotation() { Blip blip = newBlip("\nFoo bar.", Arrays.asList(new Annotation(ANNOTATION_KEY, "bold", 1, 5))); // Replace "oo" with "ooo". blip.range(2, 4).replace("ooo"); assertEquals("\nFooo bar.", blip.getContent()); assertEquals(new Range(1, 6), blip.getAnnotations().get(ANNOTATION_KEY).get(0).getRange()); // Replace "ooo" with "o". blip.range(2, 5).replace("o"); assertEquals("\nFo bar.", blip.getContent()); assertEquals(new Range(1, 4), blip.getAnnotations().get(ANNOTATION_KEY).get(0).getRange()); }
public void testShift() throws Exception { Annotation annotation = new Annotation("key", "value", 5 , 10); annotation.shift(4, 2); assertEquals(7, annotation.getRange().getStart()); assertEquals(12, annotation.getRange().getEnd()); annotation = new Annotation("key", "value", 5 , 10); annotation.shift(5, 3); assertEquals(8, annotation.getRange().getStart()); assertEquals(13, annotation.getRange().getEnd()); annotation = new Annotation("key", "value", 5 , 10); annotation.shift(9, 2); assertEquals(5, annotation.getRange().getStart()); assertEquals(12, annotation.getRange().getEnd()); annotation = new Annotation("key", "value", 5 , 10); annotation.shift(10, 2); assertEquals(5, annotation.getRange().getStart()); assertEquals(12, annotation.getRange().getEnd()); } }
public void testShift() throws Exception { Annotation annotation = new Annotation("key", "value", 5 , 10); annotation.shift(4, 2); assertEquals(7, annotation.getRange().getStart()); assertEquals(12, annotation.getRange().getEnd()); annotation = new Annotation("key", "value", 5 , 10); annotation.shift(5, 3); assertEquals(8, annotation.getRange().getStart()); assertEquals(13, annotation.getRange().getEnd()); annotation = new Annotation("key", "value", 5 , 10); annotation.shift(9, 2); assertEquals(5, annotation.getRange().getStart()); assertEquals(12, annotation.getRange().getEnd()); annotation = new Annotation("key", "value", 5 , 10); annotation.shift(10, 2); assertEquals(5, annotation.getRange().getStart()); assertEquals(12, annotation.getRange().getEnd()); } }