@Override public Range createInstance(Type type) { return new Range(-1, -1); } }
@Override public Range next() { if (hitsLeft == 0) { throw new NoSuchElementException(); } int index = getNextIndex(); if (index == -1) { throw new NoSuchElementException(); } hitsLeft--; position = index; return new Range(position, position + rangeSize); }
@Override public Range next() { if (hitsLeft == 0) { return null; } hitsLeft--; String searchIn = apiView.apiContents(); int next = searchIn.indexOf(searchFor, from + 1); if (next == -1) { return null; } from = next; return new Range(from, from + searchFor.length()); }
/** * Constructor. * * @param name the name of this annotation. * @param value the value of this annotation. * @param range the range of this annotation. */ public Annotation(String name, String value, Range range) { this.name = name; this.value = value; this.range = new Range(range.getStart(), range.getEnd()); }
/** * Constructs an instance representing an explicitly set range. * * @param blip the blip to represent. * @param start the start index of the range. * @param end the end index of the range. * @return an instance of blip references. */ public static BlipContentRefs range(Blip blip, int start, int end) { return new BlipContentRefs(blip, new BlipIterator.SingleshotIterator(blip, start, end), Parameter.of(ParamsProperty.RANGE, new Range(start, end))); }
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 testSingleshot() { Range range = new Range(0, 10); DocumentHitIterator it = new DocumentHitIterator.Singleshot(range); Range first = it.next(); assertEquals(range, first); assertNull(it.next()); }
public void testSingleshot() { Range range = new Range(0, 10); DocumentHitIterator it = new DocumentHitIterator.Singleshot(range); Range first = it.next(); assertEquals(range, first); assertNull(it.next()); }
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 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 testFailOnMultipleWhereParams() throws Exception { OperationRequest operation = operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId, Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction()), Parameter.of(ParamsProperty.RANGE, new Range(0, 1)), Parameter.of(ParamsProperty.INDEX, 0)); try { service.execute(operation, helper.getContext(), ALEX); fail("Expected InvalidRequestException"); } catch (InvalidRequestException e) { // expected } }