本文整理汇总了Java中com.google.protobuf.InvalidProtocolBufferException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java InvalidProtocolBufferException.printStackTrace方法的具体用法?Java InvalidProtocolBufferException.printStackTrace怎么用?Java InvalidProtocolBufferException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protobuf.InvalidProtocolBufferException
的用法示例。
在下文中一共展示了InvalidProtocolBufferException.printStackTrace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unpackByteArrayPacket
import com.google.protobuf.InvalidProtocolBufferException; //导入方法依赖的package包/类
@Override
public IObject unpackByteArrayPacket(ByteArrayPacket byteArrayPacket) {
int opCode = byteArrayPacket.getOpCode();
IObject cObject = CObject.newInstance();
switch (SystemRequest.get(opCode)) {
case USER_LOGIN_PB:
try {
PBSystem.CS_USER_CONNECT_TO_SERVER login = PBSystem.CS_USER_CONNECT_TO_SERVER.parseFrom(byteArrayPacket.getRawData());
String name = login.getName();
String params = login.getParams();
cObject.putUtfString("name", name);
cObject.putUtfString("params", params);
return cObject;
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
break;
default:
break;
}
return cObject;
}
示例2: valueToString
import com.google.protobuf.InvalidProtocolBufferException; //导入方法依赖的package包/类
@Nullable
private String valueToString(Value v) throws IOException {
if (strictCast() && !v.getValueTypeCase().equals(ValueTypeCase.STRING_VALUE)) {
return null;
}
switch (v.getValueTypeCase()) {
case STRING_VALUE:
return v.getStringValue();
case INTEGER_VALUE:
return Long.toString(v.getIntegerValue());
case DOUBLE_VALUE:
return Double.toString(v.getDoubleValue());
case BOOLEAN_VALUE:
return Boolean.toString(v.getBooleanValue());
case TIMESTAMP_VALUE:
return valueToTimestamp(v);
case NULL_VALUE:
return null;
case BLOB_VALUE:
return valueToBytes(v);
case ARRAY_VALUE:
ArrayList<String> arr = new ArrayList<>();
for (Value av: v.getArrayValue().getValuesList()) {
arr.add(valueToString(av));
}
return Transport.getJsonFactory().toString(arr);
case ENTITY_VALUE:
try {
return JsonFormat.printer()
.usingTypeRegistry(TypeRegistry.newBuilder()
.add(Entity.getDescriptor())
.build())
.omittingInsignificantWhitespace()
.print(v.getEntityValue());
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
return null;
}
case GEO_POINT_VALUE:
return valueToGeopoint(v);
case KEY_VALUE:
return keyToString(v.getKeyValue());
default:
throw new IllegalArgumentException(
"ValueType Case not handled: " + v.getValueTypeCase());
}
}
示例3: collect
import com.google.protobuf.InvalidProtocolBufferException; //导入方法依赖的package包/类
@Override
public StreamObserver<UpstreamSegment> collect(final StreamObserver<Downstream> responseObserver) {
return new StreamObserver<UpstreamSegment>() {
public void onNext(UpstreamSegment value) {
try {
TraceSegmentObject traceSegmentObject = TraceSegmentObject.parseFrom(value.getSegment());
Segment.SegmentBuilder segmentBuilder = Segment.SegmentBuilder.newBuilder(traceSegmentObject.getTraceSegmentId());
logger.debug("Receive segment: Application[{}], TraceSegmentId[{}]",
traceSegmentObject.getApplicationId(),
traceSegmentObject.getTraceSegmentId());
for (SpanObject spanObject : traceSegmentObject.getSpansList()) {
Segment.SpanBuilder spanBuilder = Segment.SpanBuilder.newBuilder(spanObject.getOperationName()).parentSpanId(spanObject.getParentSpanId())
.spanId(spanObject.getSpanId()).componentId(spanObject.getComponentId()).componentName(spanObject.getComponent())
.spanLayer(spanObject.getSpanLayer().toString()).endTime(spanObject.getEndTime())
.startTime(spanObject.getStartTime()).spanType(spanObject.getSpanType().toString())
.peer(spanObject.getPeer()).peerId(spanObject.getPeerId()).operationId(spanObject.getOperationNameId());
for (LogMessage logMessage : spanObject.getLogsList()) {
spanBuilder.logEvent(logMessage.getDataList());
}
for (KeyWithStringValue tags : spanObject.getTagsList()) {
spanBuilder.tags(tags.getKey(), tags.getValue());
}
segmentBuilder.addSpan(spanBuilder.build());
}
for (TraceSegmentReference ref : traceSegmentObject.getRefsList()) {
Segment.SegmentRef segmentRef = Segment.SegmentRefBuilder.newBuilder(ref).build();
segmentBuilder.addRefs(segmentRef);
}
ValidateData.INSTANCE.getSegmentItem().addSegmentItem(traceSegmentObject.getApplicationId(), segmentBuilder.build());
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
}
public void onError(Throwable t) {
}
public void onCompleted() {
responseObserver.onNext(Downstream.getDefaultInstance());
responseObserver.onCompleted();
}
};
}