本文整理汇总了Java中org.waveprotocol.wave.model.document.operation.algorithm.DocOpCollector.add方法的典型用法代码示例。如果您正苦于以下问题:Java DocOpCollector.add方法的具体用法?Java DocOpCollector.add怎么用?Java DocOpCollector.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.waveprotocol.wave.model.document.operation.algorithm.DocOpCollector
的用法示例。
在下文中一共展示了DocOpCollector.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: collectInto
import org.waveprotocol.wave.model.document.operation.algorithm.DocOpCollector; //导入方法依赖的package包/类
@Override
void collectInto(DocOpCollector collector) {
collector.add(docOp);
}
示例3: 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);
}
}