congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ProtostuffException
Code IndexAdd Tabnine to your IDE (free)

How to use
ProtostuffException
in
io.protostuff

Best Java code snippets using io.protostuff.ProtostuffException (Showing top 20 results out of 315)

origin: protostuff/protostuff

@Override
public boolean readBool() throws IOException
{
  final int size = buffer[offset++] | (buffer[offset++] << 8);
  if (size != 1)
    throw new ProtostuffException("Not a valid kvp boolean");
  return buffer[offset++] != 0x30;
}
origin: protostuff/protostuff

@Override
public <T> T mergeObject(T value, Schema<T> schema) throws IOException
{
  throw new ProtostuffException("Unsupported.");
}
origin: protostuff/protostuff

@Override
public byte[] readByteArray() throws IOException
{
  final int size = buffer[offset++] | (buffer[offset++] << 8);
  if (size == 0)
    return ByteString.EMPTY_BYTE_ARRAY;
  if (offset + size > limit)
    throw new ProtostuffException("Misreported size.");
  byte[] data = new byte[size];
  System.arraycopy(buffer, offset, data, 0, size);
  offset += size;
  return data;
}
origin: protostuff/protostuff

@Override
public void readBytes(final ByteBuffer bb) throws IOException
{
  final int size = buffer[offset++] | (buffer[offset++] << 8);
  if (size == 0)
    bb.put(ByteString.EMPTY_BYTE_ARRAY);
  if (offset + size > limit)
    throw new ProtostuffException("Misreported size.");
  bb.put(buffer, offset, size);
  offset += size;
}
origin: protostuff/protostuff

@Override
public boolean readBool() throws IOException
{
  if (offset + 3 > limit && !readable(3))
    throw new ProtostuffException("Truncated message.");
  final int size = buffer[offset++] | (buffer[offset++] << 8);
  if (size != 1)
    throw new ProtostuffException("Invalid kvp boolean");
  return buffer[offset++] != 0x30;
}
origin: protostuff/protostuff

private byte[] fill(final byte[] data, int dataOffset, final int len)
    throws IOException
{
  final int existing = limit - offset;
  int toRead = len - existing, read = 0;
  if (existing != 0)
  {
    // copy existing
    System.arraycopy(buffer, offset, data, dataOffset, existing);
    dataOffset += existing;
  }
  // reset
  offset = 0;
  limit = 0;
  do
  {
    read = in.read(data, dataOffset, toRead);
    if (read == -1)
      throw new ProtostuffException("Truncated message.");
    dataOffset += read;
    toRead -= read;
  } while (toRead > 0);
  return data;
}
origin: protostuff/protostuff

@Override
public int readInt32() throws IOException
{
  final int size = buffer[offset++] | (buffer[offset++] << 8);
  if (size == 0)
    return 0;
  if (offset + size > limit)
    throw new ProtostuffException("Misreported size.");
  final int number = parseInt(buffer, offset, size, 10);
  offset += size;
  return number;
}
origin: protostuff/protostuff

@Override
public long readInt64() throws IOException
{
  final int size = buffer[offset++] | (buffer[offset++] << 8);
  if (size == 0)
    return 0;
  if (offset + size > limit)
    throw new ProtostuffException("Misreported size.");
  final long number = parseLong(buffer, offset, size, 10);
  offset += size;
  return number;
}
origin: protostuff/protostuff

@Override
public String readString() throws IOException
{
  final int size = buffer[offset++] | (buffer[offset++] << 8);
  if (size == 0)
    return ByteString.EMPTY_STRING;
  if (offset + size > limit)
    throw new ProtostuffException("Misreported size.");
  final String str = STRING.deser(buffer, offset, size);
  offset += size;
  return str;
}
origin: protostuff/protostuff

@Override
public <T> void handleUnknownField(int fieldNumber, Schema<T> schema) throws IOException
{
  if (offset + 2 > limit && !readable(2))
    throw new ProtostuffException("Truncated message.");
  final int size = buffer[offset++] | (buffer[offset++] << 8);
  if (offset + size > limit)
  {
    int toRead = size - (limit - offset), read = 0;
    // read until toRead
    do
    {
      read = in.read(buffer, 0, buffer.length);
      if (read == -1)
        throw new ProtostuffException("Truncated message.");
      toRead -= read;
    } while (toRead > 0);
    offset = read - (-toRead);
    limit = read;
    return;
  }
  offset += size;
}
origin: protostuff/protostuff

