/** * Return true if the given blip is a blip in which Echoey has written. */ private boolean isShadowBlip(Blip blip) { List<Annotation> annotations = blip.getAnnotations().get(ECHOEY_ANNOTATION); return annotations != null && !annotations.isEmpty(); } }
/** * Updates the shadow map for a given wavelet. */ private void updateShadowMap(Wavelet wavelet) { for (Blip blip : wavelet.getBlips().values()) { if (isShadowBlip(blip)) { String shadowBlipId = blip.getBlipId(); if (!shadowBlipMap.containsValue(shadowBlipId)) { String originalBlipId = blip.getAnnotations().get(ECHOEY_ANNOTATION).get(0).getValue(); shadowBlipMap.put(originalBlipId, shadowBlipId); } } } }
public void testAdd() throws Exception { Annotations annotations = new Annotations(); annotations.add("name", "value", 3, 5); assertEquals(1, annotations.get("name").size()); annotations.add("name", "value", 1, 2); annotations.add("name", "value", 10, 15); assertEquals(3, annotations.get("name").size()); annotations.add("name", "value", 4, 7); assertEquals(3, annotations.get("name").size()); assertEquals(new Range(3, 7), annotations.get("name").get(2).getRange()); annotations.add("name", "value2", 6, 7); assertEquals(4, annotations.get("name").size()); assertEquals(new Range(3, 6), annotations.get("name").get(2).getRange()); assertEquals("value", annotations.get("name").get(2).getValue()); assertEquals(new Range(6, 7), annotations.get("name").get(3).getRange()); assertEquals("value2", annotations.get("name").get(3).getValue()); }
public void testAdd() throws Exception { Annotations annotations = new Annotations(); annotations.add("name", "value", 3, 5); assertEquals(1, annotations.get("name").size()); annotations.add("name", "value", 1, 2); annotations.add("name", "value", 10, 15); assertEquals(3, annotations.get("name").size()); annotations.add("name", "value", 4, 7); assertEquals(3, annotations.get("name").size()); assertEquals(new Range(3, 7), annotations.get("name").get(2).getRange()); annotations.add("name", "value2", 6, 7); assertEquals(4, annotations.get("name").size()); assertEquals(new Range(3, 6), annotations.get("name").get(2).getRange()); assertEquals("value", annotations.get("name").get(2).getValue()); assertEquals(new Range(6, 7), annotations.get("name").get(3).getRange()); assertEquals("value2", annotations.get("name").get(3).getValue()); }
public void testDelete() throws Exception { Annotations annotations = new Annotations(); annotations.add("name", "value", 1, 2); annotations.add("name2", "value", 3, 5); annotations.add("name2", "value", 10, 15); annotations.delete("name", 2, 3); assertEquals(1, annotations.get("name").size()); annotations.delete("name", 1, 2); assertNull(annotations.get("name")); annotations.delete("name2", 1, 6); assertEquals(1, annotations.get("name2").size()); annotations.delete("name2", 10, 12); assertEquals(1, annotations.get("name2").size()); assertEquals(new Range(12, 15), annotations.get("name2").get(0).getRange()); }
public void testDelete() throws Exception { Annotations annotations = new Annotations(); annotations.add("name", "value", 1, 2); annotations.add("name2", "value", 3, 5); annotations.add("name2", "value", 10, 15); annotations.delete("name", 2, 3); assertEquals(1, annotations.get("name").size()); annotations.delete("name", 1, 2); assertNull(annotations.get("name")); annotations.delete("name2", 1, 6); assertEquals(1, annotations.get("name2").size()); annotations.delete("name2", 10, 12); assertEquals(1, annotations.get("name2").size()); assertEquals(new Range(12, 15), annotations.get("name2").get(0).getRange()); }
public void testShift() throws Exception { Annotations annotations = new Annotations(); annotations.add("name", "value", 1, 3); annotations.add("name2", "value", 3, 5); annotations.add("name2", "value", 10, 15); annotations.shift(2, 3); assertEquals(new Range(1, 6), annotations.get("name").get(0).getRange()); assertEquals(new Range(6, 8), annotations.get("name2").get(0).getRange()); assertEquals(new Range(13, 18), annotations.get("name2").get(1).getRange()); annotations = new Annotations(); annotations.add("name", "value", 1, 3); annotations.add("name", "value", 5, 8); annotations.shift(5, -2); assertEquals(1, annotations.get("name").size()); assertEquals(new Range(1, 6), annotations.get("name").get(0).getRange()); } }
public void testShift() throws Exception { Annotations annotations = new Annotations(); annotations.add("name", "value", 1, 3); annotations.add("name2", "value", 3, 5); annotations.add("name2", "value", 10, 15); annotations.shift(2, 3); assertEquals(new Range(1, 6), annotations.get("name").get(0).getRange()); assertEquals(new Range(6, 8), annotations.get("name2").get(0).getRange()); assertEquals(new Range(13, 18), annotations.get("name2").get(1).getRange()); annotations = new Annotations(); annotations.add("name", "value", 1, 3); annotations.add("name", "value", 5, 8); annotations.shift(5, -2); assertEquals(1, annotations.get("name").size()); assertEquals(new Range(1, 6), annotations.get("name").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 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 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 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 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()); }