|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Document
An indexable document.
Instance of this class represent a single document. Documents provide access to possibly several fields, which represent units of information that should be indexed separately.
Each field is accessible by a call to content(int)
. Note, however, that unless specified
otherwise field content must be accessed in increasing order. You can skip some field,
but the contract of this class does not require that you can access fields in random order (although implementations
may provide this feature). Moreover, the data provided by a call to
content(int)
(e.g., a Reader
for TEXT
fields) may become invalid
at the next call (similarly to the behaviour of DocumentCollection.document(int)
).
The same holds for wordReader(int)
.
After obtaining a document, it is your responsibility to close it.
It is advisable, although not strictly required, that documents have
a toString()
equal to their title.
Method Summary | |
---|---|
void |
close()
Closes this document, releasing all resources. |
Object |
content(int field)
Returns the content of the given field. |
CharSequence |
title()
The title of this document. |
CharSequence |
uri()
A URI that is associated with this document. |
WordReader |
wordReader(int field)
Returns a word reader for the given DocumentFactory.FieldType.TEXT field. |
Method Detail |
---|
CharSequence title()
null
.CharSequence uri()
null
.Object content(int field) throws IOException
field
- the field index.
DocumentFactory
that
built this document. For example, the returned object is going to be a Reader
if the field type is
DocumentFactory.FieldType.TEXT
.
IOException
WordReader wordReader(int field)
DocumentFactory.FieldType.TEXT
field.
field
- the field index.
void close() throws IOException
You should always call this method after manipulating a document. Implementations
are invited to call this method in a finaliser as a safety net (even better,
implement SafelyCloseable
), but since there
is no guarantee as to when finalisers are invoked, you should not depend on this behaviour.
close
in interface Closeable
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |