de.aitools.aq.invertedindex.core
Class Record<E extends Value>

java.lang.Object
  extended by de.aitools.aq.invertedindex.core.Record<E>

public class Record<E extends Value>
extends java.lang.Object

A class to represent key-value-pair. The key is a string, the value some specialization of Value.

Version:
$Id: Record.java,v 1.3 2011/02/15 10:32:43 hoppe Exp $
Author:
martin.trenkmann@uni-weimar.de

Field Summary
static java.lang.String EMPTY_KEY
           
static char SEPARATOR
           
 
Constructor Summary
Record(java.lang.Class<E> clazz)
          The default constructor.
Record(Record<E> record)
          The copy constructor.
Record(java.lang.String key, E value)
          The explicit constructor.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.lang.String getKey()
          Gets the key of this record.
 E getValue()
          Get the value of the record.
 int hashCode()
           
 void parseFrom(TokenStream in)
          Parses all elements from a token stream.
 java.io.PrintStream printTo(java.io.PrintStream out)
           
 java.io.PrintWriter printTo(java.io.PrintWriter out)
          Prints all elements to an output stream.
 void set(java.lang.String key, E value)
          Sets both the key and the value at once.
 void setKey(java.lang.String key)
          Sets the key of this record.
 void setValue(E value)
          Sets the value of this record.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_KEY

public static final java.lang.String EMPTY_KEY
See Also:
Constant Field Values

SEPARATOR

public static final char SEPARATOR
See Also:
Constant Field Values
Constructor Detail

Record

public Record(java.lang.Class<E> clazz)
The default constructor.

Parameters:
clazz - the type information about the value class.
Throws:
java.lang.IllegalAccessException
java.lang.InstantiationException

Record

public Record(java.lang.String key,
              E value)
       throws Value.InvalidArgumentException
The explicit constructor.

Parameters:
key - the key as string.
value - the value as a typed postlist entry.
Throws:
Value.InvalidArgumentException - if key is empty or contains any whitespace character.

Record

public Record(Record<E> record)
The copy constructor.

Parameters:
record - the record to initialize this record.
Method Detail

getKey

public java.lang.String getKey()
Gets the key of this record.


getValue

public E getValue()
Get the value of the record.


parseFrom

public void parseFrom(TokenStream in)
               throws java.io.IOException
Parses all elements from a token stream.

Throws:
java.io.IOException

printTo

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


printTo

public java.io.PrintStream printTo(java.io.PrintStream out)

setKey

public void setKey(java.lang.String key)
            throws Value.InvalidArgumentException
Sets the key of this record.

Parameters:
key - the key as string.
Throws:
Value.InvalidArgumentException - if key is empty or contains any whitespace character.

setValue

public void setValue(E value)
Sets the value of this record.

Parameters:
value - the value of this record.

set

public void set(java.lang.String key,
                E value)
         throws Value.InvalidArgumentException
Sets both the key and the value at once.

Parameters:
key - the key of this record.
value - the value of this record.
Throws:
Value.InvalidArgumentException - if key is empty or contains any whitespace character.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object