de.aitools.aq.invertedindex.value
Interface Value

All Known Implementing Classes:
ByteString, FloatFloat, FloatFloatFloat, FloatInt, FloatIntFloat, FloatIntInt, FloatLong, FloatString, IntFloat, IntFloatFloat, IntInt, IntIntFloat, IntIntInt, IntIntIntInt, IntLong, IntString, LongFloat, LongFloatFloat, LongFloatLongInt, LongInt, LongIntFloat, LongIntInt, LongLong, LongLongFloatFloat, LongLongIntInt, LongLongLongLong, LongString, ShortFloat, ShortFloatFloat, ShortInt, ShortIntFloat, ShortIntInt, ShortLong, ShortString, SingleByte, SingleFloat, SingleInt, SingleLong, SingleShort, SingleString, StringString

public interface Value

The interface of an index value type. Classes that implement this interface have to override the methods Object.hashCode() and Object.equals(Object) as well.

Version:
$Id: Value.java,v 1.3 2010/10/15 15:30:15 trenkman Exp $
Author:
martin.trenkmann@uni-weimar.de

Nested Class Summary
static class Value.Check
           
static class Value.InvalidArgumentException
           
 
Field Summary
static char SEPARATOR
           
 
Method Summary
 int byteSize()
          Returns the serialized size of this value.
 TokenStream parseFrom(TokenStream input)
          Parses all elements from a TokenStream.
 java.io.PrintStream printTo(java.io.PrintStream output)
          Prints all elements to a .
 java.io.PrintWriter printTo(java.io.PrintWriter output)
          Prints all elements to a .
 void toBytes(java.nio.ByteBuffer buffer)
          Serializes all elements into a ByteBuffer.
 void wrap(java.nio.ByteBuffer buffer)
          Deserializes the value from a ByteBuffer.
 

Field Detail

SEPARATOR

static final char SEPARATOR
See Also:
Constant Field Values
Method Detail

parseFrom

TokenStream parseFrom(TokenStream input)
                      throws java.io.IOException
Parses all elements from a TokenStream.

Parameters:
input - the token stream to read the value from.
Returns:
the given token stream.
Throws:
java.io.IOException

printTo

java.io.PrintWriter printTo(java.io.PrintWriter output)
Prints all elements to a . The content printed to the writer is equivalent to the string returned by #toString(), but for serialization purposes this method is much faster since no temporal variables are needed.

Parameters:
output - the print writer to write the value to.
Returns:
the given print writer.

printTo

java.io.PrintStream printTo(java.io.PrintStream output)
Prints all elements to a . The content printed to the stream is equivalent to the string returned by #toString(), but for serialization purposes this method is much faster since no temporal variables are needed.

Parameters:
output - the print stream to write the value to.
Returns:
the given print stream.

byteSize

int byteSize()
Returns the serialized size of this value. The return value must be equivalent to the number of bytes written to the ByteBuffer when calling toBytes(ByteBuffer).

Returns:
the serialized value size in byte.
See Also:
wrap(ByteBuffer), toBytes(ByteBuffer)

toBytes

void toBytes(java.nio.ByteBuffer buffer)
Serializes all elements into a ByteBuffer. Note that the given buffer has the correct ByteOrder, which is by default, but has to be ByteOrder.LITTLE_ENDIAN on Intel machines because of JNI. TODO check automatic buffer resizing if possible ... otherwise there has to be a precondition: buffer.capacity() >= size()

Parameters:
buffer - a byte buffer to serialize the value to.
See Also:
wrap(ByteBuffer)

wrap

void wrap(java.nio.ByteBuffer buffer)
Deserializes the value from a ByteBuffer. All elements of this value are read from the current get position.

Parameters:
buffer - a byte buffer that contains all elements of this value.
See Also:
toBytes(ByteBuffer)