org.apache.kafka.common.protocol.types
Class Schema

java.lang.Object
  extended by org.apache.kafka.common.protocol.types.Type
      extended by org.apache.kafka.common.protocol.types.Schema

public class Schema
extends Type

The schema for a compound record definition


Field Summary
 
Fields inherited from class org.apache.kafka.common.protocol.types.Type
BYTES, INT16, INT32, INT64, INT8, STRING
 
Constructor Summary
Schema(Field... fs)
           
 
Method Summary
 Field[] fields()
          Get all the fields in this schema
 Field get(int slot)
          Get a field by its slot in the record array
 Field get(java.lang.String name)
          Get a field by its name
 int numFields()
          The number of fields in this schema
 java.lang.Object read(java.nio.ByteBuffer buffer)
          Read a struct from the buffer
 int sizeOf(java.lang.Object o)
          The size of the given record
 java.lang.String toString()
          Display a string representation of the schema
 Struct validate(java.lang.Object item)
           
 void write(java.nio.ByteBuffer buffer, java.lang.Object o)
          Write a struct to the buffer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Schema

public Schema(Field... fs)
Method Detail

write

public void write(java.nio.ByteBuffer buffer,
                  java.lang.Object o)
Write a struct to the buffer

Specified by:
write in class Type

read

public java.lang.Object read(java.nio.ByteBuffer buffer)
Read a struct from the buffer

Specified by:
read in class Type

sizeOf

public int sizeOf(java.lang.Object o)
The size of the given record

Specified by:
sizeOf in class Type

numFields

public int numFields()
The number of fields in this schema


get

public Field get(int slot)
Get a field by its slot in the record array

Parameters:
slot - The slot at which this field sits
Returns:
The field

get

public Field get(java.lang.String name)
Get a field by its name

Parameters:
name - The name of the field
Returns:
The field

fields

public Field[] fields()
Get all the fields in this schema


toString

public java.lang.String toString()
Display a string representation of the schema

Overrides:
toString in class java.lang.Object

validate

public Struct validate(java.lang.Object item)
Specified by:
validate in class Type