org.kit.furia.io
Class AbstractFuriaInput<O extends org.ajmm.obsearch.OB>

java.lang.Object
  extended by org.kit.furia.io.AbstractFuriaInput<O>
Direct Known Subclasses:
FuriaInputOBFragment

public abstract class AbstractFuriaInput<O extends org.ajmm.obsearch.OB>
extends java.lang.Object

AbstractFuriaInput is in charge of reading fragment files and creating documents out of them.

Since:
0
Author:
Arnoldo Jose Muller Molina

Field Summary
static java.lang.String fragmentFileName
          The name of the file that holds the fragments (words) inside a directory.
 
Constructor Summary
AbstractFuriaInput(java.io.File directory)
          Creates a new fragment file reader based on the given directory.
 
Method Summary
 Document<O> getDocument(java.lang.String id, java.io.File fragments)
          Parses a file that is in the furia-chan fragment file format: "#" starts a comment and it is ignored.
 java.util.Iterator<Document<O>> getDocumentsFromDirectory()
          This method receives a directory and returns an iterator that will lazily create documents from the given directory.
 boolean isParsableLine(java.lang.String line)
          Returns true if the given line is not null or if it is not a comment.
protected abstract  O readObjectFromStringLine(java.lang.String data)
          Reads and creates an O object from the given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fragmentFileName

public static final java.lang.String fragmentFileName
The name of the file that holds the fragments (words) inside a directory.

See Also:
Constant Field Values
Constructor Detail

AbstractFuriaInput

public AbstractFuriaInput(java.io.File directory)
Creates a new fragment file reader based on the given directory.

Parameters:
directory -
Method Detail

readObjectFromStringLine

protected abstract O readObjectFromStringLine(java.lang.String data)
                                                                    throws org.ajmm.obsearch.exception.OBException
Reads and creates an O object from the given string.

Parameters:
data - The string to be parsed
Returns:
an O object that was created from data
Throws:
org.ajmm.obsearch.exception.OBException - if something goes wrong when parsing the data.

getDocumentsFromDirectory

public java.util.Iterator<Document<O>> getDocumentsFromDirectory()
                                                                                       throws java.io.IOException
This method receives a directory and returns an iterator that will lazily create documents from the given directory. The directory is composed of directories in which a file called "fragments" was previously created.

Parameters:
directory - that will be processed
Returns:
An iterator that will return one by one all the documents found in the given directory.
Throws:
java.io.IOException - If the given directory does not exist.

getDocument

public Document<O> getDocument(java.lang.String id,
                               java.io.File fragments)
                                                     throws java.io.IOException,
                                                            org.ajmm.obsearch.exception.OBException
Parses a file that is in the furia-chan fragment file format: "#" starts a comment and it is ignored. Every object is a string separated by a newline. The subclass knows how to interpret this line, and an appropriate O object will be generated from this line.

Parameters:
fragments - A file in which fragment files can be found.
id - The id that the document will hold.
Returns:
A document of O objects created from the given file.
Throws:
java.io.IOException - If fragments does not exist, or any other error occurs.
org.ajmm.obsearch.exception.OBException

isParsableLine

public boolean isParsableLine(java.lang.String line)
Returns true if the given line is not null or if it is not a comment.

Returns:
true if the given line can be parsed.


Copyright © 2008 Arnoldo Jose Muller Molina. All Rights Reserved.