io.protostuff.Schema.typeClass()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中io.protostuff.Schema.typeClass()方法的一些代码示例,展示了Schema.typeClass()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Schema.typeClass()方法的具体详情如下:
包路径:io.protostuff.Schema
类名称:Schema
方法名:typeClass

Schema.typeClass介绍

[英]Gets the class of the message.
[中]获取消息的类。

代码示例

代码示例来源:origin: protostuff/protostuff

@Override
public Class<? super T> typeClass()
{
  return schema.typeClass();
}

代码示例来源:origin: protostuff/protostuff

@Override
protected void transferKey(Pipe pipe, Input input, Output output, int number,
    boolean repeated) throws IOException
{
  if (kPipeSchema == null)
  {
    throw new RuntimeException("No pipe schema for key: " +
        kSchema.typeClass().getName());
  }
  output.writeObject(number, pipe, kPipeSchema, repeated);
}

代码示例来源:origin: protostuff/protostuff

@Override
protected void transferValue(Pipe pipe, Input input, Output output, int number, boolean repeated)
    throws IOException
{
  if (pipeSchema == null)
  {
    throw new RuntimeException("No pipe schema for value: " +
        schema.typeClass().getName());
  }
  output.writeObject(number, pipe, pipeSchema, repeated);
}

代码示例来源:origin: protostuff/protostuff

@Override
protected void transferValue(Pipe pipe, Input input, Output output, int number,
    boolean repeated) throws IOException
{
  if (vPipeSchema == null)
  {
    throw new RuntimeException("No pipe schema for value: " +
        vSchema.typeClass().getName());
  }
  output.writeObject(number, pipe, vPipeSchema, repeated);
}

代码示例来源:origin: protostuff/protostuff

@Override
protected void transferValue(Pipe pipe, Input input, Output output, int number,
    boolean repeated) throws IOException
{
  if (vPipeSchema == null)
  {
    throw new RuntimeException("No pipe schema for value: " +
        vSchema.typeClass().getName());
  }
  output.writeObject(number, pipe, vPipeSchema, repeated);
}

代码示例来源:origin: protostuff/protostuff

/**
 * Pojo ids start at 1.
 */
@Override
public <T> Registry registerPojo(Schema<T> schema, Pipe.Schema<T> pipeSchema,
    int id)
{
  if (id >= strategy.pojoIdStart)
    throw new IllegalArgumentException("pojo ids must be lesser than " + strategy.pojoIdStart);
  else if (strategy.pojos.get(id) != null)
  {
    throw new IllegalArgumentException("Duplicate id registration: " + id +
        " (" + schema.typeClass().getName() + ")");
  }
  if (strategy.pojoMapping.containsKey(schema.typeClass()))
    throw new IllegalArgumentException("Duplicate registration for: " + schema.typeClass());
  Registered<T> wrapper = new Registered<T>(id, schema, pipeSchema, strategy);
  strategy.pojos.set(id, wrapper);
  strategy.pojoMapping.put(schema.typeClass(), wrapper);
  return this;
}

代码示例来源:origin: protostuff/protostuff

/**
 * Pojo ids start at 1.
 */
@Override
public <T> Registry registerPojo(Schema<T> schema, Pipe.Schema<T> pipeSchema,
    int id)
{
  if (id >= strategy.pojos.size())
    grow(strategy.pojos, id + 1);
  else if (strategy.pojos.get(id) != null)
  {
    throw new IllegalArgumentException("Duplicate id registration: " + id +
        " (" + schema.typeClass().getName() + ")");
  }
  if (strategy.pojoMapping.containsKey(schema.typeClass()))
    throw new IllegalArgumentException("Duplicate registration for: " + schema.typeClass());
  Registered<T> wrapper = new Registered<T>(id, schema, pipeSchema, strategy);
  strategy.pojos.set(id, wrapper);
  strategy.pojoMapping.put(schema.typeClass(), wrapper);
  return this;
}

代码示例来源:origin: protostuff/protostuff

@Override
  public Pipe.Schema<T> getPipeSchema()
  {
    Pipe.Schema<T> pipeSchema = this.pipeSchema;
    if (pipeSchema == null)
    {
      synchronized (this)
      {
        if ((pipeSchema = this.pipeSchema) == null)
        {
          this.pipeSchema = pipeSchema = RuntimeSchema
              .resolvePipeSchema(schema, schema.typeClass(),
                  true);
        }
      }
    }
    return pipeSchema;
  }
}

代码示例来源:origin: protostuff/protostuff

@Override
protected Class<?> pojoClass(int id)
{
  final BaseHS<?> wrapper = id < pojos.size() ? pojos.get(id) : null;
  if (wrapper == null)
    throw new UnknownTypeException("Unknown pojo id: " + id);
  return wrapper.getSchema().typeClass();
}

