|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.hpi.fgis.dude.output.CSVOutput
public class CSVOutput
Writes passed DudeObjectPairs
, their similarity value and selected optional value in a CSV file row by row.
Field Summary | |
---|---|
static char |
DEFAULT_ESCAPE_CHARACTER
The default escape character. |
static char |
DEFAULT_QUOTE_CHARACTER
The default quote character. |
static char |
DEFAULT_SEPARATOR
The default separator character. |
protected String[] |
defaultColumnNames
The default header. |
Constructor Summary | |
---|---|
protected |
CSVOutput()
Internal constructor for Jsonable deserialization. |
|
CSVOutput(File file)
Initializes a new CSVOutput . |
|
CSVOutput(OutputStream stream)
Initializes a new CSVOutput with the passed OutputStream . |
|
CSVOutput(Writer writer)
Initializes a new CSVOutput . |
Method Summary | |
---|---|
void |
close()
Closes the stream. |
void |
disablePrintingCompleteIdentifier()
If this is disabled, the source id won't be printed. |
void |
enablePrintingCompleteIdentifier()
If this is enabled, the complete identifier is printed. |
void |
fromJson(DuDeJsonParser<?> jsonParser)
Initializes the current instance using the passed DuDeJsonParser . |
protected String[] |
getDataLine(DuDeObjectPair pair)
Generates the data that shall be printed. |
char |
getEscapeCharacter()
Returns the escape character. |
protected String[] |
getHeader()
Returns the header. |
char |
getQuoteCharacter()
Returns the quote character. |
char |
getSeparator()
Returns the separator character. |
protected static String |
getString(Object obj)
Returns the String representation of the object or null , if null was passed. |
boolean |
headerIsEnabled()
Checks whether the header shall be written. |
boolean |
printingCompleteIdentifierEnabled()
Checks whether printing the complete identifier is enabled. |
boolean |
printingDataEnabled()
Checks whether printing the data is enabled. |
void |
resetOptionalColumns()
Resets the values of all optional columns using empty Strings. |
void |
setEscapeCharacter(char escapeCharacter)
Sets the escape character. |
boolean |
setOptionalColumn(String identifier)
Sets a new optional column with no value. |
boolean |
setOptionalColumn(String identifier,
String value)
Sets a new optional column with the passed value. |
void |
setQuoteCharacter(char quoteCharacter)
Sets the quote character. |
void |
setSeparator(char sep)
Sets the separator character. |
void |
toJson(DuDeJsonGenerator jsonGenerator)
Generates the Json code using the passed DuDeJsonGenerator . |
DuDeOutput |
withData()
Enables printing the data. |
CSVOutput |
withHeader()
Writing the header before writing the first pair is enabled. |
DuDeOutput |
withoutData()
Disables printing the data. |
CSVOutput |
withoutHeader()
Writing the header before writing the first pair is disabled. |
void |
write(DuDeObjectPair pair)
Writes the Ids of the DuDeObjects their similarity value and specified optional values into the file. |
void |
writeDuplicatesOnly(DuDeObjectPair pair)
Writes the passed DuDeObjectPair onto the stream, if it is flagged as a duplicate. |
protected void |
writeHeader()
Writes the header into the output. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char DEFAULT_SEPARATOR
public static final char DEFAULT_QUOTE_CHARACTER
public static final char DEFAULT_ESCAPE_CHARACTER
protected final String[] defaultColumnNames
Constructor Detail |
---|
public CSVOutput(File file) throws IOException
CSVOutput
.
file
- The file that is used for this output.
IOException
- if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any
other reasonpublic CSVOutput(OutputStream stream)
CSVOutput
with the passed OutputStream
.
stream
- The stream that is used for printing the result.public CSVOutput(Writer writer)
CSVOutput
.
writer
- The writer that is used for this output.protected CSVOutput()
Jsonable
deserialization.
Method Detail |
---|
protected static String getString(Object obj)
null
, if null
was passed.
obj
- The object whose String representation shall be returned.
null
, if null
was passed.public void close() throws IOException
DuDeOutput
close
in interface DuDeOutput
IOException
- If an error occurs while closing the stream.public void disablePrintingCompleteIdentifier()
public void enablePrintingCompleteIdentifier()
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.protected String[] getDataLine(DuDeObjectPair pair)
pair
- The pair whose information shall be printed.
public char getEscapeCharacter()
protected String[] getHeader()
public char getQuoteCharacter()
public char getSeparator()
public boolean headerIsEnabled()
true
, if the header will be written before the first pair is printed; otherwise false
.public boolean printingCompleteIdentifierEnabled()
true
, if it is enabled; otherwise false
.public boolean printingDataEnabled()
true
, if it is enabled; otherwise false
.public void resetOptionalColumns()
public void setEscapeCharacter(char escapeCharacter)
escapeCharacter
- The new escape character.public boolean setOptionalColumn(String identifier)
identifier
- The column's identifier.
true
, if a new column was added; otherwise false
.public boolean setOptionalColumn(String identifier, String value)
identifier
- The column's identifier.value
- The column's value.
true
, if a new column was added; otherwise false
.public void setQuoteCharacter(char quoteCharacter)
quoteCharacter
- The new quote character.public void setSeparator(char sep)
sep
- The new separator character.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 DuDeOutput withData()
DuDeOutput
withData
in interface DuDeOutput
public CSVOutput withHeader()
public DuDeOutput withoutData()
DuDeOutput
withoutData
in interface DuDeOutput
public CSVOutput withoutHeader()
public void write(DuDeObjectPair pair) throws IOException
write
in interface DuDeOutput
pair
- A pair of two DuDeObject
s that are written into an OutputStream
.
IOException
- If an error occurs while writing onto the stream.public void writeDuplicatesOnly(DuDeObjectPair pair) throws IOException
DuDeOutput
DuDeObjectPair
onto the stream, if it is flagged as a duplicate.
writeDuplicatesOnly
in interface DuDeOutput
pair
- The pair that shall be written to the stream.
IOException
- If an error occurs while writing onto the stream.DuDeObjectPair.getDuplicateInfo()
protected void writeHeader() throws IOException
IOException
- If an error occurs during the write process.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |