case VIRTUAL:
final int nfrag = rawContentDataInputStream.readInt();
for ( int i = 0; i < 2 * nfrag; i++ ) MutableString.skipSelfDelimUTF8( rawContent );
break;
default: // Non-text and non-virtual
new ObjectInputStream( rawContent ).readObject();
}
nextFieldToRead++;
}
/** Skips to the given field.
*
* @param field the field to skip to.
* @throws IOException
* @throws ClassNotFoundException
*/
private void skipToField( final int field ) throws IOException, ClassNotFoundException {
if ( nextFieldToRead > field ) throw new IllegalStateException( "Trying to skip to field " + field + " after " + nextFieldToRead );
while ( nextFieldToRead < field ) skipOneField();
}
public Object content( final int field ) {
ensureFieldIndex( field );
Object result = null;
if ( DEBUG ) LOGGER.debug( "Called content(" + field + "); nextField:" + nextFieldToRead );
try {
skipToField( field );
if ( fieldType( nextFieldToRead ) == FieldType.VIRTUAL ) {
final int nfrag = rawContentDataInputStream.readInt();
MutableString doc = new MutableString();
MutableString text = new MutableString();
VirtualDocumentFragment[] fragArray = new VirtualDocumentFragment[ nfrag ];
for ( int i = 0; i < nfrag; i++ ) {
doc.readSelfDelimUTF8( rawContent );
text.readSelfDelimUTF8( rawContent );
fragArray[ i ] = new AnchorExtractor.Anchor( doc.copy(), text.copy() );
}
result = new ObjectArrayList<VirtualDocumentFragment>( fragArray );
}
else if ( fieldType( nextFieldToRead ) != FieldType.TEXT ) {
result = new ObjectInputStream( rawContent ).readObject();
if ( DEBUG ) LOGGER.debug( "Read " + result + " from field " + fieldName( nextFieldToRead ) + " of object " + title() );
nextFieldToRead++;
}
else {
if ( DEBUG ) LOGGER.debug( "Returning reader for " + field );