|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object it.unimi.di.mg4j.document.AbstractDocumentFactory it.unimi.di.mg4j.document.TRECHeaderDocumentFactory
public class TRECHeaderDocumentFactory
A factory without fields that is used to interpret the header of a
TREC GOV2 document. It is usually the first factory to interpret
a document of a TRECDocumentCollection
.
Presently, its only rôumflex;le is that of parsing the document
URI and setting a metadata item with key PropertyBasedDocumentFactory.MetadataKeys.URI
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface it.unimi.di.mg4j.document.DocumentFactory |
---|
DocumentFactory.FieldType |
Constructor Summary | |
---|---|
TRECHeaderDocumentFactory()
|
Method Summary | |
---|---|
DocumentFactory |
copy()
|
int |
fieldIndex(String fieldName)
Returns the index of a field, given its symbolic name. |
String |
fieldName(int fieldIndex)
Returns the symbolic name of a field. |
DocumentFactory.FieldType |
fieldType(int fieldIndex)
Returns the type of a field. |
Document |
getDocument(InputStream rawContent,
Reference2ObjectMap<Enum<?>,Object> metadata)
Returns the document obtained by parsing the given byte stream. |
int |
numberOfFields()
Returns the number of fields present in the documents produced by this factory. |
protected static boolean |
startsWith(byte[] a,
int l,
byte[] b)
|
protected static boolean |
startsWithIgnoreCase(byte[] a,
int l,
char[] b)
|
Methods inherited from class it.unimi.di.mg4j.document.AbstractDocumentFactory |
---|
ensureFieldIndex, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TRECHeaderDocumentFactory()
Method Detail |
---|
public int numberOfFields()
DocumentFactory
public String fieldName(int fieldIndex)
DocumentFactory
fieldIndex
- the index of a field (between 0 inclusive and DocumentFactory.numberOfFields()
exclusive}).
field
-th field.public int fieldIndex(String fieldName)
DocumentFactory
fieldName
- the name of a field of this factory.
fieldName
.public DocumentFactory.FieldType fieldType(int fieldIndex)
DocumentFactory
The possible types are defined in DocumentFactory.FieldType
.
fieldIndex
- the index of a field (between 0 inclusive and DocumentFactory.numberOfFields()
exclusive}).
field
-th field.protected static boolean startsWith(byte[] a, int l, byte[] b)
protected static boolean startsWithIgnoreCase(byte[] a, int l, char[] b)
public Document getDocument(InputStream rawContent, Reference2ObjectMap<Enum<?>,Object> metadata) throws IOException
DocumentFactory
The parameter metadata
actually replaces the lack of a simple keyword-based
parameter-passing system in Java. This method might take several different type of “suggestions”
which have been collected by the collection: typically, the document title, a URI representing
the document, its MIME type, its encoding and so on. Some of this information might be
set by default (as it happens, for instance, in a PropertyBasedDocumentFactory
).
Implementations of this method must consult the metadata provided by the collection, possibly
complete them with default factory metadata, and proceed to the document construction.
rawContent
- the raw content from which the document should be extracted; it must not be closed, as
resource management is a responsibility of the DocumentCollection.metadata
- a map from enums (e.g., keys taken in PropertyBasedDocumentFactory
) to various kind of objects.
IOException
public DocumentFactory copy()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |