本文整理汇总了Java中io.protostuff.Input类的典型用法代码示例。如果您正苦于以下问题:Java Input类的具体用法?Java Input怎么用?Java Input使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Input类属于io.protostuff包,在下文中一共展示了Input类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testReadRequestHeader
import io.protostuff.Input; //导入依赖的package包/类
@Test
public void testReadRequestHeader() {
boolean status = true;
try {
new MockUp<NotWrapSchema>() {
@Mock
public Object readObject(Input input) throws IOException {
return new RequestHeader();
}
};
bodyBuffer = Buffer.buffer("\"abc\"");
RequestHeader requestHeader = HighwayCodec.readRequestHeader(bodyBuffer, null);
Assert.assertNotNull(requestHeader);
Assert.assertEquals(0, requestHeader.getFlags());
} catch (Exception e) {
status = false;
}
Assert.assertTrue(status);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:20,代码来源:TestHighwayCodec.java
示例2: readObject
import io.protostuff.Input; //导入依赖的package包/类
@SuppressWarnings("unchecked")
default <T> T readObject(Buffer buffer, ProtobufFeature protobufFeature) throws Exception {
if (buffer == null || buffer.length() == 0) {
// void以及函数入参为null的场景
// 空串时,protobuf至少为编码为1字节
return (T) readFromEmpty();
}
ByteBuffer nioBuffer = buffer.getByteBuf().nioBuffer();
Input input = new ByteBufferInput(nioBuffer, false);
ProtobufFeatureUtils.setProtobufFeature(protobufFeature);
try {
return (T) readObject(input);
} finally {
ProtobufFeatureUtils.removeProtobufFeature();
}
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:19,代码来源:WrapSchema.java
示例3: testReadObject
import io.protostuff.Input; //导入依赖的package包/类
@Test
public void testReadObject() {
boolean status = true;
Input input = null;
String[] stringArray = new String[1];
stringArray[0] = "abc";
MultiWrapper multiWrapper = Mockito.mock(MultiWrapper.class);
Mockito.when(schema.newMessage()).thenReturn(multiWrapper);
try {
Object object = argsWrapSchema.readObject(input);
Assert.assertNull(object);
} catch (IOException e) {
status = true;
}
Assert.assertTrue(status);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:18,代码来源:TestArgsWrapSchema.java
示例4: deserializeObject
import io.protostuff.Input; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Object deserializeObject(Buffer buffer) {
Input input = new ZeroCopyBufferInput(buffer, true);
byte type = buffer.readByte();
Schema<Object> schema;
if (type == CRC32_TYPE) {
long crc = buffer.readLong();
schema = (Schema<Object>) registeredCrc.get(crc).schema;
} else {
schema = (Schema<Object>) registeredSha1.get(buffer, SHA1_DIGEST_SIZE).schema;
}
int size = buffer.readInt();
Object message = schema.newMessage();
try {
buffer.limitNext(size);
schema.mergeFrom(input, message);
buffer.resetNextLimit();
} catch (Exception e) {
throw new RuntimeException(e);
}
return message;
}
开发者ID:dmart28,项目名称:reveno,代码行数:23,代码来源:ProtostuffSerializer.java
示例5: readPrimitiveFrom
import io.protostuff.Input; //导入依赖的package包/类
protected Object readPrimitiveFrom(Input input, Object owner, int len)
throws IOException
{
long[] array = new long[len];
if (input instanceof GraphInput)
{
// update the actual reference.
((GraphInput) input).updateLast(array, owner);
}
for (int i = 0; i < len; i++)
{
if (ID_ARRAY_DATA != input.readFieldNumber(this))
throw new ProtostuffException("Corrupt input.");
array[i] = input.readInt64();
}
if (0 != input.readFieldNumber(this))
throw new ProtostuffException("Corrupt input.");
return array;
}
开发者ID:protostuff,项目名称:protostuff,代码行数:24,代码来源:ArraySchemas.java
示例6: transferDelegateId
import io.protostuff.Input; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected <T> HasDelegate<T> transferDelegateId(Input input, Output output,
int fieldNumber) throws IOException
{
final String className = input.readString();
final HasDelegate<T> hd = (HasDelegate<T>) delegateMapping
.get(className);
if (hd == null)
throw new UnknownTypeException("delegate: " + className
+ " (Outdated registry)");
output.writeString(fieldNumber, className, false);
return hd;
}
开发者ID:BFergerson,项目名称:Beam,代码行数:18,代码来源:DefaultIdStrategy.java
示例7: readObjectFrom
import io.protostuff.Input; //导入依赖的package包/类
static Object readObjectFrom(Input input, Schema<?> schema, Object owner,
IdStrategy strategy) throws IOException
{
if (ID_ENUM != input.readFieldNumber(schema))
throw new ProtostuffException("Corrupt input.");
final EnumIO<?> eio = strategy.resolveEnumFrom(input);
if (ID_ENUM_VALUE != input.readFieldNumber(schema))
throw new ProtostuffException("Corrupt input.");
final Object value = eio.readFrom(input);
if (input instanceof GraphInput)
{
// update the actual reference.
((GraphInput) input).updateLast(value, owner);
}
if (0 != input.readFieldNumber(schema))
throw new ProtostuffException("Corrupt input.");
return value;
}
开发者ID:BFergerson,项目名称:Beam,代码行数:25,代码来源:PolymorphicEnumSchema.java
示例8: transferObject
import io.protostuff.Input; //导入依赖的package包/类
static void transferObject(Pipe.Schema<Object> pipeSchema, Pipe pipe,
Input input, Output output, IdStrategy strategy) throws IOException
{
if (ID_ENUM != input.readFieldNumber(pipeSchema.wrappedSchema))
throw new ProtostuffException("Corrupt input.");
strategy.transferEnumId(input, output, ID_ENUM);
if (ID_ENUM_VALUE != input.readFieldNumber(pipeSchema.wrappedSchema))
throw new ProtostuffException("Corrupt input.");
EnumIO.transfer(pipe, input, output, 1, false);
if (0 != input.readFieldNumber(pipeSchema.wrappedSchema))
throw new ProtostuffException("Corrupt input.");
}
开发者ID:BFergerson,项目名称:Beam,代码行数:17,代码来源:PolymorphicEnumSchema.java
示例9: transferPojoId
import io.protostuff.Input; //导入依赖的package包/类
@Override
protected <T> HasSchema<T> transferPojoId(Input input, Output output,
int fieldNumber) throws IOException
{
final String className = input.readString();
final HasSchema<T> wrapper = getSchemaWrapper(className,
0 != (AUTO_LOAD_POLYMORPHIC_CLASSES & flags));
if (wrapper == null)
{
throw new ProtostuffException("polymorphic pojo not registered: "
+ className);
}
output.writeString(fieldNumber, className, false);
return wrapper;
}
开发者ID:protostuff,项目名称:protostuff,代码行数:19,代码来源:DefaultIdStrategy.java
示例10: resolveMapFrom
import io.protostuff.Input; //导入依赖的package包/类
@Override
protected MapSchema.MessageFactory resolveMapFrom(Input input)
throws IOException
{
final String className = input.readString();
MapSchema.MessageFactory factory = mapMapping.get(className);
if (factory == null)
{
if (className.indexOf('.') == -1)
{
factory = MapSchema.MessageFactories.valueOf(className);
}
else
{
factory = new RuntimeMapFactory(RuntimeEnv.loadClass(className));
MapSchema.MessageFactory f = mapMapping.putIfAbsent(className,
factory);
if (f != null)
factory = f;
}
}
return factory;
}
开发者ID:protostuff,项目名称:protostuff,代码行数:25,代码来源:DefaultIdStrategy.java
示例11: object
import io.protostuff.Input; //导入依赖的package包/类
@Test
public void object() throws Exception {
WrapSchema schema = ProtobufSchemaUtils.getOrCreateSchema(Object.class);
LinkedBuffer linkedBuf = LinkedBuffer.allocate();
ProtobufOutput output = new ProtobufOutput(linkedBuf);
schema.writeObject(output, 1);
Input input = new ByteArrayInput(output.toByteArray(), false);
Object result = schema.readObject(input);
Assert.assertEquals(1, result);
Assert.assertThat(result, Matchers.instanceOf(Integer.class));
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:15,代码来源:TestProtobufSchemaUtils.java
示例12: testReadObject
import io.protostuff.Input; //导入依赖的package包/类
@Test
public void testReadObject() {
boolean status = true;
Input input = null;
try {
Object object = argsNotWrapSchema.readObject(input);
Assert.assertNotNull(object);
// object is created but no values inside to assert
} catch (Exception e) {
status = false;
}
Assert.assertTrue(status);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:14,代码来源:TestArgsNotWrapSchema.java
示例13: mergeFrom
import io.protostuff.Input; //导入依赖的package包/类
@Override
public void mergeFrom(Input input, Foo message) throws IOException {
for (int number = input.readFieldNumber(this);; number = input.readFieldNumber(this)) {
switch (number) {
case 0:
return;
case 1:
message.bar = input.readDouble();
break;
default:
input.handleUnknownField(number, this);
}
}
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:15,代码来源:TestProtostuffUtils.java
示例14: deserialize
import io.protostuff.Input; //导入依赖的package包/类
@Override
public RepositoryData deserialize(Buffer buffer) {
changeClassLoaderIfRequired();
// TODO unnecessary allocation
Input input = new ZeroCopyBufferInput(buffer, true);
RepositoryData repoData = repoSchema.newMessage();
try {
repoSchema.mergeFrom(input, repoData);
} catch (IOException e) {
throw new RuntimeException(e);
}
return repoData;
}
开发者ID:dmart28,项目名称:reveno,代码行数:15,代码来源:ProtostuffSerializer.java
示例15: transferClassId
import io.protostuff.Input; //导入依赖的package包/类
@Override
protected void transferClassId(Input input, Output output, int fieldNumber,
boolean mapped, boolean array) throws IOException
{
if (mapped)
input.transferByteRangeTo(output, true, fieldNumber, false);
else
output.writeUInt32(fieldNumber, input.readUInt32(), false);
}
开发者ID:protostuff,项目名称:protostuff,代码行数:10,代码来源:NumericIdStrategy.java
示例16: transfer
import io.protostuff.Input; //导入依赖的package包/类
@Override
protected void transfer(Pipe pipe, Input input, Output output)
throws IOException
{
transferObject(this, pipe, input, output, strategy,
RuntimeFieldFactory.SHORT);
}
开发者ID:BFergerson,项目名称:Beam,代码行数:8,代码来源:ArraySchemas.java
示例17: readFrom
import io.protostuff.Input; //导入依赖的package包/类
@Override
public Object readFrom(Input input, Object owner) throws IOException
{
if (ID_ARRAY_LEN != input.readFieldNumber(this))
throw new ProtostuffException("Corrupt input.");
final int len = input.readUInt32();
String[] array = new String[len];
if (input instanceof GraphInput)
{
// update the actual reference.
((GraphInput) input).updateLast(array, owner);
}
for (int i = 0; i < len;)
{
switch (input.readFieldNumber(this))
{
case ID_ARRAY_DATA:
array[i++] = input.readString();
break;
case ID_ARRAY_NULLCOUNT:
i += input.readUInt32();
break;
default:
throw new ProtostuffException("Corrupt input.");
}
}
if (0 != input.readFieldNumber(this))
throw new ProtostuffException("Corrupt input.");
return array;
}
开发者ID:BFergerson,项目名称:Beam,代码行数:36,代码来源:ArraySchemas.java
示例18: transfer
import io.protostuff.Input; //导入依赖的package包/类
@Override
protected void transfer(Pipe pipe, Input input, Output output)
throws IOException
{
transferObject(this, pipe, input, output, strategy,
RuntimeFieldFactory.BIGINTEGER);
}
开发者ID:protostuff,项目名称:protostuff,代码行数:8,代码来源:ArraySchemas.java
示例19: resolvePojoFrom
import io.protostuff.Input; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected <T> HasSchema<T> resolvePojoFrom(Input input, int fieldNumber)
throws IOException
{
final int id = input.readUInt32();
final BaseHS<T> wrapper = id < pojos.size() ? (BaseHS<T>) pojos.get(id) : null;
if (wrapper == null)
throw new UnknownTypeException("pojo id: " + id + " (Outdated registry)");
return wrapper;
}
开发者ID:protostuff,项目名称:protostuff,代码行数:14,代码来源:ExplicitIdStrategy.java
示例20: transfer
import io.protostuff.Input; //导入依赖的package包/类
/**
* Transfers the {@link Enum} from the input to the output.
*/
public static void transfer(Pipe pipe, Input input, Output output,
int number, boolean repeated) throws IOException
{
if (ENUMS_BY_NAME)
input.transferByteRangeTo(output, true, number, repeated);
else
output.writeEnum(number, input.readEnum(), repeated);
}
开发者ID:BFergerson,项目名称:Beam,代码行数:12,代码来源:EnumIO.java
注:本文中的io.protostuff.Input类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论