Examples of OpCursorException


Examples of org.waveprotocol.wave.model.operation.OpCursorException

    }
  }

  private void checkRetain(int count) {
    if (currentLocation + count > size()) {
      throw new OpCursorException("Retain past end of document [location:" +
          (currentLocation + count) + "] [doc size:" + size() + "]");
    }
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.OpCursorException

          substrate.removeAttribute(node, key);
        }
      }
      for (Map.Entry<String, String> attribute : newAttrs.entrySet()) {
        if (attribute.getValue() == null) {
          throw new OpCursorException("Null attribute value in setAttributes");
        }
        substrate.setAttribute(node, attribute.getKey(), attribute.getValue());
      }
      ++currentLocation;
      currentContainer = currentContainer.getNextContainer();
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.OpCursorException

    @Override
    public void deleteElementStart(String type, Attributes attrs) {

      E nodeToDelete = substrate.asElement(currentContainer.getValue());
      if (nodeToDelete == null) {
        throw new OpCursorException("No element to delete at the current location.");
      }
      if (deletionDepth == 0) {
        substrate.removeChild(currentParent, nodeToDelete);
      }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.OpCursorException

          substrate.removeAttribute(node, attribute.getKey());
        }
      }
      for (Map.Entry<String, String> attribute : newAttrs.entrySet()) {
        if (attribute.getValue() == null) {
          throw new OpCursorException("Null attribute value in setAttributes");
        }
        substrate.setAttribute(node, attribute.getKey(), attribute.getValue());
      }

      currentLocation++;
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.OpCursorException

    }

    public void deleteElementStart() {
      E nodeToDelete = substrate.asElement(currentContainer.getValue());
      if (nodeToDelete == null) {
        throw new OpCursorException("No element to delete at the current location.");
      }
      String tagName = substrate.getTagName(nodeToDelete);
      Attributes attributes = new AttributesImpl(substrate.getAttributes(nodeToDelete));
      if (deletionDepth == 0) {
        substrate.removeChild(currentParent, nodeToDelete);
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.OpCursorException

  }

  @Override
  public void skip(int skipSize) {
    if (skipSize > size() - currentLocation) {
      throw new OpCursorException("attempt to skip beyond end of document (cursor at "
          + currentLocation + ", size is " + size() + ", distance is " + skipSize + ")");
    }
    traverse(skipTraverser, skipSize);
    currentLocation += skipSize;
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.OpCursorException

  }

  @Override
  public void delete(int deleteSize) {
    if (deleteSize > size() - currentLocation) {
      throw new OpCursorException("attempt to delete beyond end of document (cursor at "
          + currentLocation + ", size is " + size() + ", deleteSize is " + deleteSize + ")");
    }
    traverse(deleteTraverser, deleteSize);
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.OpCursorException

  @Override
  public void skip(int distance) {
    assert cursor != -1;
    assert distance > 0;
    if (distance > size() - cursor) {
      throw new OpCursorException("Attempt to skip beyond end of document (cursor at "
          + cursor + ", size is " + size() + ", distance is " + distance + ")");
    }

    cursor += distance;
    assert cursor > 0;
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.OpCursorException

  @Override
  public void delete(int deleteSize) {
    assert cursor != -1;
    assert deleteSize > 0;
    if (deleteSize > size() - cursor) {
      throw new OpCursorException("Attempt to delete beyond end of document (cursor at "
          + cursor + ", size is " + size() + ", deleteSize is " + deleteSize + ")");
    }

    updateInheritedAnnotationsFromPosition(cursor + deleteSize - 1);
    tree.delete(cursor, cursor + deleteSize);
View Full Code Here

Examples of org.waveprotocol.wave.model.operation.OpCursorException

        @Override
        public void deleteCharacters(String s) {
          for (int i = 0; i < s.length(); i++) {
            CharacterItem item = nextCharacter();
            if (s.charAt(i) != item.character) {
              throw new OpCursorException("Mismatched deleted characters: " +
                  s.charAt(i) + " vs " + item.character);
            }
            inherited = item.getAnnotations();
            iterator.remove();
          }
        }

        @Override
        public void deleteElementEnd() {
          ElementEndItem item = nextElementEnd();
          inherited = item.getAnnotations();
          iterator.remove();
        }

        @Override
        public void deleteElementStart(String tag, Attributes attrs) {
          ElementStartItem item = nextElementStart();
          inherited = item.getAnnotations();
          iterator.remove();
        }

        @Override
        public void retain(int distance) {
          for (int i = 0; i < distance; i++) {
            inheritAndAnnotate(next());
          }
        }

        @Override
        public void replaceAttributes(Attributes oldAttrs, Attributes newAttrs) {
          ElementStartItem item = nextElementStart();
          item.replaceAttributes(newAttrs);
          inheritAndAnnotate(item);
        }

        @Override
        public void updateAttributes(AttributesUpdate attrUpdate) {
          ElementStartItem item = nextElementStart();
          item.updateAttributes(attrUpdate);
          inheritAndAnnotate(item);
        }

        private void inheritAndAnnotate(Item item) {
          inherited = item.getAnnotations();
          item.updateAnnotations(annotationUpdates);
        }

        Item next() {
          if (!iterator.hasNext()) {
            throw new OpCursorException("Action past end of document, of size: " + length());
          }
          current = iterator.next();
          return current;
        }

        ElementStartItem nextElementStart() {
          try {
            return (ElementStartItem) next();
          } catch (ClassCastException e) {
            throw new OpCursorException("Not at an element start, at: " + current);
          }
        }

        ElementEndItem nextElementEnd() {
          try {
            return (ElementEndItem) next();
          } catch (ClassCastException e) {
            throw new OpCursorException("Not at an element end, at: " + current);
          }
        }

        CharacterItem nextCharacter() {
          try {
            return (CharacterItem) next();
          } catch (ClassCastException e) {
            throw new OpCursorException("Not at a character, at: " + current);
          }
        }
      });
      if (iterator.hasNext()) {
        int remainingItems = 0;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.