@Override
public byte[] readByteArray() throws IOException
{
  if (offset + 2 > limit && !readable(2))
    throw new ProtostuffException("Truncated message.");
  final int size = buffer[offset++] | (buffer[offset++] << 8);
  if (size == 0)
    return ByteString.EMPTY_BYTE_ARRAY;
  if (size > MAX_VALUE_SIZE)
    throw new ProtostuffException("Exceeded kvp max value size.");
  if (offset + size > limit)
    return fill(new byte[size], 0, size);
  final byte[] data = new byte[size];
  System.arraycopy(buffer, offset, data, 0, size);
  offset += size;
  return data;
}
origin: protostuff/protostuff

static Class<?> getArrayClass(Input input, Schema<?> schema,
    final Class<?> componentType) throws IOException
{
  if (input.readFieldNumber(schema) != ID_ARRAY_DIMENSION)
    throw new ProtostuffException("Corrupt input.");
  final int dimensions = input.readUInt32();
  // TODO is there another way (reflection) to obtain an array class?
  if (dimensions == 1)
    return Array.newInstance(componentType, 0).getClass();
  final int[] arg = new int[dimensions];
  arg[0] = 0;
  return Array.newInstance(componentType, arg).getClass();
}
origin: protostuff/protostuff

static Class<?> getArrayClass(Input input, Schema<?> schema,
    final Class<?> componentType) throws IOException
{
  if (input.readFieldNumber(schema) != ID_ARRAY_DIMENSION)
    throw new ProtostuffException("Corrupt input.");
  final int dimensions = input.readUInt32();
  // TODO is there another way (reflection) to obtain an array class?
  if (dimensions == 1)
    return Array.newInstance(componentType, 0).getClass();
  final int[] arg = new int[dimensions];
  arg[0] = 0;
  return Array.newInstance(componentType, arg).getClass();
}
origin: protostuff/protostuff

@Override
public void readBytes(final ByteBuffer bb) throws IOException
{
  if (offset + 2 > limit && !readable(2))
    throw new ProtostuffException("Truncated message.");
  final int size = buffer[offset++] | (buffer[offset++] << 8);
  if (size == 0)
  {
    bb.put(ByteString.EMPTY_BYTE_ARRAY);
    return;
  }
  if (size > MAX_VALUE_SIZE)
    throw new ProtostuffException("Exceeded kvp max value size.");
  if (offset + size > limit)
  {
    fill(bb.array(), 0, size);
  }
  bb.put(buffer, offset, size);
  offset += size;
}
origin: protostuff/protostuff

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, strategy);
  if (0 != input.readFieldNumber(pipeSchema.wrappedSchema))
    throw new ProtostuffException("Corrupt input.");
}
origin: protostuff/protostuff

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, strategy);
  if (0 != input.readFieldNumber(pipeSchema.wrappedSchema))
    throw new ProtostuffException("Corrupt input.");
}
origin: protostuff/protostuff

@Override
public int readInt32() throws IOException
{
  if (offset + 2 > limit && !readable(2))
    throw new ProtostuffException("Truncated message.");
  final int size = buffer[offset++] | (buffer[offset++] << 8);
  if (size == 0)
    return 0;
  if (offset + size > limit && !readable(size))
    throw new ProtostuffException("Truncated message.");
  final int number = parseInt(buffer, offset, size, 10);
  offset += size;
  return number;
}
origin: protostuff/protostuff

@Override
public long readInt64() throws IOException
{
  if (offset + 2 > limit && !readable(2))
    throw new ProtostuffException("Truncated message.");
  final int size = buffer[offset++] | (buffer[offset++] << 8);
  if (size == 0)
    return 0;
  if (offset + size > limit && !readable(size))
    throw new ProtostuffException("Truncated message.");
  final long number = parseLong(buffer, offset, size, 10);
  offset += size;
  return number;
}
origin: protostuff/protostuff

static Object readObjectFrom(Input input, Schema<?> schema, Object owner,
    IdStrategy strategy) throws IOException
{
  final int number = input.readFieldNumber(schema);
  if (number != ID_THROWABLE)
    throw new ProtostuffException("Corrupt input.");
  return readObjectFrom(input, schema, owner, strategy, number);
}
origin: protostuff/protostuff

static void transferObject(Pipe.Schema<Object> pipeSchema, Pipe pipe,
    Input input, Output output, IdStrategy strategy) throws IOException
{
  final int number = input.readFieldNumber(pipeSchema.wrappedSchema);
  if (number != ID_POJO)
    throw new ProtostuffException("Corrupt input.");
  
  transferObject(pipeSchema, pipe, input, output, strategy, number);
}

io.protostuffProtostuffException

Javadoc

The base io exception for all formats (protobuf/json/xml).

Most used methods

  • <init>
  • getMessage

Popular in Java

  • Creating JSON documents from java classes using gson
  • setRequestProperty (URLConnection)
  • compareTo (BigDecimal)
  • setContentView (Activity)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now