本文整理汇总了Java中org.waveprotocol.wave.model.document.operation.algorithm.DocOpCollector类的典型用法代码示例。如果您正苦于以下问题:Java DocOpCollector类的具体用法?Java DocOpCollector怎么用?Java DocOpCollector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DocOpCollector类属于org.waveprotocol.wave.model.document.operation.algorithm包,在下文中一共展示了DocOpCollector类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compact
import org.waveprotocol.wave.model.document.operation.algorithm.DocOpCollector; //导入依赖的package包/类
@Override
public List<DocOp> compact(List<DocOp> clientOps) {
if (clientOps.isEmpty()) {
return clientOps;
}
DocOpCollector c = new DocOpCollector();
for (DocOp op : clientOps) {
c.add(op);
}
return ImmutableList.of(c.composeAll());
}
示例2: DocDiff
import org.waveprotocol.wave.model.document.operation.algorithm.DocOpCollector; //导入依赖的package包/类
DocDiff(long lastReadVersion) {
Preconditions.checkArgument(lastReadVersion >= 0, "lastReadVersion = %s", lastReadVersion);
this.lastReadVersion = lastReadVersion;
this.state = new DocOpCollector();
this.diff = new DocOpCollector();
}
示例3: collectInto
import org.waveprotocol.wave.model.document.operation.algorithm.DocOpCollector; //导入依赖的package包/类
@Override
void collectInto(DocOpCollector collector) {
collector.add(docOp);
}
示例4: composeAll
import org.waveprotocol.wave.model.document.operation.algorithm.DocOpCollector; //导入依赖的package包/类
/**
* Composes all the operations together and returns the result.
*
* @return The composition of all the operations in the list.
*/
DocOp composeAll() {
DocOpCollector collector = new DocOpCollector();
collectInto(collector);
return collector.composeAll();
}
示例5: transform
import org.waveprotocol.wave.model.document.operation.algorithm.DocOpCollector; //导入依赖的package包/类
/**
* Transforms a pair of operations.
*
* @param clientOp the operation from the client
* @param serverOp the operation from the server
* @return the transformed pair of operations
* @throws TransformException if a problem was encountered during the
* transformation process
*/
public static OperationPair<DocOp> transform(DocOp clientOp,
DocOp serverOp) throws TransformException {
try {
Decomposition c = Decomposer.decompose(clientOp);
Decomposition s = Decomposer.decompose(serverOp);
DocOp ci = c.insertion;
DocOp cp = c.preservation;
DocOp cd = c.deletion;
DocOp si = s.insertion;
DocOp sp = s.preservation;
DocOp sd = s.deletion;
OperationPair<DocOp> r =
new InsertionInsertionTransformer().transformOperations(ci, si);
ci = r.clientOp();
si = r.serverOp();
r = new InsertionPreservationTransformer().transformOperations(ci, sp);
ci = r.clientOp();
sp = r.serverOp();
r = new InsertionPreservationTransformer().transformOperations(si, cp);
si = r.clientOp();
cp = r.serverOp();
r = new InsertionDeletionTransformer().transformOperations(ci, sd);
ci = r.clientOp();
sd = r.serverOp();
r = new InsertionDeletionTransformer().transformOperations(si, cd);
si = r.clientOp();
cd = r.serverOp();
DocOpCollector clientCollector = new DocOpCollector();
DocOpCollector serverCollector = new DocOpCollector();
clientCollector.add(ci);
serverCollector.add(si);
while (!AnnotationTamenessChecker.checkTameness(cp, sp, cd, sd)) {
r = new PreservationPreservationTransformer().transformOperations(cp, sp);
cp = r.clientOp();
sp = r.serverOp();
Pair<DocOp, Pair<DocOp, DocOp>> rc =
new PreservationDeletionTransformer().transformOperations(cp, sd);
Pair<DocOp, Pair<DocOp, DocOp>> rs =
new PreservationDeletionTransformer().transformOperations(sp, cd);
clientCollector.add(rc.first);
serverCollector.add(rs.first);
sp = rc.second.first;
sd = rc.second.second;
cp = rs.second.first;
cd = rs.second.second;
}
r = new DeletionDeletionTransformer().transformOperations(cd, sd);
cd = r.clientOp();
sd = r.serverOp();
clientCollector.add(cd);
serverCollector.add(sd);
return new OperationPair<DocOp>(
clientCollector.composeAll(), serverCollector.composeAll());
// We're catching runtime exceptions here, but checked exceptions may be better.
} catch (RuntimeException e) {
throw new TransformException(e);
}
}