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


Java WaveletBlipOperation类代码示例

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


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

示例1: deserialize

import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation; //导入依赖的package包/类
/**
 * Deserialize a {@link ProtocolWaveletOperation} as a {@link WaveletOperation}.
 *
 * @param protobufOp protocol buffer wavelet operation to deserialize
 * @return deserialized wavelet operation
 */
public static WaveletOperation deserialize(ProtocolWaveletOperation protobufOp,
    WaveletOperationContext context) {
  if (protobufOp.hasNoOp()) {
    return new NoOp(context);
  } else if (protobufOp.hasAddParticipant()) {
    return new AddParticipant(context, new ParticipantId(protobufOp.getAddParticipant()));
  } else if (protobufOp.hasRemoveParticipant()) {
    return new RemoveParticipant(context, new ParticipantId(protobufOp.getRemoveParticipant()));
  } else if (protobufOp.hasMutateDocument()) {
    return new WaveletBlipOperation(protobufOp.getMutateDocument().getDocumentId(),
        new BlipContentOperation(context,
            deserialize(protobufOp.getMutateDocument().getDocumentOperation())));
  } else {
    throw new IllegalArgumentException("Unsupported operation: " + protobufOp);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:23,代码来源:OperationSerializer.java

示例2: deserializeWaveletOperation

import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation; //导入依赖的package包/类
public static WaveletOperation deserializeWaveletOperation(DBObject dbObject,
    WaveletOperationContext context) throws PersistenceException {
  String type = (String) dbObject.get(FIELD_TYPE);
  if (type.equals(WAVELET_OP_NOOP)) {
    return new NoOp(context);
  } else if (type.equals(WAVELET_OP_ADD_PARTICIPANT)) {
    return new AddParticipant(context,
        deserializeParicipantId((DBObject) dbObject.get(FIELD_PARTICIPANT)));
  } else if (type.equals(WAVELET_OP_REMOVE_PARTICIPANT)) {
    return new RemoveParticipant(context,
        deserializeParicipantId((DBObject) dbObject.get(FIELD_PARTICIPANT)));
  } else if (type.equals(WAVELET_OP_WAVELET_BLIP_OPERATION)) {
    return new WaveletBlipOperation((String) dbObject.get(FIELD_BLIPID),
        deserializeBlipContentOperation((DBObject) dbObject.get(FIELD_BLIPOP), context));
  } else {
    throw new IllegalArgumentException("Unsupported operation: " + type);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:19,代码来源:MongoDbStoreUtil.java

示例3: attachDocHandler

import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation; //导入依赖的package包/类
/**
 * Attaches a doc handler to the blip the operation applies to.
 *
 * @param conversation the conversation the op is to be applied to.
 * @param op the op to be applied
 * @param docHandlers the list of attached dochandlers.
 * @param capabilities the capabilities of the robot.
 * @param messages the bundle to put the generated events in.
 * @param deltaAuthor the author of the events generated.
 * @param timestamp the timestamp at which these events occurred.
 */
private void attachDocHandler(ObservableConversation conversation, WaveletOperation op,
    Map<String, EventGeneratingDocumentHandler> docHandlers,
    Map<EventType, Capability> capabilities, EventMessageBundle messages,
    ParticipantId deltaAuthor, long timestamp) {
  WaveletBlipOperation blipOp = (WaveletBlipOperation) op;
  String blipId = blipOp.getBlipId();
  // Ignoring the documents outside the conversation such as tags
  // and robot data docs.
  ObservableConversationBlip blip = conversation.getBlip(blipId);
  if (blip != null) {
    String blipId1 = blip.getId();

    EventGeneratingDocumentHandler docHandler = docHandlers.get(blipId1);
    if (docHandler == null) {
      ObservableDocument doc = (ObservableDocument) blip.getDocument();
      docHandler = new EventGeneratingDocumentHandler(
          doc, blip, capabilities, messages, deltaAuthor, timestamp);
      doc.addListener(docHandler);
      docHandlers.put(blipId1, docHandler);
    } else {
      docHandler.setAuthorAndTimeStamp(deltaAuthor, timestamp);
    }
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:36,代码来源:EventGenerator.java

示例4: serialize

import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation; //导入依赖的package包/类
/**
 * Serialize a {@link WaveletOperation} as a {@link ProtocolWaveletOperation}.
 *
 * @param waveletOp wavelet operation to serialize
 * @return serialized protocol buffer wavelet operation
 */
public ProtocolWaveletOperation serialize(WaveletOperation waveletOp) {
  ProtocolWaveletOperation protobufOp = adaptor.createProtocolWaveletOperation();

  if (waveletOp instanceof NoOp) {
    protobufOp.setNoOp(true);
  } else if (waveletOp instanceof AddParticipant) {
    protobufOp.setAddParticipant(((AddParticipant) waveletOp).getParticipantId().getAddress());
  } else if (waveletOp instanceof RemoveParticipant) {
    protobufOp.setRemoveParticipant(((RemoveParticipant) waveletOp).getParticipantId()
        .getAddress());
  } else if (waveletOp instanceof WaveletBlipOperation) {
    ProtocolWaveletOperation.MutateDocument mutation = adaptor.createProtocolWaveletDocumentOperation();
    mutation.setDocumentId(((WaveletBlipOperation) waveletOp).getBlipId());
    mutation.setDocumentOperation(serialize(((WaveletBlipOperation) waveletOp).getBlipOp()));
    protobufOp.setMutateDocument(mutation);
  } else {
    throw new IllegalArgumentException("Unsupported operation type: " + waveletOp);
  }

  return protobufOp;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:28,代码来源:WaveletOperationSerializer.java

示例5: deserialize

import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation; //导入依赖的package包/类
/**
 * Deserialize a {@link ProtocolWaveletOperation} as a
 * {@link WaveletOperation}.
 *
 * @param protobufOp protocol buffer wavelet operation to deserialize
 * @return deserialized wavelet operation
 */
public static WaveletOperation deserialize(ProtocolWaveletOperation protobufOp,
    WaveletOperationContext ctx) {
  if (protobufOp.hasNoOp()) {
    return new NoOp(ctx);
  } else if (protobufOp.hasAddParticipant()) {
    return new AddParticipant(ctx, new ParticipantId(protobufOp.getAddParticipant()));
  } else if (protobufOp.hasRemoveParticipant()) {
    return new RemoveParticipant(ctx, new ParticipantId(protobufOp.getRemoveParticipant()));
  } else if (protobufOp.hasMutateDocument()) {
    return new WaveletBlipOperation(protobufOp.getMutateDocument().getDocumentId(),
        new BlipContentOperation(ctx, deserialize(protobufOp.getMutateDocument()
            .getDocumentOperation())));
  } else {
    throw new IllegalArgumentException("Unsupported operation: " + protobufOp);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:24,代码来源:WaveletOperationSerializer.java

示例6: AggregateOperation

import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation; //导入依赖的package包/类
/**
 * Constructs an aggregate operation that has the same behaviour as a
 * <code>WaveletBlipOperation</code>.
 *
 * @param op The wavelet blip operation.
 */
AggregateOperation(WaveletBlipOperation op) {
  segmentsToRemove = Collections.emptyList();
  segmentsToAdd = Collections.emptyList();
  segmentsToEndModifying = Collections.emptyList();
  segmentsToStartModifying = Collections.emptyList();
  participantsToRemove = Collections.emptyList();
  participantsToAdd = Collections.emptyList();
  if (op.getBlipOp() instanceof BlipContentOperation) {
  docOps = Collections.singletonList(
      new DocumentOperations(
          op.getBlipId(),
          new DocOpList.Singleton(((BlipContentOperation) op.getBlipOp()).getContentOp())));
  } else {
    docOps = Collections.emptyList();
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:23,代码来源:AggregateOperation.java

示例7: checkInsert

import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation; //导入依赖的package包/类
private void checkInsert(WaveletOperation operation, int location, String content,
    int remaining) {
  if (operation instanceof WaveletBlipOperation) {
    WaveletBlipOperation waveOp = (WaveletBlipOperation) operation;
    if (waveOp.getBlipOp() instanceof BlipContentOperation) {
      BlipContentOperation blipOp = (BlipContentOperation) waveOp.getBlipOp();
      DocOpBuilder builder = new DocOpBuilder();
      builder.retain(location).characters(content);
      if (remaining > 0) {
          builder.retain(remaining);
      }
      assertTrue(OpComparators.SYNTACTIC_IDENTITY.equal(builder.build(), blipOp.getContentOp()));
      return;
    }
  }
  fail("Did not get an insertion operation.");
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:18,代码来源:DeltaPairTest.java

示例8: serialize

import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation; //导入依赖的package包/类
/**
 * Serialize a {@link WaveletOperation} as a {@link ProtocolWaveletOperation}.
 *
 * @param waveletOp wavelet operation to serialize
 * @return serialized protocol buffer wavelet operation
 */
public static ProtocolWaveletOperation serialize(WaveletOperation waveletOp) {
  ProtocolWaveletOperation protobufOp = ProtocolWaveletOperationJsoImpl.create();

  if (waveletOp instanceof NoOp) {
    protobufOp.setNoOp(true);
  } else if (waveletOp instanceof AddParticipant) {
    protobufOp.setAddParticipant(((AddParticipant) waveletOp).getParticipantId().getAddress());
  } else if (waveletOp instanceof RemoveParticipant) {
    protobufOp.setRemoveParticipant(((RemoveParticipant) waveletOp).getParticipantId()
        .getAddress());
  } else if (waveletOp instanceof WaveletBlipOperation) {
    ProtocolWaveletOperation.MutateDocument mutation =
        ProtocolWaveletOperationJsoImpl.MutateDocumentJsoImpl.create();
    mutation.setDocumentId(((WaveletBlipOperation) waveletOp).getBlipId());
    mutation.setDocumentOperation(serialize(((WaveletBlipOperation) waveletOp).getBlipOp()));
    protobufOp.setMutateDocument(mutation);
  } else {
    throw new IllegalArgumentException("Unsupported operation type: " + waveletOp);
  }

  return protobufOp;
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:29,代码来源:WaveletOperationSerializer.java

示例9: attachDocHandler

import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation; //导入依赖的package包/类
/**
 * Attaches a doc handler to the blip the operation applies to.
 *
 * @param conversation the conversation the op is to be applied to.
 * @param op the op to be applied
 * @param docHandlers the list of attached dochandlers.
 * @param capabilities the capabilities of the robot.
 * @param messages the bundle to put the generated events in.
 * @param deltaAuthor the author of the events generated.
 * @param timestamp the timestamp at which these events occurred.
 */
private void attachDocHandler(ObservableConversation conversation, WaveletOperation op,
    Map<String, EventGeneratingDocumentHandler> docHandlers,
    Map<EventType, Capability> capabilities, EventMessageBundle messages,
    ParticipantId deltaAuthor, long timestamp, Wavelet wavelet, EventDataConverter converter) {
  WaveletBlipOperation blipOp = (WaveletBlipOperation) op;
  String blipId = blipOp.getBlipId();
  // Ignoring the documents outside the conversation such as tags
  // and robot data docs.
  ObservableConversationBlip blip = conversation.getBlip(blipId);
  if (blip != null) {
    String blipId1 = blip.getId();

    EventGeneratingDocumentHandler docHandler = docHandlers.get(blipId1);
    if (docHandler == null) {
      ObservableDocument doc = (ObservableDocument) blip.getContent();
      docHandler =
          new EventGeneratingDocumentHandler(doc, blip, capabilities, messages, deltaAuthor,
              timestamp, wavelet, converter);
      doc.addListener(docHandler);
      docHandlers.put(blipId1, docHandler);
    } else {
      docHandler.setAuthorAndTimeStamp(deltaAuthor, timestamp);
    }
  }
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:37,代码来源:EventGenerator.java

示例10: createBlipOperation

import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation; //导入依赖的package包/类
/**
 * Creates a wavelet-blip operation from a message.
 *
 * @param context
 * @param message
 * @param checkWellFormed If we should check for wellformness of deserialised DocOp
 * @return a wavelet-blip operation described by {@code message}, or {@code null} if
 *   {@code message} does not describe a blip operation.
 */
private static WaveletBlipOperation createBlipOperation(WaveletOperationContext context,
    ProtocolWaveletOperation message, boolean checkWellFormed)
    throws InvalidInputException {

  if (message.getMutateDocument() != null) {
    MutateDocument opMessage = message.getMutateDocument();
    return new WaveletBlipOperation(opMessage.getDocumentId(), new BlipContentOperation(
        context, createDocumentOperation(opMessage.getDocumentOperation(), checkWellFormed)));
  }
  throw new InvalidInputException("Failed to create blip operation for message " + message);
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:21,代码来源:OperationFactory.java

示例11: serialize

import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation; //导入依赖的package包/类
/**
 * Serializes a wavelet operation as a {@link ProtocolWaveletOperation}.
 *
 * @param waveletOp wavelet operation to serialize
 * @return serialized protocol buffer wavelet operation
 */
public static ProtocolWaveletOperation serialize(WaveletOperation waveletOp) {
  ProtocolWaveletOperation.Builder protobufOp = ProtocolWaveletOperation.newBuilder();

  if (waveletOp instanceof NoOp) {
    protobufOp.setNoOp(true);
  } else if (waveletOp instanceof AddParticipant) {
    protobufOp.setAddParticipant(
        ((AddParticipant) waveletOp).getParticipantId().getAddress());
  } else if (waveletOp instanceof RemoveParticipant) {
    protobufOp.setRemoveParticipant(
        ((RemoveParticipant) waveletOp).getParticipantId().getAddress());
  } else if (waveletOp instanceof WaveletBlipOperation) {
    final WaveletBlipOperation wbOp = (WaveletBlipOperation) waveletOp;
    final ProtocolWaveletOperation.MutateDocument.Builder mutation =
      ProtocolWaveletOperation.MutateDocument.newBuilder();
    mutation.setDocumentId(wbOp.getBlipId());
    wbOp.getBlipOp().acceptVisitor(new BlipOperationVisitor() {
      @Override
      public void visitBlipContentOperation(BlipContentOperation blipOp) {
        mutation.setDocumentOperation(serialize(blipOp.getContentOp()));
      }

      @Override
      public void visitSubmitBlip(SubmitBlip op) {
        throw new IllegalArgumentException("Unsupported blip operation: " + wbOp.getBlipOp());
      }
    });
    protobufOp.setMutateDocument(mutation.build());
  } else {
    throw new IllegalArgumentException("Unsupported wavelet operation: " + waveletOp);
  }

  return protobufOp.build();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:41,代码来源:OperationSerializer.java

示例12: makeSegmentOperations

import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation; //导入依赖的package包/类
@Timed
static Map<SegmentId, SegmentOperation> makeSegmentOperations(WaveletDeltaRecord delta) {
  LoadingCache<SegmentId, ImmutableList.Builder<WaveletOperation>> builders = CacheBuilder.newBuilder().build(
    new CacheLoader<SegmentId, ImmutableList.Builder<WaveletOperation>>(){

    @Override
    public ImmutableList.Builder<WaveletOperation> load(SegmentId segmentId) {
      return ImmutableList.builder();
    }
  });
  Map<SegmentId, SegmentOperation> segmentOperations = CollectionUtils.newHashMap();
  for (WaveletOperation op : delta.getTransformedDelta()) {
    WaveletOperationContext newContext = makeSegmentContext(op.getContext(), delta.getResultingVersion().getVersion());
    if (op instanceof AddParticipant) {
      builders.getUnchecked(SegmentId.PARTICIPANTS_ID).add(
        new AddParticipant(newContext, ((AddParticipant)op).getParticipantId()));
    } else if (op instanceof RemoveParticipant) {
      builders.getUnchecked(SegmentId.PARTICIPANTS_ID).add(
        new RemoveParticipant(newContext, ((RemoveParticipant)op).getParticipantId()));
    } else if (op instanceof NoOp) {
      builders.getUnchecked(SegmentId.PARTICIPANTS_ID).add(new NoOp(newContext));
    } else {
      WaveletBlipOperation blipOp = (WaveletBlipOperation)op;
      BlipContentOperation blipContentOp = (BlipContentOperation)blipOp.getBlipOp();
      BlipContentOperation newBlipContentOp = new BlipContentOperation(newContext,
        blipContentOp.getContentOp(), blipContentOp.getContributorMethod());
      WaveletBlipOperation newBlipOp = new WaveletBlipOperation(blipOp.getBlipId(), newBlipContentOp);
      builders.getUnchecked(SegmentId.ofBlipId(blipOp.getBlipId())).add(newBlipOp);
    }
  }
  for (Entry<SegmentId, ImmutableList.Builder<WaveletOperation>> entry : builders.asMap().entrySet()) {
    segmentOperations.put(entry.getKey(), new SegmentOperationImpl(entry.getValue().build()));
  }
  return segmentOperations;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:36,代码来源:SegmentWaveletStateImpl.java

示例13: prepareOperation

import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation; //导入依赖的package包/类
private void prepareOperation(WaveletOperation op) {
  if (op instanceof AddParticipant) {
    log(3, "AddParticipant " + ((AddParticipant)op).getParticipantId().toString());
  } else if (op instanceof RemoveParticipant) {
    log(3, "RemoveParticipant " + ((RemoveParticipant)op).getParticipantId().toString());
  } else if (op instanceof WaveletBlipOperation) {
    WaveletBlipOperation waveletBlipOp = (WaveletBlipOperation) op;
    BlipOperation blipOp = waveletBlipOp.getBlipOp();
    if (blipOp instanceof BlipContentOperation) {
      DocOp docOp = ((BlipContentOperation) blipOp).getContentOp();
      log(3, "BlipId=" + waveletBlipOp.getBlipId() + ", Op=" + operationToString(docOp) +
          ", OpSize=" + docOp.size());
    }
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:16,代码来源:DeltaPreparator.java

示例14: serialize

import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation; //导入依赖的package包/类
public static DBObject serialize(WaveletOperation waveletOp) {
  final BasicDBObject mongoOp = new BasicDBObject();

  if (waveletOp instanceof NoOp) {
    mongoOp.append(FIELD_TYPE, WAVELET_OP_NOOP);

  } else if (waveletOp instanceof AddParticipant) {
    mongoOp.append(FIELD_TYPE, WAVELET_OP_ADD_PARTICIPANT);
    mongoOp.append(FIELD_PARTICIPANT, serialize(((AddParticipant) waveletOp).getParticipantId()));

  } else if (waveletOp instanceof RemoveParticipant) {
    mongoOp.append(FIELD_TYPE, WAVELET_OP_REMOVE_PARTICIPANT);
    mongoOp.append(FIELD_PARTICIPANT,
        serialize(((RemoveParticipant) waveletOp).getParticipantId()));
  } else if (waveletOp instanceof WaveletBlipOperation) {
    final WaveletBlipOperation waveletBlipOp = (WaveletBlipOperation) waveletOp;

    mongoOp.append(FIELD_TYPE, WAVELET_OP_WAVELET_BLIP_OPERATION);
    mongoOp.append(FIELD_BLIPID, waveletBlipOp.getBlipId());

    if (waveletBlipOp.getBlipOp() instanceof BlipContentOperation) {
      mongoOp.append(FIELD_BLIPOP, serialize((BlipContentOperation) waveletBlipOp.getBlipOp()));
    } else {
      throw new IllegalArgumentException("Unsupported blip operation: "
          + waveletBlipOp.getBlipOp());
    }
  } else {
    throw new IllegalArgumentException("Unsupported wavelet operation: " + waveletOp);
  }
  return mongoOp;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:32,代码来源:MongoDbStoreUtil.java

示例15: serializeOperation

import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation; //导入依赖的package包/类
private void serializeOperation(WaveletOperation operation, ProtoWaveletOperation serialized) {
  if (operation instanceof AddSegment) {
    serialized.setAddSegment(
      serializeOptionalSegmentId(((AddSegment)operation).getSegmentId()));
  } else if (operation instanceof RemoveSegment) {
    serialized.setRemoveSegment(
      serializeOptionalSegmentId(((RemoveSegment)operation).getSegmentId()));
  } else if (operation instanceof StartModifyingSegment) {
    serialized.setStartModifyingSegment(
      serializeOptionalSegmentId(((StartModifyingSegment)operation).getSegmentId()));
  } else if (operation instanceof EndModifyingSegment) {
    serialized.setEndModifyingSegment(
      serializeOptionalSegmentId(((EndModifyingSegment)operation).getSegmentId()));
  } else if (operation instanceof AddParticipant) {
    serialized.setAddParticipant(((AddParticipant)operation).getParticipantId().getAddress());
  } else if (operation instanceof RemoveParticipant) {
    serialized.setRemoveParticipant(((RemoveParticipant)operation).getParticipantId().getAddress());
  } else if (operation instanceof WaveletBlipOperation) {
    WaveletBlipOperation waveletOp = (WaveletBlipOperation)operation;
    BlipContentOperation blipOp = (BlipContentOperation)waveletOp.getBlipOp();
    switch (blipOp.getContributorMethod()) {
    case ADD:
      serialized.setAddDocumentContributor(true);
      break;
    case REMOVE:
      serialized.setRemoveDocumentContributor(true);
      break;
    }
    serialized.setDocumentOperation(operationSerializer.serialize(blipOp.getContentOp()));
  } else if (operation instanceof NoOp) {
    serialized.setNoOp(true);
  } else {
    throw new RuntimeException("Bad operation type");
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:36,代码来源:RawOperationSerializer.java


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