當前位置: 首頁>>代碼示例>>Java>>正文


Java ViolationCollector類代碼示例

本文整理匯總了Java中org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector的典型用法代碼示例。如果您正苦於以下問題:Java ViolationCollector類的具體用法?Java ViolationCollector怎麽用?Java ViolationCollector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ViolationCollector類屬於org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton包,在下文中一共展示了ViolationCollector類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateAttributes

import org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector; //導入依賴的package包/類
private ValidationResult validateAttributes(String tag, Map<String, String> attr,
    ViolationCollector v, boolean allowRemovals) {
  if (attr == null) { return nullAttributes(v); }
  for (Map.Entry<String, String> e : attr.entrySet()) {
    String key = e.getKey();
    String value = e.getValue();
    if (key == null) { return nullAttributeKey(v); }
    if (!isXmlName(key)) { return attributeKeyNotXmlName(v, key); }
    if (value == null) {
      if (!allowRemovals) { return nullAttributeValue(v); }
      if (!elementAllowsAttribute(tag, key)) { return invalidAttribute(v, tag, key); }
    } else {
      if (!elementAllowsAttribute(tag, key, value)) {
        return invalidAttribute(v, tag, key, value);
      }
    }
  }
  return ValidationResult.VALID;
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:20,代碼來源:NindoAutomaton.java

示例2: generate

import org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector; //導入依賴的package包/類
@Override
RandomizerMutationComponent generate(boolean valid) {
  if (!valid) {
    return null;
  }
  if (p.getAnnotationOptions().isEmpty()) {
    return null;
  }

  Parameters.AnnotationOption option = randomElement(r, p.getAnnotationOptions());
  final String key = option.getKey();
  final String value = option.randomValue(r);
  return new RandomizerMutationComponent() {
    @Override
    public ValidationResult check(ViolationCollector v) {
      return a.checkStartAnnotation(key, value, v);
    }

    @Override
    public void apply() {
      a.doStartAnnotation(key, value);
      targetDoc.startAnnotation(key, value);
    }
  };
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:26,代碼來源:RandomNindoGenerator.java

示例3: createDocumentOperation

import org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector; //導入依賴的package包/類
/**
 * Create an implementation of DocumentOperation.
 *
 * @param input The provider of the message to wrap.
 * @param checkWellFormed If we should check for wellformness of deserialised DocOp
 * @return The created operation.
 */
private static DocOp createDocumentOperation(
    final DocOpMessageProvider input, boolean checkWellFormed) throws InvalidInputException {

  DocOp value = new MessageWrapperDocOp(input, checkWellFormed);

  if (checkWellFormed) {
    try {
      if (!DocOpValidator.isWellFormed(null, value)) {
        // Check again, collecting violations this time.
        ViolationCollector v = new ViolationCollector();
        DocOpValidator.isWellFormed(v, value);
        throw new InvalidInputException("Attempt to build ill-formed operation ("
            + v + "): " + value);
      }
    } catch (MessageWrapperDocOp.DelayedInvalidInputException e) {
      throw new InvalidInputException("Caught DelayedInvalidInputException while validating: "
          // Append e's message to our own message here.  It's not
          // enough to have e's message somewhere in the cause chain
          // because some places only log the getMessage() of our
          // exception.
          + e + ", " + input, e);
    }
  }

  return value;
}
 
開發者ID:ArloJamesBarnes,項目名稱:walkaround,代碼行數:34,代碼來源:OperationFactory.java

示例4: checkSkip

import org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector; //導入依賴的package包/類
/**
 * Checks if a skip transition with the given parameters would be valid.
 */
public ValidationResult checkSkip(int distance, ViolationCollector v) {
  if (distance <= 0) { return skipDistanceNotPositive(v); }
  if (!stackIsEmpty()) { return skipInsideInsertOrDelete(v); }
  if (!canSkip(distance)) { return skipPastEnd(v); }
  return valid();
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:10,代碼來源:NindoAutomaton.java

示例5: checkCharacters

import org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector; //導入依賴的package包/類
/**
 * Checks if a characters transition with the given parameters would be valid.
 */
public ValidationResult checkCharacters(String characters, ViolationCollector v) {
  // TODO(danilatos/ohler): Check schema and surrogates
  if (characters == null) { return nullCharacters(v); }
  if (characters.length() == 0) { return emptyCharacters(v); }
  if (topOfStackIsDeletion()) { return insertInsideDelete(v); }
  String enclosingTag = effectiveEnclosingElementTag();
  if (!tagAllowsText(enclosingTag)) { return textNotAllowedInElement(v, enclosingTag); }
  if (!canIncreaseLength(characters.length())) { return tooLong(v); }
  return valid();
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:14,代碼來源:NindoAutomaton.java

示例6: checkDeleteCharacters

import org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector; //導入依賴的package包/類
/**
 * Checks if a deleteCharacters transition with the given parameters would be valid.
 */
public ValidationResult checkDeleteCharacters(int count, ViolationCollector v) {
  if (count <= 0) { return deleteLengthNotPositive(v); }
  if (topOfStackIsInsertion()) { return deleteInsideInsert(v); }
  int available = maxCharactersToDelete();
  if (count > available) { return cannotDeleteSoManyCharacters(v, count, available); }
  return valid();
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:11,代碼來源:NindoAutomaton.java

示例7: checkElementStart

import org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector; //導入依賴的package包/類
/**
 * Checks if an elementStart with the given parameters would be valid.
 */
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
      && effectiveEnclosingElementTag() == null
      && stackIsEmpty()
      && resultingLength() == 0) {
    if (elementAllowedAsRoot(tag)) {
      return valid();
    } else {
      return typeInvalidRoot(v);
    }
  }
  String parentTag = effectiveEnclosingElementTag();
  if (parentTag == null) {
    if (!elementAllowedAsRoot(tag)) { return typeInvalidRoot(v); }
  } else {
    if (!elementAllowsChild(parentTag, tag)) { return invalidChild(v, parentTag, tag); }
  }
  return valid();
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:32,代碼來源:NindoAutomaton.java

示例8: checkChangeAttributes

import org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector; //導入依賴的package包/類
private ValidationResult checkChangeAttributes(Map<String, String> attr, ViolationCollector v,
    boolean allowNullValues) {
  if (!stackIsEmpty()) { return attributeChangeInsideInsertOrDelete(v); }
  if (effectiveDocSymbol() != DocSymbol.OPEN) { return noElementStartToChangeAttributes(v); }
  String actualTag = effectiveDocSymbolTag();
  assert actualTag != null;
  return validateAttributes(actualTag, attr, v, allowNullValues);
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:9,代碼來源:NindoAutomaton.java

示例9: checkStartAnnotation

import org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector; //導入依賴的package包/類
/**
 * 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();
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:11,代碼來源:NindoAutomaton.java

示例10: checkEndAnnotation

import org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector; //導入依賴的package包/類
/**
 * 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();
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:12,代碼來源:NindoAutomaton.java

示例11: checkFinish

import org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector; //導入依賴的package包/類
/**
 * Checks whether the automaton is in an accepting state, i.e., whether the
 * operation would be valid if no further mutation components follow.
 */
public ValidationResult checkFinish(ViolationCollector v) {
  for (StackEntry e : stack) {
    return e.notClosed(this, v);
  }
  for (String key : openAnnotationKeys) {
    return mismatchedStartAnnotation(v, key);
  }
  return ValidationResult.VALID;
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:14,代碼來源:NindoAutomaton.java

示例12: validate

import org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector; //導入依賴的package包/類
/**
 * Returns whether op is a well-formed document initialization and satisfies
 * the given schema constraints.
 */
public static ValidationResult validate(ViolationCollector v,
    DocumentSchema schema, DocInitialization op) {
  Preconditions.checkNotNull(schema, "Schema constraints required, if not, " +
      "use DocumentSchema.NO_SCHEMA_CONSTRAINTS");
  return validate(v, schema, DocOpAutomaton.EMPTY_DOCUMENT, op);
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:11,代碼來源:DocOpValidator.java

示例13: isWellFormed

import org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector; //導入依賴的package包/類
/**
 * Returns whether op is well-formed.
 *
 * Any violations recorded in the output v that are not well-formedness
 * violations are meaningless.
 */
public static boolean isWellFormed(ViolationCollector v, DocOp op) {
  if (op instanceof BufferedDocOpImpl) {
    return isWellFormed(v, (BufferedDocOpImpl) op);
  } else {
    return isWellFormedRaw(v, op);
  }
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:14,代碼來源:DocOpValidator.java

示例14: isWellFormedRaw

import org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector; //導入依賴的package包/類
/**
 * Same as {@link #isWellFormed(ViolationCollector, DocOp)}, but without
 * the fast path for BufferedDocOpImpl
 */
public static boolean isWellFormedRaw(ViolationCollector v, DocOp op) {
  // We validate the operation against the empty document.  It will likely
  // be invalid; however, we ignore the validity aspect anyway since we
  // only care about well-formedness.
  return !validate(v, DocumentSchema.NO_SCHEMA_CONSTRAINTS,
      DocOpAutomaton.EMPTY_DOCUMENT, op)
      .isIllFormed();
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:13,代碼來源:DocOpValidator.java

示例15: checkWellformedness

import org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector; //導入依賴的package包/類
/**
 * Checks that a buffered doc op is well-formed.
 *
 * @param value op to check
 * @throws IllegalStateException if the op is ill-formed
 */
private static void checkWellformedness(DocOp value) {
  if (!DocOpValidator.isWellFormed(null, value)) {
    // Check again, collecting violations this time.
    ViolationCollector v = new ViolationCollector();
    DocOpValidator.isWellFormed(v, value);
    Preconditions.illegalState("Attempt to build ill-formed operation (" + v + "): " + value);
  }
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:15,代碼來源:BufferedDocOpImpl.java


注:本文中的org.waveprotocol.wave.model.document.operation.automaton.DocOpAutomaton.ViolationCollector類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。