Examples of DocOpBuilder


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

  private static DocOp element(String tag) {
    return new DocOpBuilder().elementStart(tag, Attributes.EMPTY_MAP).elementEnd().build();
  }

  private static DocOp characters(String text, int location, int trail) {
    return new DocOpBuilder().retain(location).characters(text).retain(trail).build();
  }
View Full Code Here

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

    assertEquals(new FocusedRange(6), selectionHelper.getSelectionRange());
    assertEquals("<doc>aaahello</doc>", XmlStringBuilder.innerXml(doc).toString());
  }

  private void insert(int location, int size) {
    DocOp op = new DocOpBuilder()
        .retain(location)
        .characters("a")
        .retain(size - location)
        .build();
    silentOperationSink.consume(op);
View Full Code Here

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

        "a", "b", null);
    IndexedDocumentImpl<Node, Element, Text, ?> doc =
        new IndexedDocumentImpl<Node, Element, Text, Void>(
            RawDocumentImpl.PROVIDER.parse("<doc><p></p></doc>"), annotations,
            DocumentSchema.NO_SCHEMA_CONSTRAINTS);
    doc.consume(new DocOpBuilder().annotationBoundary(
        new AnnotationBoundaryMapBuilder().change("a", null, "0").build())
        .characters(b.toString()).retain(2)
        .annotationBoundary(new AnnotationBoundaryMapBuilder().end("a").build()).build());

    long startTime = System.currentTimeMillis();
    final int reps = 10000;
    for (int i = 0; i < reps; i++) {
      assertTrue(
          // The test is that this doesn't time out.
          DocOpValidator.validate(null, DocumentSchema.NO_SCHEMA_CONSTRAINTS,
              Automatons.fromReadable(doc),
              new DocOpBuilder().annotationBoundary(
                  new AnnotationBoundaryMapBuilder().change("a", "0", "1").build())
                  .retain(length + 2)
                  .annotationBoundary(new AnnotationBoundaryMapBuilder().end("a").build()).build())
                  .isValid());
    }
View Full Code Here

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

  public DocInitialization toInitialization() {
    return asOperation();
  }

  private DocOp serializeDom() {
    DocOpBuilder b = new DocOpBuilder();
    int depth = 0;
    for (N node : offsetList) {
      if (node != null) {
        T textNode = substrate.asText(node);
        if (textNode != null) {
          b.characters(substrate.getData(textNode));
        } else {
          E elementNode = substrate.asElement(node);
          b.elementStart(substrate.getTagName(elementNode),
              new AttributesImpl(substrate.getAttributes(elementNode)));
          depth++;
        }
      } else {
        // To avoid the sentinel
        depth--;
        if (depth >= 0) {
          b.elementEnd();
        }
      }
    }

    DocOp domOp = b.buildUnchecked();
    assert DocOpValidator.isWellFormed(null, domOp);
    return domOp;
  }
View Full Code Here

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

    }
  }

  public void testOperationsOfDifferentSizes() throws Exception {
    String docId = "b+somedoc";
    DocOp docOp1 = new DocOpBuilder().characters("hi").build();
    WaveletDelta delta1 = createDelta(docId, docOp1, localVersion0);

    WaveServerTestUtil.applyDeltaToWavelet(localWavelet, delta1, 0L);
    try {
      DocOp docOp2 = new DocOpBuilder().characters("bye").build();
      WaveletDelta delta2 = createDelta(docId, docOp2, localWavelet.getCurrentVersion());

      WaveServerTestUtil.applyDeltaToWavelet(localWavelet, delta2, 0L);
      fail("Composition of \"hi\" and \"bye\" did not throw OperationException");
    } catch (OperationException expected) {
View Full Code Here

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

   * @param size The size of the document on which this operation should apply.
   * @param location The location at which the insert the fragment.
   * @return The operation.
   */
  private static DocOp structuralSample1(int size, int location) {
    return new DocOpBuilder()
        .retain(location)
        .characters("12")
        .elementStart("u", Attributes.EMPTY_MAP)
        .characters("34")
        .elementEnd()
View Full Code Here

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

   * @param size The size of the document on which this operation should apply.
   * @param location The location at which the insert the fragment.
   * @return The operation.
   */
  private static DocOp structuralSample2(int size, int location) {
    return new DocOpBuilder()
        .retain(location)
        .characters("12")
        .elementStart("u", Attributes.EMPTY_MAP)
        .characters("3")
        .elementStart("i", Attributes.EMPTY_MAP)
View Full Code Here

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

   * @param size The size of the document on which this operation should apply.
   * @param location The location at which the insert the fragment.
   * @return The operation.
   */
  private static DocOp structuralSample3(int size, int location) {
    return new DocOpBuilder()
        .retain(location)
        .characters("12")
        .elementStart("u", Attributes.EMPTY_MAP)
        .characters("3")
        .elementStart("i", Attributes.EMPTY_MAP)
View Full Code Here

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

   * @param size The size of the document on which this operation should apply.
   * @param location The location at which the insert the fragment.
   * @return The operation.
   */
  private static DocOp structuralSample4(int size, int location) {
    return new DocOpBuilder()
        .retain(location)
        .elementStart("i", Attributes.EMPTY_MAP)
        .characters("hello")
        .elementEnd()
        .elementStart("b", Attributes.EMPTY_MAP)
View Full Code Here

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

   * @param size The size of the document on which this operation should apply.
   * @param location The location at which the insert the fragment.
   * @return The operation.
   */
  private static DocOp structuralSample5(int size, int location) {
    return new DocOpBuilder()
        .retain(location)
        .elementStart("a", new AttributesImpl("href", "http://www.google.com/"))
        .characters("google")
        .elementEnd()
        .retain(size - location)
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.