Package org.waveprotocol.wave.model.document.operation.impl

Examples of org.waveprotocol.wave.model.document.operation.impl.DocOpBuffer


  public void testDoc1() throws OperationException {
    ModifiableDocument doc = createEmptyDocument();
    doc.consume(TEST_DOC1);
    check(TEST_DOC1_XML, doc);

    doc.consume(new DocOpBuffer() {
      {
        updateAttributes(new AttributesUpdateImpl("a", null, "2"));
        deleteCharacters("hi t");
        characters("you ");
        retain(4);
View Full Code Here


      System.out.print((testAsOperation ? "asOperation"
          : (testNindos ? "Nindo " : "DocOp ")) + ++iteration);
      long start = System.currentTimeMillis();
      if (testAsOperation) {
        for (IsDocOp d : docs) {
          d.asOperation().apply(new DocOpBuffer());
        }
      } else if (testNindos) {
        for (Nindo nindo : nindos) {
          doc.consumeAndReturnInvertible(nindo);
        }
View Full Code Here

    boolean didSomethingOtherThanDeletionSinceAnnotationBoundary = false;

    private void begin2() {
      beginChange();
      builder = new AnnotationsNormalizer<DocOp>(
          performValidation ? new DocOpBuffer() : new UncheckedDocOpBuffer());
      sizeDiffSoFar = 0;
      deletionValues.clear();
    }
View Full Code Here

public class TestOperations {

  // The test case for the message-based implementation should also use this.
  public static DocOp getBasicTestOp() {
    DocOpBuffer b = new DocOpBuffer();

    // The operation starts with characters/deleteCharacters of various lengths
    // and case, mixed with some retains and nested element start/end with
    // different mixes of attributes.
    b.characters("hello");
    b.characters("z");
    b.retain(1);
    b.deleteCharacters("ab");
    b.characters("world");
    b.retain(2);
    b.deleteCharacters("cd");
    b.elementStart("a", Attributes.EMPTY_MAP);
    b.characters("hEllo");
    b.elementStart("b", new AttributesImpl("a", "1"));
    b.characters("world");
    b.elementStart("B", new AttributesImpl("A", "1", "b", "abc12"));
    b.elementEnd();
    // A non-ASCII Unicode character.
    b.characters("\u2603");
    b.elementEnd();
    b.elementEnd();
    b.deleteElementStart("a", new AttributesImpl("a", "2", "c", ""));
    b.deleteCharacters("asdf");
    b.deleteElementEnd();

    // Now some replaceAttributes with different size and case.
    b.replaceAttributes(new AttributesImpl("a", "b"), new AttributesImpl("b", "c", "c", "d"));
    b.replaceAttributes(Attributes.EMPTY_MAP, new AttributesImpl("Aa", "aA"));
    b.replaceAttributes(new AttributesImpl("B", "A"), new AttributesImpl());
    // Try both a fresh empty AttributesImpl() instance and the preallocated
    // EMPTY_MAP.
    b.replaceAttributes(new AttributesImpl(), Attributes.EMPTY_MAP);
    // Now we add similar cases for annotation boundaries.  Since consecutive annotation
    // boundaries would make the operation ill-formed, we interleave them with further
    // updateAttributes tests.
    b.annotationBoundary(AnnotationBoundaryMapImpl.builder().build());
    b.updateAttributes(new AttributesUpdateImpl());
    b.annotationBoundary(AnnotationBoundaryMapImpl.builder()
        .updateValues("b", "XZ", "yz", "f-", null, null,
            "g-", "a", null, "k-", "b", "", "r", "", "2")
        .build());
    b.updateAttributes(new AttributesUpdateImpl("a", null, "1"));
    b.annotationBoundary(AnnotationBoundaryMapImpl.builder()
        .initializationEnd("b", "g-", "k-", "r")
        .updateValues("e", "166", null, "f-", null, null)
        .build());
    b.updateAttributes(new AttributesUpdateImpl("P", null, "", ":wq", "ZZ", null));
    b.annotationBoundary(AnnotationBoundaryMapImpl.builder()
        .initializationEnd("e", "f-")
        .build());

    return b.finish();
  }
View Full Code Here

    });
  }

  public static DocOp invert(DocOp input) {
    DocOpInverter<DocOp> inverter = new DocOpInverter<DocOp>(new DocOpBuffer());
    input.apply(inverter);
    return inverter.finish();
  }
View Full Code Here

    private int depth = 0;

    private InsertionTarget otherTarget;

    NoninsertionTarget(RelativePosition relativePosition) {
      super(OperationNormalizer.createNormalizer(new DocOpBuffer()), relativePosition);
    }
View Full Code Here

   * @throws OperationException if applying op1 followed by op2 would be invalid
   */
  public static DocOp compose(DocOp op1, DocOp op2)
      throws OperationException {
    try {
      return new Composer(new DocOpBuffer()).composeOperations(op1, op2);
    } catch (ComposeException e) {
      throw new OperationException(e.getMessage());
    }
  }
View Full Code Here

          new UpdateAttributesGenerator()
          );

    DocOp generate() {
      DocOpAutomaton a = new DocOpAutomaton(doc, DocumentSchema.NO_SCHEMA_CONSTRAINTS);
      DocOpBuffer b = new DocOpBuffer();
      generate1(a, b);
      return b.finish();
    }
View Full Code Here

    apply(cursor);
    return cursor.finish();
  }

  public static DocOp explode(DocOp op) {
    return new ExplodedDocOp(op).explodeWith(new DocOpBuffer());
  }
View Full Code Here

  private static final class InsertionTarget extends Target {

    NoninsertionTarget otherTarget;

    InsertionTarget(RelativePosition relativePosition) {
      super(new RangeNormalizer<DocOp>(new DocOpBuffer()), relativePosition);
    }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.operation.impl.DocOpBuffer

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.