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


Java OperationPair.clientOp方法代码示例

本文整理汇总了Java中org.waveprotocol.wave.model.operation.OperationPair.clientOp方法的典型用法代码示例。如果您正苦于以下问题:Java OperationPair.clientOp方法的具体用法?Java OperationPair.clientOp怎么用?Java OperationPair.clientOp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.waveprotocol.wave.model.operation.OperationPair的用法示例。


在下文中一共展示了OperationPair.clientOp方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transform

import org.waveprotocol.wave.model.operation.OperationPair; //导入方法依赖的package包/类
/**
 * Transforms a pair of blip operations.
 *
 * @param clientOp
 * @param serverOp
 * @return the transformed pair.
 * @throws TransformException
 */
public static OperationPair<BlipOperation> transform(BlipOperation clientOp,
    BlipOperation serverOp) throws TransformException {
  if (clientOp instanceof BlipContentOperation && serverOp instanceof BlipContentOperation) {
    BlipContentOperation clientBlipContentOp = (BlipContentOperation) clientOp;
    BlipContentOperation serverBlipContentOp = (BlipContentOperation) serverOp;
    DocOp clientContentOp = clientBlipContentOp.getContentOp();
    DocOp serverContentOp = serverBlipContentOp.getContentOp();
    OperationPair<? extends DocOp> transformedDocOps =
        Transformer.transform(clientContentOp, serverContentOp);
    clientOp = new BlipContentOperation(clientBlipContentOp.getContext(),
        transformedDocOps.clientOp());
    serverOp = new BlipContentOperation(serverBlipContentOp.getContext(),
        transformedDocOps.serverOp());
  } else {
    // All other blip-op pairs have identity transforms for now.
  }

  // Apply identity transform by default
  return new OperationPair<BlipOperation>(clientOp, serverOp);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:29,代码来源:Transform.java

示例2: pop

import org.waveprotocol.wave.model.operation.OperationPair; //导入方法依赖的package包/类
/**
 * Pops an operation from the undo stack and returns the operation that
 * effects the undo and the transformed non-undoable operation.
 *
 * @return a pair containeng the operation that accomplishes the desired undo
 *         and the transformed non-undoable operation
 */
Pair<T, T> pop() {
  if (stack.isEmpty()) {
    return null;
  }
  StackEntry<T> entry = stack.pop();
  T op = algorithms.invert(entry.op);
  if (entry.nonUndoables.isEmpty()) {
    return new Pair<T, T>(op, null);
  }
  OperationPair<T> pair;
  try {
    pair = algorithms.transform(op, algorithms.compose(entry.nonUndoables));
  } catch (TransformException e) {
    throw new IllegalStateException("invalid operation transformation encountered", e);
  }
  // TODO(user): Change the ternary expression to just stack.peek() after
  // switching from Stack to Deque.
  StackEntry<T> nextEntry = stack.isEmpty() ? null : stack.peek();
  if (nextEntry != null) {
    nextEntry.nonUndoables.add(pair.serverOp());
  }
  return new Pair<T, T>(pair.clientOp(), pair.serverOp());
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:31,代码来源:UndoStack.java

示例3: transformOps

import org.waveprotocol.wave.model.operation.OperationPair; //导入方法依赖的package包/类
/**
 * Transforms the specified client operations against the specified server operations,
 * returning the transformed client operations in a new list.
 *
 * @param clientOps may be unmodifiable
 * @param serverOps may be unmodifiable
 * @return transformed client ops
 */
private List<WaveletOperation> transformOps(List<WaveletOperation> clientOps,
    List<WaveletOperation> serverOps) throws OperationException {
  List<WaveletOperation> transformedClientOps = Lists.newArrayList();

  for (WaveletOperation c : clientOps) {
    for (WaveletOperation s : serverOps) {
      OperationPair<WaveletOperation> pair;
      try {
        pair = Transform.transform(c, s);
      } catch (TransformException e) {
        throw new OperationException(e);
      }
      c = pair.clientOp();
    }
    transformedClientOps.add(c);
  }
  return transformedClientOps;
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:27,代码来源:WaveletContainerImpl.java

示例4: transform

import org.waveprotocol.wave.model.operation.OperationPair; //导入方法依赖的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 {
    // The transform process consists of decomposing the client and server
    // operations into two constituent operations each and performing four
    // transforms structured as in the following diagram:
    //     ci0     cn0
    // si0     si1     si2
    //     ci1     cn1
    // sn0     sn1     sn2
    //     ci2     cn2
    //
    Pair<DocOp, DocOp> c = Decomposer.decompose(clientOp);
    Pair<DocOp, DocOp> s = Decomposer.decompose(serverOp);
    DocOp ci0 = c.first;
    DocOp cn0 = c.second;
    DocOp si0 = s.first;
    DocOp sn0 = s.second;
    OperationPair<DocOp> r1 = new InsertionTransformer().transformOperations(ci0, si0);
    DocOp ci1 = r1.clientOp();
    DocOp si1 = r1.serverOp();
    OperationPair<DocOp> r2 =
        new InsertionNoninsertionTransformer().transformOperations(ci1, sn0);
    DocOp ci2 = r2.clientOp();
    DocOp sn1 = r2.serverOp();
    OperationPair<DocOp> r3 =
        new InsertionNoninsertionTransformer().transformOperations(si1, cn0);
    DocOp si2 = r3.clientOp();
    DocOp cn1 = r3.serverOp();
    OperationPair<DocOp> r4 = new NoninsertionTransformer().transformOperations(cn1, sn1);
    DocOp cn2 = r4.clientOp();
    DocOp sn2 = r4.serverOp();
    return new OperationPair<DocOp>(
        Composer.compose(ci2, cn2),
        Composer.compose(si2, sn2));
  } catch (OperationException e) {
    throw new TransformException(e);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:49,代码来源:Transformer.java

示例5: transformNonUndoable

import org.waveprotocol.wave.model.operation.OperationPair; //导入方法依赖的package包/类
/**
 * Transforms a non undoable operation against the operations in the undo
 * stack.
 *
 * If updateUndoStack is true, also transform and update the undo stack,
 * otherwise, leave the undo stack untouched.
 *
 * @param op
 * @param updateUndoStack
 * @return returns the transformed nonundoable operation
 */
public List<WaveletOperation> transformNonUndoable(WaveletOperation op, boolean updateUndoStack) {
  if (!hasOperations() || OpUtils.isNoop(op)) {
    // If there are no buffered operations, or if the op is not important,
    // then we don't need to transform.
    return Collections.singletonList(op);
  }

  WaveAggregateOp nonUndoable = WaveAggregateOp.createAggregate(op);
  WaveAggregateOp composed = WaveAggregateOp.compose(undoable);

  final WaveAggregateOp transformedNonUndoable;
  final WaveAggregateOp transformedUndoable;
  try {
    OperationPair<WaveAggregateOp> transform =
        WaveAggregateOp.transform(nonUndoable, composed);
    transformedNonUndoable = transform.clientOp();
    transformedUndoable = transform.serverOp();
  } catch (TransformException e) {
    throw new RuntimeException("Transform exception while transforming nonUndoable", e);
  }

  // Update buffer
  undoable.clear();
  if (updateUndoStack) {
    undoable.add(transformedUndoable);
  } else {
    // As an optimization, since we have composed the operations in the undo
    // stack, replace it with the composed op.
    undoable.add(composed);
  }

  WaveletOperationContext originalContext = op.getContext();
  return transformedNonUndoable.toWaveletOperationsWithVersions(originalContext
      .getSegmentVersion(), originalContext.getHashedVersion());
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:47,代码来源:OneStepBuffer.java

示例6: transformNonUndoable

import org.waveprotocol.wave.model.operation.OperationPair; //导入方法依赖的package包/类
/**
 * Transforms a non undoable operation against the operations in the undo
 * stack.
 *
 * If updateUndoStack is true, also transform and update the undo stack,
 * otherwise, leave the undo stack untouched.
 *
 * @param op
 * @param updateUndoStack
 * @return returns the transformed nonundoable operation
 */
public List<WaveletOperation> transformNonUndoable(WaveletOperation op, boolean updateUndoStack) {
  if (!hasOperations() || OpUtils.isNoop(op)) {
    // If there are no buffered operations, or if the op is not important,
    // then we don't need to transform.
    return Collections.singletonList(op);
  }

  WaveAggregateOp nonUndoable = WaveAggregateOp.createAggregate(op);
  WaveAggregateOp composed = WaveAggregateOp.compose(undoable);

  final WaveAggregateOp transformedNonUndoable;
  final WaveAggregateOp transformedUndoable;
  try {
    OperationPair<WaveAggregateOp> transform =
        WaveAggregateOp.transform(nonUndoable, composed);
    transformedNonUndoable = transform.clientOp();
    transformedUndoable = transform.serverOp();
  } catch (TransformException e) {
    throw new RuntimeException("Transform exception while transforming nonUndoable", e);
  }

  // Update buffer
  undoable.clear();
  if (updateUndoStack) {
    undoable.add(transformedUndoable);
  } else {
    // As an optimization, since we have composed the operations in the undo
    // stack, replace it with the composed op.
    undoable.add(composed);
  }

  WaveletOperationContext originalContext = op.getContext();
  return transformedNonUndoable.toWaveletOperationsWithVersions(originalContext
      .getVersionIncrement(), originalContext.getHashedVersion());
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:47,代码来源:OneStepBuffer.java

示例7: transform

import org.waveprotocol.wave.model.operation.OperationPair; //导入方法依赖的package包/类
/**
 * Transforms a pair of operations.
 *
 * @param clientOp The client's operation.
 * @param clientOpAuthor The author of the client's operation.
 * @param serverOp The server's operation.
 * @param serverOpAuthor The author of the server's operation.
 * @return The resulting transformed client and server operations.
 * @throws TransformException if a problem was encountered during the
 *         transformation.
 */
public static OperationPair<CoreWaveletOperation> transform(CoreWaveletOperation clientOp,
    ParticipantId clientOpAuthor, CoreWaveletOperation serverOp, ParticipantId serverOpAuthor)
    throws TransformException {
  if (clientOp instanceof CoreWaveletDocumentOperation && serverOp instanceof
      CoreWaveletDocumentOperation) {
    final CoreWaveletDocumentOperation clientWaveDocOp = (CoreWaveletDocumentOperation) clientOp;
    final CoreWaveletDocumentOperation serverWaveDocOp = (CoreWaveletDocumentOperation) serverOp;
    if (clientWaveDocOp.getDocumentId().equals(serverWaveDocOp.getDocumentId())) {
      // Transform document operations
      final DocOp clientMutation = clientWaveDocOp.getOperation();
      final DocOp serverMutation = serverWaveDocOp.getOperation();
      final OperationPair<DocOp> transformedDocOps =
        Transformer.transform(clientMutation, serverMutation);
      clientOp = new CoreWaveletDocumentOperation(clientWaveDocOp.getDocumentId(),
          transformedDocOps.clientOp());
      serverOp = new CoreWaveletDocumentOperation(serverWaveDocOp.getDocumentId(),
          transformedDocOps.serverOp());
    } else {
      // Different documents don't conflict; use identity transform below
    }
  } else {

    if (serverOp instanceof CoreRemoveParticipant) {
      CoreRemoveParticipant serverRemoveOp = (CoreRemoveParticipant) serverOp;
      if (serverRemoveOp.getParticipantId().equals(clientOpAuthor)) {
        // clientOpAuthor has issued a client operation that is concurrent with a server
        // operation to remove clientOpAuthor, hence the client operation is doomed
        throw new RemovedAuthorException(clientOpAuthor.getAddress());
      }
      if (clientOp instanceof CoreRemoveParticipant) {
        CoreRemoveParticipant clientRemoveOp = (CoreRemoveParticipant) clientOp;
        if (clientRemoveOp.getParticipantId().equals(serverRemoveOp.getParticipantId())) {
          clientOp = CoreNoOp.INSTANCE;
          serverOp = CoreNoOp.INSTANCE;
        }
      } else if (clientOp instanceof CoreAddParticipant) {
        checkParticipantRemovalAndAddition(serverRemoveOp, (CoreAddParticipant) clientOp);
      }
    } else if (serverOp instanceof CoreAddParticipant) {
      CoreAddParticipant serverAddOp = (CoreAddParticipant) serverOp;
      if (clientOp instanceof CoreAddParticipant) {
        CoreAddParticipant clientAddOp = (CoreAddParticipant) clientOp;
        if (clientAddOp.getParticipantId().equals(serverAddOp.getParticipantId())) {
          clientOp = CoreNoOp.INSTANCE;
          serverOp = CoreNoOp.INSTANCE;
        }
      } else if (clientOp instanceof CoreRemoveParticipant) {
        checkParticipantRemovalAndAddition((CoreRemoveParticipant) clientOp, serverAddOp);
      }
    }
  }
  // Apply identity transform by default
  return new OperationPair<CoreWaveletOperation>(clientOp, serverOp);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:66,代码来源:CoreTransform.java

示例8: transform

import org.waveprotocol.wave.model.operation.OperationPair; //导入方法依赖的package包/类
private static OperationPair<OpCreatorPair> transform(OpCreatorPair c, OpCreatorPair s)
    throws TransformException {
  OperationPair<AggregateOperation> transformed = AggregateOperation.transform(c.op, s.op);
  return new OperationPair<OpCreatorPair>(new OpCreatorPair(transformed.clientOp(), c.creator, c.timestamp),
      new OpCreatorPair(transformed.serverOp(), s.creator, s.timestamp));
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:7,代码来源:WaveAggregateOp.java

示例9: transform

import org.waveprotocol.wave.model.operation.OperationPair; //导入方法依赖的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);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:68,代码来源:ReferenceTransformer.java

示例10: transform

import org.waveprotocol.wave.model.operation.OperationPair; //导入方法依赖的package包/类
/**
 * Transforms a pair of operations.
 *
 * @param clientOp The client's operation.
 * @param clientOpAuthor The author of the client's operation.
 * @param serverOp The server's operation.
 * @param serverOpAuthor The author of the server's operation.
 * @return The resulting transformed client and server operations.
 * @throws TransformException if a problem was encountered during the
 *         transformation.
 */
public static OperationPair<CoreWaveletOperation> transform(CoreWaveletOperation clientOp,
    ParticipantId clientOpAuthor, CoreWaveletOperation serverOp, ParticipantId serverOpAuthor)
    throws TransformException {
  if (clientOp instanceof CoreWaveletDocumentOperation && serverOp instanceof
      CoreWaveletDocumentOperation) {
    CoreWaveletDocumentOperation clientWaveDocOp = (CoreWaveletDocumentOperation) clientOp;
    CoreWaveletDocumentOperation serverWaveDocOp = (CoreWaveletDocumentOperation) serverOp;
    if (clientWaveDocOp.getDocumentId().equals(serverWaveDocOp.getDocumentId())) {
      // Transform document operations
      DocOp clientMutation = clientWaveDocOp.getOperation();
      DocOp serverMutation = serverWaveDocOp.getOperation();
      OperationPair<DocOp> transformedDocOps =
        Transformer.transform(clientMutation, serverMutation);
      clientOp = new CoreWaveletDocumentOperation(clientWaveDocOp.getDocumentId(),
          transformedDocOps.clientOp());
      serverOp = new CoreWaveletDocumentOperation(serverWaveDocOp.getDocumentId(),
          transformedDocOps.serverOp());
    } else {
      // Different documents don't conflict; use identity transform below
    }
  } else {

    if (serverOp instanceof CoreRemoveParticipant) {
      CoreRemoveParticipant serverRemoveOp = (CoreRemoveParticipant) serverOp;
      if (serverRemoveOp.getParticipantId().equals(clientOpAuthor)) {
        // clientOpAuthor has issued a client operation that is concurrent with a server
        // operation to remove clientOpAuthor, hence the client operation is doomed
        throw new RemovedAuthorException(clientOpAuthor.getAddress());
      }
      if (clientOp instanceof CoreRemoveParticipant) {
        CoreRemoveParticipant clientRemoveOp = (CoreRemoveParticipant) clientOp;
        if (clientRemoveOp.getParticipantId().equals(serverRemoveOp.getParticipantId())) {
          clientOp = CoreNoOp.INSTANCE;
          serverOp = CoreNoOp.INSTANCE;
        }
      } else if (clientOp instanceof CoreAddParticipant) {
        checkParticipantRemovalAndAddition(serverRemoveOp, (CoreAddParticipant) clientOp);
      }
    } else if (serverOp instanceof CoreAddParticipant) {
      CoreAddParticipant serverAddOp = (CoreAddParticipant) serverOp;
      if (clientOp instanceof CoreAddParticipant) {
        CoreAddParticipant clientAddOp = (CoreAddParticipant) clientOp;
        if (clientAddOp.getParticipantId().equals(serverAddOp.getParticipantId())) {
          clientOp = CoreNoOp.INSTANCE;
          serverOp = CoreNoOp.INSTANCE;
        }
      } else if (clientOp instanceof CoreRemoveParticipant) {
        checkParticipantRemovalAndAddition((CoreRemoveParticipant) clientOp, serverAddOp);
      }
    }
  }
  // Apply identity transform by default
  return new OperationPair<CoreWaveletOperation>(clientOp, serverOp);
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:66,代码来源:CoreTransform.java

示例11: transform

import org.waveprotocol.wave.model.operation.OperationPair; //导入方法依赖的package包/类
private static OperationPair<OpCreatorPair> transform(OpCreatorPair c, OpCreatorPair s)
    throws TransformException {
  OperationPair<AggregateOperation> transformed = AggregateOperation.transform(c.op, s.op);
  return new OperationPair<OpCreatorPair>(new OpCreatorPair(transformed.clientOp(), c.creator),
      new OpCreatorPair(transformed.serverOp(), s.creator));
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:7,代码来源:WaveAggregateOp.java


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