com.Ostermiller.util Java Utilities


com.Ostermiller.util
Interface CSVPrint

All Known Implementing Classes:
CSVPrinter, ExcelCSVPrinter

public interface CSVPrint

Print values as a comma separated list. More information about this class is available from ostermiller.org. This interface is designed to be set of general methods that all CSV printers should implement.

Since:
ostermillerutils 1.00.00
Author:
Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities, Pierre Dittgen

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(String value)
          Print the string as the next value on the line.
 void print(String[] values)
          Print multiple delimited values values.
 void println()
          Output a blank line.
 void println(String value)
          Print the string as the last value on the line.
 void println(String[] values)
          Print a single line of comma separated values.
 void println(String[][] values)
          Print several lines of comma separated values.
 void printlnComment(String comment)
          If the CSV format supports comments, write the comment to the file on its own line, otherwise, start a new line.
 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 write(String value)
          Print the string as the next value on the line.
 void write(String[] values)
          Print multiple delimited values values.
 void writeln()
          Output a blank line.
 void writeln(String value)
          Print the string as the last value on the line.
 void writeln(String[] values)
          Print a single line of comma separated values.
 void writeln(String[][] values)
          Print several lines of comma separated values.
 void writelnComment(String comment)
          If the CSV format supports comments, write the comment to the file on its own line, otherwise, start a new line.
 

Method Detail

changeDelimiter

void changeDelimiter(char newDelimiter)
                     throws BadDelimiterException
Change this printer so that it uses a new delimiter.

Parameters:
newDelimiter - The new delimiter character to use.
Throws:
BadDelimiterException - if the character cannot be used as a delimiter.
Since:
ostermillerutils 1.02.18

changeQuote

void changeQuote(char newQuote)
                 throws BadQuoteException
Change this printer so that it uses a new character for quoting.

Parameters:
newQuote - The new character to use for quoting.
Throws:
BadQuoteException - if the character cannot be used as a quote.
Since:
ostermillerutils 1.02.18

setAutoFlush

void setAutoFlush(boolean autoFlush)
Set flushing behavior. Iff set, a flush command will be issued to any underlying stream after each print or write command.

Parameters:
autoFlush - should auto flushing be enabled.
Since:
ostermillerutils 1.02.26

checkError

boolean checkError()
Flush the stream if it's not closed and check its error state. Errors are cumulative; once the stream encounters an error, this routine will return true on all successive calls.

Returns:
True if the print stream has encountered an error, either on the underlying output stream or during a format conversion.
Since:
ostermillerutils 1.02.26

println

void println(String value)
Print the string as the last value on the line. The value will be quoted if needed. If value is null, an empty value is printed.

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.

Parameters:
value - value to be outputted.
Since:
ostermillerutils 1.00.00

writeln

void writeln(String value)
             throws IOException
Print the string as the last value on the line. The value will be quoted if needed. If value is null, an empty value is printed.

Parameters:
value - value to be outputted.
Throws:
IOException - if an error occurs while writing.
Since:
ostermillerutils 1.02.26

println

void println()
Output a blank line.

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.

Since:
ostermillerutils 1.00.00

writeln

void writeln()
             throws IOException
Output a blank line.

Throws:
IOException - if an error occurs while writing.
Since:
ostermillerutils 1.02.26

println

void println(String[] values)
Print a single line of comma separated values. The values will be quoted if needed. Quotes and and other characters that need it will be escaped.

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.

Parameters:
values - values to be outputted.
Since:
ostermillerutils 1.00.00

writeln

void writeln(String[] values)
             throws IOException
Print a single line of comma separated values. The values will be quoted if needed. Quotes and and other characters that need it will be escaped.

Parameters:
values - values to be outputted.
Throws:
IOException - if an error occurs while writing.
Since:
ostermillerutils 1.02.26

println

void println(String[][] values)
Print several lines of comma separated values. The values will be quoted if needed. Quotes and newLine characters will be escaped.

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.

Parameters:
values - values to be outputted.
Since:
ostermillerutils 1.00.00

writeln

void writeln(String[][] values)
             throws IOException
Print several lines of comma separated values. The values will be quoted if needed. Quotes and newLine characters will be escaped.

Parameters:
values - values to be outputted.
Throws:
IOException - if an error occurs while writing.
Since:
ostermillerutils 1.02.26

printlnComment

void printlnComment(String comment)
If the CSV format supports comments, write the comment to the file on its own line, otherwise, start a new line.

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.

Parameters:
comment - the comment to output.
Since:
ostermillerutils 1.00.00

writelnComment

void writelnComment(String comment)
                    throws IOException
If the CSV format supports comments, write the comment to the file on its own line, otherwise, start a new line.

Parameters:
comment - the comment to output.
Throws:
IOException - if an error occurs while writing.
Since:
ostermillerutils 1.02.26

print

void print(String value)
Print the string as the next value on the line. The value will be quoted if needed.

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.

Parameters:
value - value to be outputted.
Since:
ostermillerutils 1.00.00

write

void write(String value)
           throws IOException
Print the string as the next value on the line. The value will be quoted if needed.

Parameters:
value - value to be outputted.
Throws:
IOException - if an error occurs while writing.
Since:
ostermillerutils 1.02.26

flush

void flush()
           throws IOException
Flush any data written out to underlying streams.

Throws:
IOException - if an IO error occurs
Since:
ostermillerutils 1.02.26

close

void close()
           throws IOException
Close any underlying streams.

Throws:
IOException - if an IO error occurs
Since:
ostermillerutils 1.02.26

print

void print(String[] values)
Print multiple delimited values values. The values will be quoted if needed. Quotes and and other characters that need it will be escaped.

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 write method.

Parameters:
values - values to be outputted.
Since:
ostermillerutils 1.02.26

write

void write(String[] values)
           throws IOException
Print multiple delimited values values. The values will be quoted if needed. Quotes and and other characters that need it will be escaped.

Parameters:
values - values to be outputted.
Throws:
IOException - if an error occurs while writing.
Since:
ostermillerutils 1.02.26

setAlwaysQuote

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.

Parameters:
alwaysQuote - true if quotes should be used even when not strictly needed.
Since:
ostermillerutils 1.02.26

com.Ostermiller.util Java Utilities


Copyright © 2001-2012 by Stephen Ostermiller