/** * Inserts computed contents just after the matched positions. * * @param functions the functions to compute the new contents based on the * matched contents. * @return an instance of this blip references, for chaining. */ public BlipContentRefs insertAfter(BlipContentFunction... functions) { return insertAfter(null, functions); }
/** * Inserts the given arguments just after the matched positions. * * @param arguments the new contents to be inserted. * @return an instance of this blip references, for chaining. */ public BlipContentRefs insertAfter(BlipContent... arguments) { return insertAfter(null, arguments); }
/** * Inserts the given strings just after the matched positions. * * @param arguments the new strings to be inserted. * @return an instance of this blip references, for chaining. */ public BlipContentRefs insertAfter(String... arguments) { return insertAfter(null, arguments); }
/** * Appends the given argument (element, text, or markup) to the blip. * * @param argument the element, text, or markup to be appended. * @return an instance of {@link BlipContentRefs}. */ public BlipContentRefs append(BlipContent argument) { return BlipContentRefs.all(this).insertAfter(argument); }
/** * Appends the given string to the blip. * * @param argument the string to be appended. * @return an instance of {@link BlipContentRefs}. */ public BlipContentRefs append(String argument) { return BlipContentRefs.all(this).insertAfter(argument); }
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("\n some piece of text.", blip.getContent()); assertEquals(url, ((Image) blip.first(ElementType.IMAGE).value()).getUrl()); blip.first(ElementType.IMAGE).insertAfter(new BlipContentFunction() { @Override public BlipContent call(BlipContent source) {
assertEquals("\n some piece of text.", blip.getContent()); assertEquals(url, ((Image) blip.first(ElementType.IMAGE).value()).getUrl()); blip.first(ElementType.IMAGE).insertAfter(new BlipContentFunction() { @Override public BlipContent call(BlipContent source) {