- java.lang.Object
-
- org.deepsymmetry.beatlink.dbserver.Field
-
- Direct Known Subclasses:
BinaryField,NumberField,StringField
@API(status=STABLE) public abstract class Field extends Object
All dbserver messages are made up of lists of fields, which are type-tagged values.- Author:
- James Elliott
-
-
Constructor Summary
Constructors Constructor Description Field()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract bytegetArgumentTag()Get the value which identifies this type of field in a message argument list.abstract ByteBuffergetBytes()Get the bytes which represent this field when sent over the network, including the leading type tag.abstract longgetSize()Get the size, in bytes, of the network representation of this field, excluding the leading type tag and length bytes (if any).abstract bytegetTypeTag()Get the value which identifies the start of this field in the network stream.static Fieldread(DataInputStream is)Read a field from the supplied stream, starting with the tag that identifies the type, and reading enough to collect the corresponding value.voidwrite(WritableByteChannel channel)Write the field to the specified channel.
-
-
-
Method Detail
-
getBytes
@API(status=STABLE) public abstract ByteBuffer getBytes()
Get the bytes which represent this field when sent over the network, including the leading type tag.- Returns:
- a freshly rewound buffer containing the full set of bytes which should be transmitted for this field.
-
getSize
@API(status=STABLE) public abstract long getSize()
Get the size, in bytes, of the network representation of this field, excluding the leading type tag and length bytes (if any).- Returns:
- the number of bytes which will be written after the type tag (and length indicator, if present) when sending this field.
-
getTypeTag
@API(status=STABLE) public abstract byte getTypeTag()
Get the value which identifies the start of this field in the network stream.- Returns:
- the tag which tells the recipient that this particular type of field is coming.
-
getArgumentTag
@API(status=STABLE) public abstract byte getArgumentTag()
Get the value which identifies this type of field in a message argument list.- Returns:
- the tag which is used instead of the type tag for some reason when putting together the argument type list for a dbserver message.
-
read
@API(status=STABLE) public static Field read(DataInputStream is) throws IOException
Read a field from the supplied stream, starting with the tag that identifies the type, and reading enough to collect the corresponding value.- Parameters:
is- the stream on which a type tag is expected to be the next byte, followed by the field value.- Returns:
- the field that was found on the stream.
- Throws:
IOException- if there is a problem reading the field.
-
write
@API(status=STABLE) public void write(WritableByteChannel channel) throws IOException
Write the field to the specified channel.- Parameters:
channel- the channel to which it should be written- Throws:
IOException- if there is a problem writing to the channel
-
-