/** * Constructor. * * @param blip the blip to iterate. * @param start the start index of the range to iterate. * @param end the end index of the range to iterate. */ public SingleshotIterator(Blip blip, int start, int end) { super(blip, null, 1, end - start); int length = blip.getContent().length(); this.start = start; }
@Override protected int getNextIndex() { return blip.getContent().indexOf(target, position + 1); } }
/** * Appends a message followed by a new line to the end of the blip. * * @param blip the blip. * @param msg the message. */ public static void appendLine(Blip blip, String msg) { blip.at(blip.getContent().length()).insert(msg + "\n"); }
/** * Constructs an instance representing the entire blip content. * * @param blip the blip to represent. * @return an instance of blip references. */ public static BlipContentRefs all(Blip blip) { return new BlipContentRefs(blip, new BlipIterator.SingleshotIterator(blip, 0, blip.getContent().length())); }
public void testSetTitle() throws Exception { when(rootBlip.getContent()).thenReturn("\nOld title\n\nContent"); wavelet.setTitle("New title"); verify(opQueue).setTitleOfWavelet(wavelet, "New title"); verify(rootBlip).setContent("\nNew title\n\nContent"); }
public void testSetTitleAdjustRootBlipWithOneLineProperly() throws Exception { when(rootBlip.getContent()).thenReturn("\nOld title"); wavelet.setTitle("New title"); verify(opQueue).setTitleOfWavelet(wavelet, "New title"); verify(rootBlip).setContent("\nNew title\n"); }
public void testSetTitleAdjustEmptyRootBlipProperly() throws Exception { when(rootBlip.getContent()).thenReturn("\n"); wavelet.setTitle("New title"); verify(opQueue).setTitleOfWavelet(wavelet, "New title"); verify(rootBlip).setContent("\nNew title\n"); }
public void testSetTitleAdjustEmptyRootBlipProperly() throws Exception { when(rootBlip.getContent()).thenReturn("\n"); wavelet.setTitle("New title"); verify(opQueue).setTitleOfWavelet(wavelet, "New title"); verify(rootBlip).setContent("\nNew title\n"); }
public void testBlipOperations() throws Exception { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); assertEquals(1, wavelet.getBlips().size()); Blip other = blip.reply(); other.append("hello world"); assertEquals("\nhello world", other.getContent()); assertEquals(2, wavelet.getBlips().size()); Blip inline = blip.insertInlineBlip(3); assertEquals("\n", inline.getContent()); assertEquals(3, wavelet.getBlips().size()); }
public void testDocumentModify() throws Exception { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); blip.all().replace("a text with text and then some text"); assertEquals("\na text with text and then some text", blip.getContent()); blip.at(8).insert("text "); blip.all("text").replace("foo", "bar"); assertEquals("\na foo bar with foo and then some bar", blip.getContent()); }
public void testDocumentModify() throws Exception { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); blip.all().replace("a text with text and then some text"); assertEquals("\na text with text and then some text", blip.getContent()); blip.at(8).insert("text "); blip.all("text").replace("foo", "bar"); assertEquals("\na foo bar with foo and then some bar", blip.getContent()); }
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()); }
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 testInlineBlip() throws Exception { Blip blip = newBlip("\n1234", Collections.<Annotation>emptyList()); assertEquals(-1, blip.getInlineBlipOffset()); Blip inlineBlip = blip.insertInlineBlip(3); assertTrue(blip.getChildBlipIds().contains(inlineBlip.getBlipId())); assertEquals(3, inlineBlip.getInlineBlipOffset()); assertEquals("\n12 34", blip.getContent()); assertEquals(ElementType.INLINE_BLIP, blip.getElements().get(3).getType()); }
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()); }