代码示例来源:origin: protostuff/protostuff

@Override
  public Pipe.Schema<T> getPipeSchema()
  {
    Pipe.Schema<T> pipeSchema = this.pipeSchema;
    if (pipeSchema == null)
    {
      synchronized (this)
      {
        if ((pipeSchema = this.pipeSchema) == null)
        {
          this.pipeSchema = pipeSchema = RuntimeSchema
              .resolvePipeSchema(schema, schema.typeClass(),
                  true);
        }
      }
    }
    return pipeSchema;
  }
}

代码示例来源:origin: protostuff/protostuff

@Override
protected Class<?> pojoClass(int id)
{
  final BaseHS<?> wrapper = id < pojos.size() ? pojos.get(id) : null;
  if (wrapper == null)
  {
    throw new UnknownTypeException("pojo id: " + id +
        " (Outdated registry)");
  }
  return wrapper.getSchema().typeClass();
}

代码示例来源:origin: protostuff/protostuff

@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.readInt32();
  Object[] array = (Object[])Array.newInstance(hs.getSchema().typeClass(), 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.mergeObject(null, hs.getSchema());
        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;
}

代码示例来源:origin: protostuff/protostuff

@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.readInt32();
  Object[] array = (Object[])Array.newInstance(hs.getSchema().typeClass(), 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.mergeObject(null, hs.getSchema());
        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;
}

代码示例来源:origin: io.protostuff/protostuff-collectionschema

@Override
protected void transferValue(Pipe pipe, Input input, Output output, int number,
    boolean repeated) throws IOException
{
  if (vPipeSchema == null)
  {
    throw new RuntimeException("No pipe schema for value: " +
        vSchema.typeClass().getName());
  }
  output.writeObject(number, pipe, vPipeSchema, repeated);
}

代码示例来源:origin: io.protostuff/protostuff-collectionschema

@Override
protected void transferKey(Pipe pipe, Input input, Output output, int number,
    boolean repeated) throws IOException
{
  if (kPipeSchema == null)
  {
    throw new RuntimeException("No pipe schema for key: " +
        kSchema.typeClass().getName());
  }
  output.writeObject(number, pipe, kPipeSchema, repeated);
}

代码示例来源:origin: dremio/dremio-oss

/**
 * Note: Not intended for direct use. Instead, use {@link ConnectionReader#of(ScanResult, SabotConfig)}
 */
ConnectionReaderImpl(ImmutableMap<String, Schema<? extends ConnectionConf<?, ?>>> schemaByName) {
 this.schemaByName = schemaByName;
 final ImmutableMap.Builder<String, Class<? extends ConnectionConf<?, ?>>> builder = ImmutableMap.builder();
 schemaByName.entrySet().stream()
  .forEach(entry -> builder.put(entry.getKey(), (Class<? extends ConnectionConf<?, ?>>) entry.getValue().typeClass()));
 this.connectionConfClasses = builder.build();
}

代码示例来源:origin: io.protostuff/protostuff-collectionschema

@Override
protected void transferValue(Pipe pipe, Input input, Output output, int number,
    boolean repeated) throws IOException
{
  if (vPipeSchema == null)
  {
    throw new RuntimeException("No pipe schema for value: " +
        vSchema.typeClass().getName());
  }
  output.writeObject(number, pipe, vPipeSchema, repeated);
}

代码示例来源:origin: io.protostuff/protostuff-collectionschema

@Override
protected void transferValue(Pipe pipe, Input input, Output output, int number, boolean repeated)
    throws IOException
{
  if (pipeSchema == null)
  {
    throw new RuntimeException("No pipe schema for value: " +
        schema.typeClass().getName());
  }
  output.writeObject(number, pipe, pipeSchema, repeated);
}

代码示例来源:origin: io.protostuff/protostuff-runtime-registry

@Override
protected Class<?> pojoClass(int id)
{
  final BaseHS<?> wrapper = id < pojos.size() ? pojos.get(id) : null;
  if (wrapper == null)
    throw new UnknownTypeException("Unknown pojo id: " + id);
  return wrapper.getSchema().typeClass();
}

代码示例来源:origin: io.protostuff/protostuff-runtime-registry

@Override
protected Class<?> pojoClass(int id)
{
  final BaseHS<?> wrapper = id < pojos.size() ? pojos.get(id) : null;
  if (wrapper == null)
  {
    throw new UnknownTypeException("pojo id: " + id +
        " (Outdated registry)");
  }
  return wrapper.getSchema().typeClass();
}

相关文章