Package com.google.wave.api

Examples of com.google.wave.api.Range


   */
  private void replace(OperationRequest operation, Document doc, ApiView view,
      DocumentHitIterator hitIterator, DocumentModifyAction modifyAction)
      throws InvalidRequestException {
    int valueIndex = 0;
    Range range = hitIterator.next();
    while (range != null) {
      int replaceAt = range.getStart();

      int numInserted = insertInto(operation, doc, view, replaceAt, modifyAction, valueIndex);

      // Remove the text after what was inserted (so it looks like it has been
      // replaced).
      view.delete(replaceAt + numInserted, range.getEnd() + numInserted);

      // Shift the iterator from the start of the replacement with the amount of
      // characters that have been added.
      int numRemoved = Math.min(0, range.getStart() - range.getEnd());
      hitIterator.shift(replaceAt, numInserted + numRemoved);

      valueIndex++;
      range = hitIterator.next();
    }
View Full Code Here


   * @throws InvalidRequestException if something goes wrong.
   */
  private void updateElement(OperationRequest operation, Document doc, ApiView view,
      DocumentHitIterator hitIterator, DocumentModifyAction modifyAction)
      throws InvalidRequestException {
    Range range = null;
    for (int index = 0; ((range = hitIterator.next()) != null); ++index) {
      Element element = modifyAction.getElement(index);
      if (element != null) {
        if (element.isGadget()) {
          int xmlStart = view.transformToXmlOffset(range.getStart());
          Doc.E docElem = Point.elementAfter(doc, doc.locate(xmlStart));
          updateExistingGadgetElement(doc, docElem, element);
        } else {
          // TODO (Yuri Z.) Updating other elements.
          throw new UnsupportedOperationException(
View Full Code Here

   * An instance creator that creates an empty {@link Annotation}.
   */
  private static class RangeInstanceCreator implements InstanceCreator<Range> {
    @Override
    public Range createInstance(Type type) {
      return new Range(-1, -1);
    }
View Full Code Here

      int next = searchIn.indexOf(searchFor, from + 1);
      if (next == -1) {
        return null;
      }
      from = next;
      return new Range(from, from + searchFor.length());
    }
View Full Code Here

          }
          if (!allMatched) {
            continue;
          }
          index = elementInfo.apiPosition;
          return new Range(index, index + 1);
        }
      }
      return null;
    }
View Full Code Here

    super.setUp();
    Blips.init();
  }

  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());
  }
View Full Code Here

  public void testTextMatcherWithoutShift() {
    ApiView apiView = createApiViewFromXml("1 1 1");
    DocumentHitIterator it = new DocumentHitIterator.TextMatcher(apiView, "1", -1);
    for (int i = 0; i < 3; i++) {
      Range r = it.next();
      assertEquals(i * 2 + 1, r.getStart());
      assertEquals(i * 2 + 2, r.getEnd());
    }
    assertNull(it.next());
  }
View Full Code Here

  public void testTextMatcherDeletingTheFirstChar() {
    ApiView apiView = createApiViewFromXml("1 1 1");
    DocumentHitIterator it = new DocumentHitIterator.TextMatcher(apiView, "1", -1);
    for (int i = 0; i < 3; i++) {
      Range r = it.next();
      assertEquals(i + 1, r.getStart());
      apiView.delete(1, 2);
      it.shift(1, -1);
    }
    assertNull(it.next());
  }
View Full Code Here

   */
  public void testTextMatcherShiftInsertAfter() {
    ApiView apiView = createApiViewFromXml("1 1 1");
    DocumentHitIterator it = new DocumentHitIterator.TextMatcher(apiView, "1", -1);
    for (int i = 0; i < 3; i++) {
      Range r = it.next();
      assertEquals(i * 3 + 1, r.getStart());
      apiView.insert(r.getEnd(), "1");
      it.shift(r.getEnd(), 1);
    }
    assertNull(it.next());
  }
View Full Code Here

   * An instance creator that creates an empty {@link Annotation}.
   */
  private static class RangeInstanceCreator implements InstanceCreator<Range> {
    @Override
    public Range createInstance(Type type) {
      return new Range(-1, -1);
    }
View Full Code Here

TOP

Related Classes of com.google.wave.api.Range

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.