Package com.google.wave.api

Examples of com.google.wave.api.Range


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

      int inserted = insertInto(operation, doc, view, insertAt, modifyAction, valueIndex);
      hitIterator.shift(insertAt, inserted);

      valueIndex++;
View Full Code Here


   */
  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

    List<Annotation> result = Lists.newArrayList();
    for (RangedAnnotation<String> annotation : doc.rangedAnnotations(0, doc.size(), null)) {
      if (annotation.key() != null && annotation.value() != null) {
        int start = apiView.transformToTextOffset(annotation.start());
        int end = apiView.transformToTextOffset(annotation.end());
        result.add(new Annotation(annotation.key(), annotation.value(), new Range(start, end)));
      }
    }
    return result;
  }
View Full Code Here

          }
          if (!allMatched) {
            continue;
          }
          index = elementInfo.apiPosition;
          return new Range(index, index + 1);
        }
      }
      return null;
    }
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

  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());
    }
  }
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.