Examples of DocOpAutomaton


Examples of org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton

            AnnotationBoundaryMapImpl map = AnnotationBoundaryMapImpl.builder()
                .initializationEnd(toArray(keysToEnd))
                .updateValues(toArray(changeKeys), toArray(changeOldValues),
                    toArray(changeNewValues)).build();
            final RandomizerOperationComponent component = generate(map);
            DocOpAutomaton temp = new DocOpAutomaton(a);
            ViolationCollector v = new ViolationCollector();
            component.check(temp, v);
            assert !component.check(temp, null).isIllFormed();
            component.apply(temp);
//            System.err.println("begin lookahead for " + map);
View Full Code Here

Examples of org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton

          new ReplaceAttributesGenerator(),
          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

Examples of org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton

      AutomatonDocument doc, DocOp op) {

    if (schema == null) {
      schema = DocumentSchema.NO_SCHEMA_CONSTRAINTS;
    }
    final DocOpAutomaton a = new DocOpAutomaton(doc, schema);
    final ValidationResult[] accu = new ValidationResult[] { ValidationResult.VALID };
    try {
      op.apply(new DocOpCursor() {
        void abortIfIllFormed() {
          if (accu[0].isIllFormed()) {
            throw ILL_FORMED;
          }
        }

        @Override
        public void characters(String s) {
          accu[0] = accu[0].mergeWith(a.checkCharacters(s, v));
          abortIfIllFormed();
          a.doCharacters(s);
        }

        @Override
        public void deleteCharacters(String chars) {
          accu[0] = accu[0].mergeWith(a.checkDeleteCharacters(chars, v));
          abortIfIllFormed();
          a.doDeleteCharacters(chars);
        }

        @Override
        public void deleteElementEnd() {
          accu[0] = accu[0].mergeWith(a.checkDeleteElementEnd(v));
          abortIfIllFormed();
          a.doDeleteElementEnd();
        }

        @Override
        public void deleteElementStart(String type, Attributes attrs) {
          accu[0] = accu[0].mergeWith(a.checkDeleteElementStart(type, attrs, v));
          abortIfIllFormed();
          a.doDeleteElementStart(type, attrs);
        }

        @Override
        public void replaceAttributes(Attributes oldAttrs, Attributes newAttrs) {
          accu[0] = accu[0].mergeWith(a.checkReplaceAttributes(oldAttrs, newAttrs, v));
          abortIfIllFormed();
          a.doReplaceAttributes(oldAttrs, newAttrs);
        }

        @Override
        public void retain(int itemCount) {
          accu[0] = accu[0].mergeWith(a.checkRetain(itemCount, v));
          abortIfIllFormed();
          a.doRetain(itemCount);
        }

        @Override
        public void updateAttributes(AttributesUpdate u) {
          accu[0] = accu[0].mergeWith(a.checkUpdateAttributes(u, v));
          abortIfIllFormed();
          a.doUpdateAttributes(u);
        }

        @Override
        public void annotationBoundary(AnnotationBoundaryMap map) {
          accu[0] = accu[0].mergeWith(a.checkAnnotationBoundary(map, v));
          abortIfIllFormed();
          a.doAnnotationBoundary(map);
        }

        @Override
        public void elementEnd() {
          accu[0] = accu[0].mergeWith(a.checkElementEnd(v));
          abortIfIllFormed();
          a.doElementEnd();
        }

        @Override
        public void elementStart(String type, Attributes attrs) {
          accu[0] = accu[0].mergeWith(a.checkElementStart(type, attrs, v));
          abortIfIllFormed();
          a.doElementStart(type, attrs);
        }
      });
    } catch (IllFormed e) {
      return ValidationResult.ILL_FORMED;
    }
    accu[0] = accu[0].mergeWith(a.checkFinish(v));
    return accu[0];
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton

      AutomatonDocument doc, DocOp op) {

    if (schema == null) {
      schema = DocumentSchema.NO_SCHEMA_CONSTRAINTS;
    }
    final DocOpAutomaton a = new DocOpAutomaton(doc, schema);
    final ValidationResult[] accu = new ValidationResult[] { ValidationResult.VALID };
    try {
      op.apply(new DocOpCursor() {
        void abortIfIllFormed() {
          if (accu[0].isIllFormed()) {
            throw ILL_FORMED;
          }
        }

        @Override
        public void characters(String s) {
          accu[0] = accu[0].mergeWith(a.checkCharacters(s, v));
          abortIfIllFormed();
          a.doCharacters(s);
        }

        @Override
        public void deleteCharacters(String chars) {
          accu[0] = accu[0].mergeWith(a.checkDeleteCharacters(chars, v));
          abortIfIllFormed();
          a.doDeleteCharacters(chars);
        }

        @Override
        public void deleteElementEnd() {
          accu[0] = accu[0].mergeWith(a.checkDeleteElementEnd(v));
          abortIfIllFormed();
          a.doDeleteElementEnd();
        }

        @Override
        public void deleteElementStart(String type, Attributes attrs) {
          accu[0] = accu[0].mergeWith(a.checkDeleteElementStart(type, attrs, v));
          abortIfIllFormed();
          a.doDeleteElementStart(type, attrs);
        }

        @Override
        public void replaceAttributes(Attributes oldAttrs, Attributes newAttrs) {
          accu[0] = accu[0].mergeWith(a.checkReplaceAttributes(oldAttrs, newAttrs, v));
          abortIfIllFormed();
          a.doReplaceAttributes(oldAttrs, newAttrs);
        }

        @Override
        public void retain(int itemCount) {
          accu[0] = accu[0].mergeWith(a.checkRetain(itemCount, v));
          abortIfIllFormed();
          a.doRetain(itemCount);
        }

        @Override
        public void updateAttributes(AttributesUpdate u) {
          accu[0] = accu[0].mergeWith(a.checkUpdateAttributes(u, v));
          abortIfIllFormed();
          a.doUpdateAttributes(u);
        }

        @Override
        public void annotationBoundary(AnnotationBoundaryMap map) {
          accu[0] = accu[0].mergeWith(a.checkAnnotationBoundary(map, v));
          abortIfIllFormed();
          a.doAnnotationBoundary(map);
        }

        @Override
        public void elementEnd() {
          accu[0] = accu[0].mergeWith(a.checkElementEnd(v));
          abortIfIllFormed();
          a.doElementEnd();
        }

        @Override
        public void elementStart(String type, Attributes attrs) {
          accu[0] = accu[0].mergeWith(a.checkElementStart(type, attrs, v));
          abortIfIllFormed();
          a.doElementStart(type, attrs);
        }
      });
    } catch (IllFormed e) {
      return ValidationResult.ILL_FORMED;
    }
    accu[0] = accu[0].mergeWith(a.checkFinish(v));
    return accu[0];
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton

          new ReplaceAttributesGenerator(),
          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

Examples of org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton

            AnnotationBoundaryMapImpl map = AnnotationBoundaryMapImpl.builder()
                .initializationEnd(toArray(keysToEnd))
                .updateValues(toArray(changeKeys), toArray(changeOldValues),
                    toArray(changeNewValues)).build();
            final RandomizerOperationComponent component = generate(map);
            DocOpAutomaton temp = new DocOpAutomaton(a);
            ViolationCollector v = new ViolationCollector();
            component.check(temp, v);
            assert !component.check(temp, null).isIllFormed();
            component.apply(temp);
//            System.err.println("begin lookahead for " + map);
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.