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

Examples of org.waveprotocol.wave.model.document.operation.AnnotationBoundaryMapBuilder


public class WorthyChangeCheckerTest extends TestCase {

  public void testAnchorRemovalIsUnworthy1() throws OperationException {
    IndexedDocument<Node, Element, Text> d = DocProviders.POJO.build(
        new DocInitializationBuilder()
            .annotationBoundary(new AnnotationBoundaryMapBuilder().change("a", null, "b").build())
            .characters("a")
            .annotationBoundary(new AnnotationBoundaryMapBuilder().end("a").build())
            .characters("a")
            .elementStart(WorthyChangeChecker.THREAD_INLINE_ANCHOR_TAGNAME, Attributes.EMPTY_MAP)
            .elementEnd()
            .build(),
        DocumentSchema.NO_SCHEMA_CONSTRAINTS);
View Full Code Here


  // This one is still failing; fixing it is not as easy.
  public void XtestAnchorRemovalIsUnworthy2() throws OperationException {
    IndexedDocument<Node, Element, Text> d = DocProviders.POJO.build(
        new DocInitializationBuilder()
            .annotationBoundary(new AnnotationBoundaryMapBuilder().change("a", null, "b").build())
            .elementStart(WorthyChangeChecker.THREAD_INLINE_ANCHOR_TAGNAME, Attributes.EMPTY_MAP)
            .elementEnd()
            .annotationBoundary(new AnnotationBoundaryMapBuilder().end("a").build())
            .build(),
        DocumentSchema.NO_SCHEMA_CONSTRAINTS);
    DocOp op = d.consumeAndReturnInvertible(new Nindo.Builder() {
      {
        deleteElementStart();
View Full Code Here

    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());
    }
    long endTime = System.currentTimeMillis();
    long elapsed = endTime - startTime;
    System.err.println("millis per rep: " + (((float) elapsed) / reps));
View Full Code Here

        case TEXT:
          builder.characters(p.getText());
          continue;
        case PROCESSING_INSTRUCTION:
          String name = p.getProcessingInstructionName();
          AnnotationBoundaryMapBuilder anBuilder = new AnnotationBoundaryMapBuilder();
          if (PI_TARGET.equals(name)) {
            List<Pair<String, String>> parseAnnotations =
                AnnotationParser.parseAnnotations(p.getProcessingInstructionValue());
            for (Pair<String, String> ann : parseAnnotations) {
              final String key = ann.first;
              final String oldValue = null;
              final String newValue = ann.second;
              if (newValue == null) {
                anBuilder.end(key);
              } else {
                anBuilder.change(key, oldValue, newValue);
              }
            }
            builder.annotationBoundary(anBuilder.build());
          }
          continue;
      }
    }
View Full Code Here

    while (containsAnnotationKey(content, key)) {
      key += "1";
    }
    return new DocOpBuilder()
        .annotationBoundary(
            new AnnotationBoundaryMapBuilder().change(key,
                first ? null : "a",
                first ? "a" : null)
            .build())
        .retain(size)
        .annotationBoundary(new AnnotationBoundaryMapBuilder().end(key).build())
        .build();
  }
View Full Code Here

        case TEXT:
          builder.characters(p.getText());
          continue;
        case PROCESSING_INSTRUCTION:
          String name = p.getProcessingInstructionName();
          AnnotationBoundaryMapBuilder anBuilder = new AnnotationBoundaryMapBuilder();
          if (PI_TARGET.equals(name)) {
            List<Pair<String, String>> parseAnnotations =
                AnnotationParser.parseAnnotations(p.getProcessingInstructionValue());
            for (Pair<String, String> ann : parseAnnotations) {
              final String key = ann.first;
              final String oldValue = null;
              final String newValue = ann.second;
              if (newValue == null) {
                anBuilder.end(key);
              } else {
                anBuilder.change(key, oldValue, newValue);
              }
            }
            builder.annotationBoundary(anBuilder.build());
          }
          continue;
      }
    }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.operation.AnnotationBoundaryMapBuilder

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.