|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.hpi.fgis.dude.util.AbstractCleanable de.hpi.fgis.dude.datasource.AbstractDataSource<CSVSource> de.hpi.fgis.dude.datasource.CSVSource
public class CSVSource
CSVSource
represents *.csv files.
Nested Class Summary | |
---|---|
protected class |
CSVSource.CSVSourceIterator
CSVSourceIterator is used for generating DuDeObject s out of CSVSource s. |
Nested classes/interfaces inherited from class de.hpi.fgis.dude.datasource.AbstractDataSource |
---|
AbstractDataSource.AbstractDataSourceIterator<T extends AbstractDataSource<?>> |
Constructor Summary | |
---|---|
protected |
CSVSource()
Internal constructor for Jsonable deserialization. |
|
CSVSource(String identifier,
File file)
Initializes a CSVSource . |
|
CSVSource(String identifier,
File file,
String... colNames)
Initializes a CSVSource with column names. |
Method Summary | |
---|---|
void |
disableHeader()
Disables header reading. |
void |
enableHeader()
Enables header reading. |
void |
fromJson(DuDeJsonParser<?> jsonParser)
Initializes the current instance using the passed DuDeJsonParser . |
protected String[] |
getColumnNames()
Returns the column names or null , if no column names were set. |
protected String |
getFilePath()
Returns the path of the CSV file. |
char |
getQuoteCharacter()
Returns the set quote character. |
char |
getSeparatorCharacter()
Returns the set separator character. |
Iterator<DuDeObject> |
iterator()
|
boolean |
readHeader()
Checks whether interpreting the first line as header is enabled. |
void |
setQuoteCharacter(char quoteChar)
Sets the quote character. |
void |
setSeparatorCharacter(char separatorChar)
Sets the separator character. |
void |
toJson(DuDeJsonGenerator jsonGenerator)
Generates the Json code using the passed DuDeJsonGenerator . |
CSVSource |
withHeader()
By calling this method the extractor will interpret the first line as a header. |
CSVSource |
withQuoteCharacter(char quChar)
Set the quote character that is used in the file. |
CSVSource |
withSeparatorCharacter(char sepChar)
Sets the separator character that is used in the file. |
Methods inherited from class de.hpi.fgis.dude.datasource.AbstractDataSource |
---|
addIdAttributes, autoGeneratedIds, close, equals, getExtractedRecordCount, getIdAttributes, getIdentifier, hashCode, setExtractedRecordCount, toString, withIdAttributes |
Methods inherited from class de.hpi.fgis.dude.util.AbstractCleanable |
---|
cleanUp, registerCleanable, registerCloseable |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface de.hpi.fgis.dude.util.Cleanable |
---|
cleanUp, registerCleanable, registerCloseable |
Constructor Detail |
---|
protected CSVSource()
Jsonable
deserialization.
public CSVSource(String identifier, File file) throws FileNotFoundException
CSVSource
.
identifier
- The identifier of the DataSource
instance.file
- The file of which the data will be extracted.
FileNotFoundException
- If the passed file does not exist.public CSVSource(String identifier, File file, String... colNames) throws FileNotFoundException
CSVSource
with column names.
identifier
- The identifier of the DataSource
instance.file
- The file of which the data will be extracted.colNames
- The column names.
FileNotFoundException
- If the passed file does not exist.Method Detail |
---|
public char getQuoteCharacter()
public void setQuoteCharacter(char quoteChar)
quoteChar
- The quote character to set.public char getSeparatorCharacter()
public void setSeparatorCharacter(char separatorChar)
separatorChar
- The separator character to set.public void disableHeader()
public void enableHeader()
public boolean readHeader()
true
, if the header flag is enabled; otherwise false
.public CSVSource withHeader()
enableHeader()
public CSVSource withQuoteCharacter(char quChar)
quChar
- The quote character.
setQuoteCharacter(char)
public CSVSource withSeparatorCharacter(char sepChar)
sepChar
- The separator character.
setSeparatorCharacter(char)
public Iterator<DuDeObject> iterator()
iterator
in interface Iterable<DuDeObject>
iterator
in class AbstractDataSource<CSVSource>
protected String getFilePath()
protected String[] getColumnNames()
null
, if no column names were set.
public void toJson(DuDeJsonGenerator jsonGenerator) throws org.codehaus.jackson.JsonGenerationException, IOException
Jsonable
DuDeJsonGenerator
.
toJson
in interface Jsonable
jsonGenerator
- The DuDeJsonGenerator
that is used internally.
org.codehaus.jackson.JsonGenerationException
- If an error occurs while generating the Json syntax.
IOException
- If an error occurs while writing to the output.public void fromJson(DuDeJsonParser<?> jsonParser) throws org.codehaus.jackson.JsonParseException, IOException
Jsonable
DuDeJsonParser
.
fromJson
in interface Jsonable
jsonParser
- The parser that is used for extracting the data out of the Json.
org.codehaus.jackson.JsonParseException
- If an error occurs while parsing the Json.
IOException
- If an error occurs while reading from the stream.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |