Package com.google.walkaround.proto.ProtocolDocumentOperation

Examples of com.google.walkaround.proto.ProtocolDocumentOperation.Component


    docOp.apply(new DocOpCursor() {

      @Override
      public void retain(int itemCount) {
        Component component = MessageFactoryHelper.createDocumentOperationComponent();
        component.setRetainItemCount(itemCount);
        mutation.addComponent(component);
      }

      @Override
      public void characters(String characters) {
        Component component = MessageFactoryHelper.createDocumentOperationComponent();
        component.setCharacters(characters);
        mutation.addComponent(component);
      }

      @Override
      public void elementStart(String type, Attributes attributes) {
        Component component = MessageFactoryHelper.createDocumentOperationComponent();
        component.setElementStart(createElementStart(type, attributes));
        mutation.addComponent(component);
      }

      @Override
      public void elementEnd() {
        Component component = MessageFactoryHelper.createDocumentOperationComponent();
        component.setElementEnd(true);
        mutation.addComponent(component);
      }

      @Override
      public void deleteCharacters(String characters) {
        Component component = MessageFactoryHelper.createDocumentOperationComponent();
        component.setDeleteCharacters(characters);
        mutation.addComponent(component);
      }

      @Override
      public void deleteElementStart(String type, Attributes attributes) {
        Component component = MessageFactoryHelper.createDocumentOperationComponent();
        component.setDeleteElementStart(createElementStart(type, attributes));
        mutation.addComponent(component);
      }

      @Override
      public void deleteElementEnd() {
        Component component = MessageFactoryHelper.createDocumentOperationComponent();
        component.setDeleteElementEnd(true);
        mutation.addComponent(component);
      }

      @Override
      public void replaceAttributes(Attributes oldAttributes, Attributes newAttributes) {
        Component component =
            MessageFactoryHelper.createDocumentOperationComponent();
        ReplaceAttributes replace =
            MessageFactoryHelper.createDocumentReplaceAttributes();
        if (oldAttributes.isEmpty() && newAttributes.isEmpty()) {
          replace.setEmpty(true);
        } else {
          for (Map.Entry<String, String> e : oldAttributes.entrySet()) {
            replace.addOldAttribute(createKeyValuePair(e.getKey(), e.getValue()));
          }
          for (Map.Entry<String, String> e : newAttributes.entrySet()) {
            replace.addNewAttribute(createKeyValuePair(e.getKey(), e.getValue()));
          }
        }
        component.setReplaceAttributes(replace);
        mutation.addComponent(component);
      }

      @Override
      public void updateAttributes(AttributesUpdate update) {
        Component component = MessageFactoryHelper.createDocumentOperationComponent();
        UpdateAttributes updateAttributes =
            MessageFactoryHelper.createDocumentUpdateAttributes();
        int n = update.changeSize();
        if (n == 0) {
          updateAttributes.setEmpty(true);
        } else {
          for (int i = 0; i < n; i++) {
          updateAttributes.addAttributeUpdate(createKeyValueUpdate(
              update.getChangeKey(i), update.getOldValue(i), update.getNewValue(i)));
          }
        }
        component.setUpdateAttributes(updateAttributes);
        mutation.addComponent(component);
      }

      @Override
      public void annotationBoundary(AnnotationBoundaryMap map) {
        Component component = MessageFactoryHelper.createDocumentOperationComponent();
        AnnotationBoundary boundary =
            MessageFactoryHelper.createDocumentAnnotationBoundary();
        int endSize = map.endSize();
        int changeSize = map.changeSize();
        if (endSize == 0 && changeSize == 0) {
          boundary.setEmpty(true);
        } else {
          for (int i = 0; i < endSize; i++) {
            boundary.addEnd(map.getEndKey(i));
          }
          for (int i = 0; i < changeSize; i++) {
            boundary.addChange(createKeyValueUpdate(map.getChangeKey(i),
                map.getOldValue(i), map.getNewValue(i)));
          }
        }
        component.setAnnotationBoundary(boundary);
        mutation.addComponent(component);
      }
    });
    return mutation;
  }
View Full Code Here


    this.checkAttributes = checkAttributes;
  }

  @Override
  public void applyComponent(int i, DocOpCursor cursor) {
    Component component = provider.getContent().getComponent(i);
    applyComponent(cursor, component);
  }
View Full Code Here

    applyComponent(cursor, component);
  }

  @Override
  public AnnotationBoundaryMap getAnnotationBoundary(int i) {
    Component component = provider.getContent().getComponent(i);
    return annotationBoundaryFrom(component.getAnnotationBoundary());
  }
View Full Code Here

    return annotationBoundaryFrom(component.getAnnotationBoundary());
  }

  @Override
  public String getCharactersString(int i) {
    Component component = provider.getContent().getComponent(i);
    return component.getCharacters();
  }
View Full Code Here

    return component.getCharacters();
  }

  @Override
  public String getDeleteCharactersString(int i) {
    Component component = provider.getContent().getComponent(i);
    return component.getDeleteCharacters();
  }
View Full Code Here

    return component.getDeleteCharacters();
  }

  @Override
  public Attributes getDeleteElementStartAttributes(int i) {
    Component component = provider.getContent().getComponent(i);
    ElementStart elementStart = component.getDeleteElementStart();
    return attributesFrom(elementStart);
  }
View Full Code Here

    return attributesFrom(elementStart);
  }

  @Override
  public String getDeleteElementStartTag(int i) {
    Component component = provider.getContent().getComponent(i);
    ElementStart elementStart = component.getDeleteElementStart();
    return elementStart.getType();
  }
View Full Code Here

    return elementStart.getType();
  }

  @Override
  public Attributes getElementStartAttributes(int i) {
    Component component = provider.getContent().getComponent(i);
    ElementStart elementStart = component.getElementStart();
    return attributesFrom(elementStart);
  }
View Full Code Here

    return attributesFrom(elementStart);
  }

  @Override
  public String getElementStartTag(int i) {
    Component component = provider.getContent().getComponent(i);
    ElementStart elementStart = component.getElementStart();
    return elementStart.getType();
  }
View Full Code Here

    return elementStart.getType();
  }

  @Override
  public Attributes getReplaceAttributesNewAttributes(int i) {
    Component component = provider.getContent().getComponent(i);
    ReplaceAttributes r = component.getReplaceAttributes();
    return newAttributesFrom(r);
  }
View Full Code Here

TOP

Related Classes of com.google.walkaround.proto.ProtocolDocumentOperation.Component

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.