本文整理匯總了Java中org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta.Builder方法的典型用法代碼示例。如果您正苦於以下問題:Java ProtocolWaveletDelta.Builder方法的具體用法?Java ProtocolWaveletDelta.Builder怎麽用?Java ProtocolWaveletDelta.Builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta
的用法示例。
在下文中一共展示了ProtocolWaveletDelta.Builder方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convertDelta
import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //導入方法依賴的package包/類
/**
* Replaces domain in deltas for Add/Remove participant operations.
*
* @param delta source delta
* @param waveDomain target wave domain
* @return delta for waveDomain if WaveDoamin is not null, otherwise source delta.
* @throws InvalidParticipantAddress if there is a problem with deserialization of participant id.
*/
public static ProtocolWaveletDelta convertDelta(ProtocolWaveletDelta delta,
String waveDomain) throws InvalidParticipantAddress {
if (waveDomain != null) {
ProtocolWaveletDelta.Builder newDelta = ProtocolWaveletDelta.newBuilder(delta);
ParticipantId author = convertParticipantId(delta.getAuthor(), waveDomain);
newDelta.setAuthor(author.getAddress());
for (int i = 0; i < delta.getOperationCount(); i++) {
ProtocolWaveletOperation op = delta.getOperation(i);
ProtocolWaveletOperation.Builder newOp = ProtocolWaveletOperation.newBuilder(op);
if (op.hasAddParticipant()) {
convertAddParticipantOperation(newOp, op, waveDomain);
} else if (op.hasRemoveParticipant()) {
convertRemoveParticipantOperation(newOp, op, waveDomain);
}
// TODO(user) release convert for other operations.
newDelta.setOperation(i, newOp);
}
return newDelta.build();
} else {
return delta;
}
}
示例2: serialize
import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //導入方法依賴的package包/類
/**
* Serializes an untransformed delta as a {@link ProtocolWaveletDelta}.
*
* @param delta to serialize
* @return serialized protocol buffer wavelet delta
*/
public static ProtocolWaveletDelta serialize(WaveletDelta delta) {
ProtocolWaveletDelta.Builder protobufDelta = ProtocolWaveletDelta.newBuilder();
for (WaveletOperation waveletOp : delta) {
protobufDelta.addOperation(serialize(waveletOp));
}
protobufDelta.setAuthor(delta.getAuthor().getAddress());
protobufDelta.setHashedVersion(serialize(delta.getTargetVersion()));
return protobufDelta.build();
}
示例3: setVersionHash
import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; //導入方法依賴的package包/類
/**
* Sets correct version hash to delta.
*
* @param delta the source delta.
* @param waveletSnapshot to append delta.
* @param waveletName name of wavelet.
* @return the delta to import.
* @throws InvalidParticipantAddress deserialize of participant error.
*/
ProtocolWaveletDelta setVersionHash(ProtocolWaveletDelta delta,
HashedVersion currentVersion, WaveletName waveletName) throws InvalidParticipantAddress {
ProtocolWaveletDelta.Builder newDelta = ProtocolWaveletDelta.newBuilder(delta);
ProtocolHashedVersion ver = ProtocolHashedVersion.newBuilder(delta.getHashedVersion()).
setHistoryHash(ByteString.copyFrom(currentVersion.getHistoryHash())).
build();
newDelta.setHashedVersion(ver);
return newDelta.build();
}