/** * Copies the content of the source blip into the target blip. * * @param fromBlip the source blip. * @param toBlip the target blip. */ public static void copyBlipContents(Blip fromBlip, Blip toBlip) { for (BlipContent blipContent: fromBlip.all().values()) { toBlip.append(blipContent); } for (Annotation annotation : fromBlip.getAnnotations()) { Range range = annotation.getRange(); toBlip.range(range.getStart() + 1, range.getEnd() + 1).annotate(annotation.getName(), annotation.getValue()); } }
public void testDocumentOperations() throws Exception { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); List<BlipContent> newLines = blip.all("\n").values(); assertEquals(2, newLines.size()); assertEquals(Arrays.asList(Plaintext.of("\n"), Plaintext.of("\n")), newLines); blip.first("world").replace("jupiter"); String[] bits = blip.getContent().split("\n"); assertEquals(3, bits.length); assertEquals("hello jupiter!", bits[1]); blip.range(2, 5).delete(); assertTrue(blip.getContent().startsWith("\nho jupiter!")); blip.first("ho").insertAfter("la"); assertTrue(blip.getContent().startsWith("\nhola jupiter!")); blip.at(3).insert(" "); assertTrue(blip.getContent().startsWith("\nho la jupiter!")); blip.all().delete(); blip.at(1).insert("world!"); blip.first("world").insert(new BlipContentFunction() { @Override public BlipContent call(BlipContent source) { return Plaintext.of("Hello " + source.getText().length() + " "); } }); assertEquals("\nHello 5 world!", blip.getContent()); }
public void testDocumentOperations() throws Exception { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); List<BlipContent> newLines = blip.all("\n").values(); assertEquals(2, newLines.size()); assertEquals(Arrays.asList(Plaintext.of("\n"), Plaintext.of("\n")), newLines); blip.first("world").replace("jupiter"); String[] bits = blip.getContent().split("\n"); assertEquals(3, bits.length); assertEquals("hello jupiter!", bits[1]); blip.range(2, 5).delete(); assertTrue(blip.getContent().startsWith("\nho jupiter!")); blip.first("ho").insertAfter("la"); assertTrue(blip.getContent().startsWith("\nhola jupiter!")); blip.at(3).insert(" "); assertTrue(blip.getContent().startsWith("\nho la jupiter!")); blip.all().delete(); blip.at(1).insert("world!"); blip.first("world").insert(new BlipContentFunction() { @Override public BlipContent call(BlipContent source) { return Plaintext.of("Hello " + source.getText().length() + " "); } }); assertEquals("\nHello 5 world!", blip.getContent()); }
assertEquals(2, blip.getElements().size()); List<BlipContent> result = blip.all(ElementType.IMAGE, Image.restrictByUrl(url)).values(); assertEquals(1, result.size());
assertEquals(2, blip.getElements().size()); List<BlipContent> result = blip.all(ElementType.IMAGE, Image.restrictByUrl(url)).values(); assertEquals(1, result.size());