|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.Ostermiller.util.ExcelCSVPrinter
public class ExcelCSVPrinter
Print values as a comma separated list that can be read by the Excel spreadsheet. More information about this class is available from ostermiller.org.
| Field Summary | |
|---|---|
protected boolean |
alwaysQuote
If auto flushing is enabled. |
protected boolean |
autoFlush
If auto flushing is enabled. |
protected char |
delimiterChar
Character written as field delimiter. |
protected boolean |
error
true iff an error has occurred. |
protected java.lang.String |
lineEnding
The line ending, must be one of "\n", "\r", or "\r\n" |
protected boolean |
newLine
True iff we just began a new line. |
protected java.io.Writer |
out
The place that the values get written. |
protected char |
quoteChar
Quoting character. |
| Constructor Summary | |
|---|---|
ExcelCSVPrinter(java.io.OutputStream out)
Create a printer that will print values to the given stream. |
|
ExcelCSVPrinter(java.io.Writer out)
Create a printer that will print values to the given stream. |
|
ExcelCSVPrinter(java.io.Writer out,
boolean alwaysQuote,
boolean autoFlush)
Create a printer that will print values to the given stream. |
|
ExcelCSVPrinter(java.io.Writer out,
char quote,
char delimiter)
Create a printer that will print values to the given stream. |
|
ExcelCSVPrinter(java.io.Writer out,
char quote,
char delimiter,
boolean alwaysQuote,
boolean autoFlush)
Create a printer that will print values to the given stream. |
|
ExcelCSVPrinter(java.io.Writer out,
char quote,
char delimiter,
java.lang.String lineEnding)
Create a printer that will print values to the given stream. |
|
ExcelCSVPrinter(java.io.Writer out,
char quote,
char delimiter,
java.lang.String lineEnding,
boolean alwaysQuote,
boolean autoFlush)
Create a printer that will print values to the given stream. |
|
| Method Summary | |
|---|---|
void |
changeDelimiter(char newDelimiter)
Change this printer so that it uses a new delimiter. |
void |
changeQuote(char newQuote)
Change this printer so that it uses a new character for quoting. |
boolean |
checkError()
Flush the stream if it's not closed and check its error state. |
void |
close()
Close any underlying streams. |
void |
flush()
Flush any data written out to underlying streams. |
void |
print(java.lang.String value)
Print the string as the next value on the line. |
void |
print(java.lang.String[] values)
Print a single line of comma separated values. |
void |
println()
Output a blank line. |
void |
println(java.lang.String value)
Print the string as the last value on the line. |
void |
println(java.lang.String[] values)
Print a single line of comma separated values. |
void |
println(java.lang.String[][] values)
Print several lines of comma separated values. |
void |
printlnComment(java.lang.String comment)
Since ExcelCSV format does not support comments, this method will ignore the comment and start a new row. |
void |
setAlwaysQuote(boolean alwaysQuote)
Set whether values printers should always be quoted, or whether the printer may, at its discretion, omit quotes around the value. |
void |
setAutoFlush(boolean autoFlush)
Set flushing behavior. |
void |
setLineEnding(java.lang.String lineEnding)
Change this printer so that it uses a new line ending. |
void |
write(java.lang.String value)
Print the string as the next value on the line. |
void |
write(java.lang.String[] values)
Print a single line of comma separated values. |
void |
writeln()
Output a blank line. |
void |
writeln(java.lang.String value)
Print the string as the last value on the line. |
void |
writeln(java.lang.String[] values)
Print a single line of comma separated values. |
void |
writeln(java.lang.String[][] values)
Print several lines of comma separated values. |
void |
writelnComment(java.lang.String comment)
Since ExcelCSV format does not support comments, this method will ignore the comment and start a new row. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean autoFlush
protected boolean alwaysQuote
protected boolean error
protected char delimiterChar
protected char quoteChar
protected java.io.Writer out
protected boolean newLine
protected java.lang.String lineEnding
| Constructor Detail |
|---|
public ExcelCSVPrinter(java.io.OutputStream out)
out - stream to which to print.public ExcelCSVPrinter(java.io.Writer out)
out - stream to which to print.
public ExcelCSVPrinter(java.io.Writer out,
boolean alwaysQuote,
boolean autoFlush)
out - stream to which to print.alwaysQuote - true if quotes should be used even when not strictly needed.autoFlush - should auto flushing be enabled.
public ExcelCSVPrinter(java.io.Writer out,
char quote,
char delimiter)
throws BadDelimiterException,
BadQuoteException
out - stream to which to print.delimiter - The new delimiter character to use.quote - The new character to use for quoting.
BadQuoteException - if the character cannot be used as a quote.
BadDelimiterException - if the character cannot be used as a delimiter.
public ExcelCSVPrinter(java.io.Writer out,
char quote,
char delimiter,
java.lang.String lineEnding)
throws BadDelimiterException,
BadQuoteException,
BadLineEndingException
out - stream to which to print.delimiter - The new delimiter character to use.quote - The new character to use for quoting.lineEnding - The new line ending, or null to use the default line ending.
BadQuoteException - if the character cannot be used as a quote.
BadDelimiterException - if the character cannot be used as a delimiter.
BadLineEndingException - if the line ending is not one of the three legal line endings.
public ExcelCSVPrinter(java.io.Writer out,
char quote,
char delimiter,
boolean alwaysQuote,
boolean autoFlush)
throws BadDelimiterException,
BadQuoteException
out - stream to which to print.delimiter - The new delimiter character to use.quote - The new character to use for quoting.alwaysQuote - true if quotes should be used even when not strictly needed.autoFlush - should auto flushing be enabled.
BadQuoteException - if the character cannot be used as a quote.
BadDelimiterException - if the character cannot be used as a delimiter.
public ExcelCSVPrinter(java.io.Writer out,
char quote,
char delimiter,
java.lang.String lineEnding,
boolean alwaysQuote,
boolean autoFlush)
throws BadDelimiterException,
BadQuoteException,
BadLineEndingException
out - stream to which to print.delimiter - The new delimiter character to use.quote - The new character to use for quoting.lineEnding - The new line ending, or null to use the default line ending.alwaysQuote - true if quotes should be used even when not strictly needed.autoFlush - should auto flushing be enabled.
BadQuoteException - if the character cannot be used as a quote.
BadDelimiterException - if the character cannot be used as a delimiter.
BadLineEndingException - if the line ending is not one of the three legal line endings.| Method Detail |
|---|
public void changeDelimiter(char newDelimiter)
throws BadDelimiterException
changeDelimiter in interface CSVPrintnewDelimiter - The new delimiter character to use.
BadDelimiterException - if the character cannot be used as a delimiter.
public void changeQuote(char newQuote)
throws BadQuoteException
changeQuote in interface CSVPrintnewQuote - The new character to use for quoting.
BadQuoteException - if the character cannot be used as a quote.
public void setLineEnding(java.lang.String lineEnding)
throws BadLineEndingException
A line ending must be one of "\n", "\r", or "\r\n".
The default line ending is the system line separator as specified by
System.getProperty("line.separator"), or "\n" if the system
line separator is not a legal line ending.
lineEnding - The new line ending, or null to use the default line ending.
BadLineEndingException - if the line ending is not one of the three legal line endings.public void println(java.lang.String value)
This method never throws an I/O exception. The client may inquire as to whether any errors have occurred by invoking checkError(). If an I/O Exception is desired, the client should use the corresponding writeln method.
println in interface CSVPrintvalue - value to be outputted.
public void writeln(java.lang.String value)
throws java.io.IOException
writeln in interface CSVPrintvalue - value to be outputted.
java.io.IOException - if an error occurs while writing.public void println()
This method never throws an I/O exception. The client may inquire as to whether any errors have occurred by invoking checkError(). If an I/O Exception is desired, the client should use the corresponding writeln method.
println in interface CSVPrint
public void writeln()
throws java.io.IOException
writeln in interface CSVPrintjava.io.IOException - if an error occurs while writing.public void println(java.lang.String[] values)
This method never throws an I/O exception. The client may inquire as to whether any errors have occurred by invoking checkError(). If an I/O Exception is desired, the client should use the corresponding writeln method.
println in interface CSVPrintvalues - values to be outputted.
public void writeln(java.lang.String[] values)
throws java.io.IOException
writeln in interface CSVPrintvalues - values to be outputted.
java.io.IOException - if an error occurs while writing.public void print(java.lang.String[] values)
This method never throws an I/O exception. The client may inquire as to whether any errors have occurred by invoking checkError(). If an I/O Exception is desired, the client should use the corresponding writeln method.
print in interface CSVPrintvalues - values to be outputted.
public void write(java.lang.String[] values)
throws java.io.IOException
write in interface CSVPrintvalues - values to be outputted.
java.io.IOException - if an error occurs while writing.public void println(java.lang.String[][] values)
This method never throws an I/O exception. The client may inquire as to whether any errors have occurred by invoking checkError(). If an I/O Exception is desired, the client should use the corresponding writeln method.
println in interface CSVPrintvalues - values to be outputted.
public void writeln(java.lang.String[][] values)
throws java.io.IOException
writeln in interface CSVPrintvalues - values to be outputted.
java.io.IOException - if an error occurs while writing.public void printlnComment(java.lang.String comment)
This method never throws an I/O exception. The client may inquire as to whether any errors have occurred by invoking checkError(). If an I/O Exception is desired, the client should use the corresponding writelnComment method.
printlnComment in interface CSVPrintcomment - the comment to output (ignored).
public void writelnComment(java.lang.String comment)
throws java.io.IOException
writelnComment in interface CSVPrintcomment - the comment to output (ignored).
java.io.IOException - if an error occurs while writing.public void print(java.lang.String value)
This method never throws an I/O exception. The client may inquire as to whether any errors have occurred by invoking checkError(). If an I/O Exception is desired, the client should use the corresponding println method.
print in interface CSVPrintvalue - value to be outputted.
public void write(java.lang.String value)
throws java.io.IOException
write in interface CSVPrintvalue - value to be outputted.
java.io.IOException - if an error occurs while writing.
public void flush()
throws java.io.IOException
flush in interface CSVPrintjava.io.IOException - if an error occurs while writing.
public void close()
throws java.io.IOException
close in interface CSVPrintjava.io.IOException - if an error occurs while writing.public boolean checkError()
checkError in interface CSVPrintpublic void setAlwaysQuote(boolean alwaysQuote)
setAlwaysQuote in interface CSVPrintalwaysQuote - true if quotes should be used even when not strictly needed.public void setAutoFlush(boolean autoFlush)
setAutoFlush in interface CSVPrintautoFlush - should auto flushing be enabled.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||