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

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


  /**
   * Checks if an endAnnotation with the given parameters would be valid.
   */
  public ValidationResult checkEndAnnotation(String key, ViolationCollector v) {
    {
      ValidationResult r = validateAnnotationKey(key, v);
      if (r != ValidationResult.VALID) { return r; }
    }
    if (!isAnnotationOpen(key)) { return mismatchedEndAnnotation(v, key); }
    return valid();
  }
View Full Code Here


              @Override
              public Pair<String, String> map(String value) {
                Attributes b = finalAttrAccu.updateWith(
                    new AttributesUpdateImpl(name, null, value));
                assert b != finalAttrAccu; // assert non-destructiveness
                ValidationResult v = checker.check(b);
                if (valid && !v.isValid() || !valid && v.isIllFormed()) {
                  return null;
                } else {
                  return Pair.of(name, value);
                }
              }
View Full Code Here

        return 0;
      }

      @Override
      RandomizerMutationComponent generate(boolean valid) {
        ValidationResult v = a.checkCharacters("a", null);
        if (v.isIllFormed()) {
          return null;
        }
        int count;
        if (valid) {
          if (!v.isValid()) {
            return null;
          }
          int max = Math.min(a.maxLengthIncrease(), p.getMaxInsertLength());
          if (max == 0) {
            return null;
          }
          count = randomIntFromRange(r, 1, max + 1);
        } else {
          if (v.isValid()) {
            // Exceed length of document (if p.maxInsertLength allows it).
            int max = p.getMaxInsertLength();
            int min = a.maxLengthIncrease() + 1;
            if (min > max) {
              return null;
View Full Code Here

        Pair<String, Attributes> args = pickRandomNonNullMappedElement(r, p.getElementTypes(),
            new Mapper<String, Pair<String, Attributes>>() {
              @Override
              public Pair<String, Attributes> map(final String tag) {
                {
                  ValidationResult v = a.checkElementStart(tag, Attributes.EMPTY_MAP, null);
                  if (valid && !v.isValid() || !valid && v.isIllFormed()) {
                    // Early exit if we can't build an element start with this tag.
                    return null;
                  }
                }
View Full Code Here

  public ValidationResult checkElementStart(String tag, Map<String, String> attr,
      ViolationCollector v) {
    if (tag == null) { return nullTag(v); }
    if (!isXmlName(tag)) { return elementTypeNotXmlName(v, tag); }
    {
      ValidationResult attrViolation = validateAttributes(tag, attr, v, false);
      if (attrViolation != ValidationResult.VALID) { return attrViolation; }
    }
    if (topOfStackIsDeletion()) { return insertInsideDelete(v); }
    if (!canIncreaseLength(2)) { return tooLong(v); }
    if (effectiveDocSymbol() == DocSymbol.END
View Full Code Here

  /**
   * Checks if a startAnnotation with the given parameters would be valid.
   */
  public ValidationResult checkStartAnnotation(String key, String value, ViolationCollector v) {
    {
      ValidationResult r = validateAnnotationKey(key, v);
      if (r != ValidationResult.VALID) { return r; }
    }
    return valid();
  }
View Full Code Here

  /**
   * Checks if an endAnnotation with the given parameters would be valid.
   */
  public ValidationResult checkEndAnnotation(String key, ViolationCollector v) {
    {
      ValidationResult r = validateAnnotationKey(key, v);
      if (r != ValidationResult.VALID) { return r; }
    }
    if (!isAnnotationOpen(key)) { return mismatchedEndAnnotation(v, key); }
    return valid();
  }
View Full Code Here

              @Override
              public AttributesUpdate map(String value) {
                AttributesUpdate b = finalAccu.composeWith(new AttributesUpdateImpl(name,
                    oldAttributes.get(name), value));
                assert b != finalAccu; // assert non-destructiveness
                ValidationResult v = checker.check(b);
                if (valid && !v.isValid() || !valid && v.isIllFormed()) {
                  return null;
                } else {
                  return b;
                }
              }
View Full Code Here

      @Override
      RandomizerOperationComponent generate(DocOpAutomaton a, boolean valid, Stage stage) {
        if (stage != Stage.S1_UNRESTRICTED) {
          return null;
        }
        ValidationResult v = a.checkCharacters("a", null);
        if (v.isIllFormed()) {
          return null;
        }
        int count;
        if (valid) {
          if (!v.isValid()) {
            return null;
          }
          // TODO: implement this once we have size limits.
          int max = p.getMaxInsertLength();
          if (max == 0) {
            return null;
          }
          count = randomIntFromRange(r, 1, max + 1);
        } else {
          if (v.isValid()) {
            // Exceed length of document (if p.maxInsertLength allows it).
            int max = p.getMaxInsertLength();
            // TODO: implement this once we have size limits.
            //count = randomIntFromRange(r, min, max + 1);
            return null;
View Full Code Here

      }

      RandomizerOperationComponent generateGivenTag(final DocOpAutomaton a, final boolean valid,
          final String tag) {
        {
          ValidationResult v = a.checkElementStart(tag, Attributes.EMPTY_MAP, null);
          if (valid && !v.isValid() || !valid && v.isIllFormed()) {
            // Early exit if we can't build an element start with this tag.
            return null;
          }
        }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ValidationResult

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.