当前位置: 首页>>代码示例>>Java>>正文


Java DocOpUtil类代码示例

本文整理汇总了Java中org.waveprotocol.wave.model.document.operation.impl.DocOpUtil的典型用法代码示例。如果您正苦于以下问题:Java DocOpUtil类的具体用法?Java DocOpUtil怎么用?Java DocOpUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DocOpUtil类属于org.waveprotocol.wave.model.document.operation.impl包,在下文中一共展示了DocOpUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newWorthyDocumentOperation

import org.waveprotocol.wave.model.document.operation.impl.DocOpUtil; //导入依赖的package包/类
private DocOp newWorthyDocumentOperation(DocInitialization content, boolean first) {
  int size = DocOpUtil.resultingDocumentLength(content);
  String key = "walkaround-irrelevant-annotation-change-to-force-contribution";
  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();
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:17,代码来源:HistorySynthesizer.java

示例2: addDocumentSnapshotToWavelet

import org.waveprotocol.wave.model.document.operation.impl.DocOpUtil; //导入依赖的package包/类
private static void addDocumentSnapshotToWavelet(
    DocumentSnapshot snapshot, WaveletData container) throws InvalidParticipantAddress {
  DocOp op = CoreWaveletOperationSerializer.deserialize(snapshot.getDocumentOperation());
  DocInitialization docInit = DocOpUtil.asInitialization(op);

  Collection<ParticipantId> contributors = CollectionUtils.newArrayList();
  for (String p : snapshot.getContributorList()) {
    contributors.add(getParticipantId(p));
  }
  container.createBlip(
      snapshot.getDocumentId(),
      getParticipantId(snapshot.getAuthor()),
      contributors,
      docInit,
      snapshot.getCreationTime(),
      snapshot.getCreationVersion(),
      snapshot.getLastModifiedTime(),
      snapshot.getLastModifiedVersion());
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:20,代码来源:SnapshotSerializer.java

示例3: quotedValue

import org.waveprotocol.wave.model.document.operation.impl.DocOpUtil; //导入依赖的package包/类
private String quotedValue(char quoteChar) throws XmlParseException {
  ensure(input.charAt(offset) == quoteChar,
      "expected ", quoteChar, " at position ", offset, " in ", input);
  offset++;
  int start = offset;

  int nextQuote;
  while(true) {
    nextQuote = input.indexOf(quoteChar, offset);
    ensure(nextQuote != -1, "closing ", quoteChar, " not found");
    offset = nextQuote;
    if (input.charAt(nextQuote - 1) != '\\') {
      break;
    }
    offset++;
  }
  String value = input.substring(start, offset);
  offset++;

  return DocOpUtil.annotationUnEscape(DocOpUtil.xmlTextUnEscape(value));
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:22,代码来源:AnnotationParser.java

示例4: composeOperations

import org.waveprotocol.wave.model.document.operation.impl.DocOpUtil; //导入依赖的package包/类
private DocOp composeOperations(DocOp op1, DocOp op2)
    throws OperationException {
  target = defaultTarget;
  int op1Index = 0;
  int op2Index = 0;
  while (op1Index < op1.size()) {
    op1.applyComponent(op1Index++, target);
    while (target.isPostTarget()) {
      if (op2Index >= op2.size()) {
        throw new OperationException("Document size mismatch: "
            + "op1 resulting length=" + DocOpUtil.resultingDocumentLength(op1)
            + ", op2 initial length=" + DocOpUtil.initialDocumentLength(op2));
      }
      op2.applyComponent(op2Index++, target);
    }
  }
  if (op2Index < op2.size()) {
    target = new FinisherPostTarget();
    while (op2Index < op2.size()) {
      op2.applyComponent(op2Index++, target);
    }
  }
  flushAnnotations();
  return normalizer.finish();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:26,代码来源:Composer.java

示例5: toDebugString

import org.waveprotocol.wave.model.document.operation.impl.DocOpUtil; //导入依赖的package包/类
@Override
public String toDebugString() {
  try {
    return DocOpUtil.toXmlString(DocOpScrub.maybeScrub(toInitialization()));
  } catch (RuntimeException e) {
    if (!DocOpScrub.shouldScrubByDefault()) {
      try {
        return "#<NO ANNOTATIONS>: " + XmlStringBuilder.innerXml(this) + "# (" + e + ")";
      } catch (RuntimeException e2) {
        return "#<!SUPER BROKEN># (" + e + ")";
      }
    } else {
      return "#<!BROKEN># (" + e + ")";
    }
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:17,代码来源:IndexedDocumentImpl.java

示例6: testAsOperation

import org.waveprotocol.wave.model.document.operation.impl.DocOpUtil; //导入依赖的package包/类
/**
 * Tests the asDocInitialization method.
 */
public void testAsOperation() {
  IndexedDocumentImpl<Node, Element, Text, ?> document =
      documentParser.parseDocument(
        "<blip><p><i>ab</i>cd<b>ef</b>gh</p></blip>");
  DocInitialization expected = new DocInitializationBuilder()
      .elementStart("blip", Attributes.EMPTY_MAP)
      .elementStart("p", Attributes.EMPTY_MAP)
      .elementStart("i", Attributes.EMPTY_MAP)
      .characters("ab")
      .elementEnd()
      .characters("cd")
      .elementStart("b", Attributes.EMPTY_MAP)
      .characters("ef")
      .elementEnd()
      .characters("gh")
      .elementEnd()
      .elementEnd()
      .build();
  document.asOperation();
  assertEquals(
      DocOpUtil.toConciseString(expected),
      DocOpUtil.toConciseString(document.asOperation()));
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:27,代码来源:IndexedDocumentImplTest.java

示例7: addDocumentSnapshotToWavelet

import org.waveprotocol.wave.model.document.operation.impl.DocOpUtil; //导入依赖的package包/类
private static void addDocumentSnapshotToWavelet(
    DocumentSnapshot snapshot, WaveletData container) throws InvalidParticipantAddress {
  DocOp op = WaveletOperationSerializer.deserialize(snapshot.getDocumentOperation());
  DocInitialization docInit = DocOpUtil.asInitialization(op);

  Collection<ParticipantId> contributors = CollectionUtils.newArrayList();
  for (String p : snapshot.getContributor()) {
    contributors.add(ParticipantId.of(p));
  }
  container.createDocument(
      snapshot.getDocumentId(),
      new ParticipantId(snapshot.getAuthor()),  // We trust the server's snapshot
      contributors,
      docInit,
      snapshot.getLastModifiedTime(),
      snapshot.getLastModifiedVersion());
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:18,代码来源:SnapshotSerializer.java

示例8: addDocumentSnapshotToWavelet

import org.waveprotocol.wave.model.document.operation.impl.DocOpUtil; //导入依赖的package包/类
private static void addDocumentSnapshotToWavelet(
    DocumentSnapshot snapshot, WaveletData container) throws InvalidParticipantAddress {
  DocOp op = CoreWaveletOperationSerializer.deserialize(snapshot.getDocumentOperation());
  DocInitialization docInit = DocOpUtil.asInitialization(op);

  Collection<ParticipantId> contributors = CollectionUtils.newArrayList();
  for (String p : snapshot.getContributorList()) {
    contributors.add(getParticipantId(p));
  }
  container.createDocument(
      snapshot.getDocumentId(),
      getParticipantId(snapshot.getAuthor()),
      contributors,
      docInit,
      snapshot.getLastModifiedTime(),
      snapshot.getLastModifiedVersion());
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:18,代码来源:SnapshotSerializer.java

示例9: testAsOperation

import org.waveprotocol.wave.model.document.operation.impl.DocOpUtil; //导入依赖的package包/类
/**
 * Tests the asOperation method.
 */
public void testAsOperation() {
  IndexedDocumentImpl<Node, Element, Text, ?> document =
      documentParser.parseDocument(
        "<blip><p><i>ab</i>cd<b>ef</b>gh</p></blip>");
  DocInitialization expected = new DocInitializationBuilder()
      .elementStart("blip", Attributes.EMPTY_MAP)
      .elementStart("p", Attributes.EMPTY_MAP)
      .elementStart("i", Attributes.EMPTY_MAP)
      .characters("ab")
      .elementEnd()
      .characters("cd")
      .elementStart("b", Attributes.EMPTY_MAP)
      .characters("ef")
      .elementEnd()
      .characters("gh")
      .elementEnd()
      .elementEnd()
      .build();
  document.asOperation();
  assertEquals(
      DocOpUtil.toConciseString(expected),
      DocOpUtil.toConciseString(document.asOperation()));
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:27,代码来源:IndexedDocumentImplTest.java

示例10: run

import org.waveprotocol.wave.model.document.operation.impl.DocOpUtil; //导入依赖的package包/类
<D extends ModifiableDocument> void run(D document, DocumentParser<D> parser) {
  String initialState = parser.asString(document);
  DocOp docOp = null;

  try {
    document.consume(mutation);
  } catch (OperationException e) {
    Assert.fail("An OperationException was thrown: " + e);
  }

  String computedDocument = parser.asString(document);
  String message = "Computed: " + computedDocument + " Expected: "
      + expectedResultAlternatives + " Op: " + DocOpUtil.toConciseString(mutation);
  Assert.assertTrue(message, expectedResultAlternatives.contains(computedDocument));

}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:17,代码来源:DocumentTestCases.java

示例11: selectNonEmptyDocuments

import org.waveprotocol.wave.model.document.operation.impl.DocOpUtil; //导入依赖的package包/类
private List<GoogleDocument> selectNonEmptyDocuments(List<GoogleDocument> docs) {
  ImmutableList.Builder<GoogleDocument> out = ImmutableList.builder();
  for (GoogleDocument doc : docs) {
    if (DocOpUtil.resultingDocumentLength(
            GoogleDeserializer.deserializeContent(doc.getContent())) > 0) {
      out.add(doc);
    }
  }
  return out.build();
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:11,代码来源:HistorySynthesizer.java

示例12: describe

import org.waveprotocol.wave.model.document.operation.impl.DocOpUtil; //导入依赖的package包/类
static String describe(WaveletDataImpl udwData) {
  StringBuilder b = new StringBuilder();
  for (String id : udwData.getDocumentIds()) {
    b.append(id + ":\n");
    b.append(DocOpUtil.toPrettyXmlString(
        ((Document) udwData.getDocument(id).getContent()).toInitialization(), 2));
    b.append("\n\n");
  }
  return b.toString();
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:11,代码来源:Util.java

示例13: deserializeBlip

import org.waveprotocol.wave.model.document.operation.impl.DocOpUtil; //导入依赖的package包/类
@Override
public void deserializeBlip(Blob serialized, RawBlipSnapshot.Serializer.Writer writer) {
  Timer timer = Timing.start("RawBlipSerializer.deserializeBlip");
  try {
    ProtoBlipSnapshot serializedBlip = adaptor.createBlipSnapshot(serialized);
    ImmutableSet.Builder<ParticipantId> contributors = ImmutableSet.builder();
    try {
      writer.setAuthor(ParticipantId.of(serializedBlip.getAuthor()));
      for (String contributor : serializedBlip.getContributor()) {
        contributors.add(ParticipantId.of(contributor));
      }
    } catch (InvalidParticipantAddress ex) {
      throw new RawParseException("Blip deserializing error", ex);
    }
    writer.setContributors(contributors.build());
    writer.setCreationTime(serializedBlip.getCreationTime());
    writer.setCreationVersion(serializedBlip.getCreationVersion());
    writer.setLastModifiedTime(serializedBlip.getLastModifiedTime());
    writer.setLastModifiedVersion(serializedBlip.getLastModifiedVersion());
    ProtoDocumentSnapshot doc = adaptor.createDocumentSnapshot(
        new Blob(serializedBlip.getRawDocumentSnapshot()));
    DocOp docOp = WaveletOperationSerializer.deserialize(doc.getDocumentSnapshot());
    DocInitialization docInit = DocOpUtil.asInitialization(docOp);
    writer.setContent(docInit);
  } finally {
    Timing.stop(timer);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:29,代码来源:RawBlipSerializer.java

示例14: parse

import org.waveprotocol.wave.model.document.operation.impl.DocOpUtil; //导入依赖的package包/类
@Override
public IndexedDocument<N, E, T> parse(String text) {
  DocInitialization docInitialization;
  try {
    docInitialization = DocOpUtil.docInitializationFromXml(text);
  } catch (XmlParseException e) {
    throw new IllegalArgumentException(e);
  }
  return build(docInitialization, NO_SCHEMA_CONSTRAINTS);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:11,代码来源:IndexedDocProvider.java

示例15: formatPersistentDomString

import org.waveprotocol.wave.model.document.operation.impl.DocOpUtil; //导入依赖的package包/类
/** @return a string version of the persistent dom tree in an editor. */
public static String formatPersistentDomString(Editor editor) {
  if (EditorTestingUtil.isConsistent(editor)) {
    return DocOpUtil.toPrettyXmlString(editor.getDocumentInitialization(),
        DOCUMENT_STRINGIFY_INDENT);
  } else {
    EditorStaticDeps.logger.error().logPlainText(
        "EditorDocFormatter called with inconsistent Doc");
    return null;
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:12,代码来源:EditorDocFormatter.java


注:本文中的org.waveprotocol.wave.model.document.operation.impl.DocOpUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。