org.pentaho.reporting.engine.classic.core.modules.output.csv
Class CSVQuoter

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.modules.output.csv.CSVQuoter

public class CSVQuoter
extends Object

The CSVQuoter is a helper class to encode a string for the CSV file format.

Author:
Thomas Morgner.

Constructor Summary
CSVQuoter()
          Creates a new CSVQuoter, which uses a comma as the default separator.
CSVQuoter(String separator)
          Creates a new CSVQuoter, which uses the defined separator.
 
Method Summary
 String doQuoting(String original)
          Encodes the string, so that the string can safely be used in CSV files.
 String getSeparator()
          Gets the separator used in this quoter and the CSV file.
 void setSeparator(String separator)
          Defines the separator, which is used in the CSV file.
 String undoQuoting(String nativeString)
          Decodes the string, so that all escape sequences get removed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVQuoter

public CSVQuoter()
Creates a new CSVQuoter, which uses a comma as the default separator.


CSVQuoter

public CSVQuoter(String separator)
Creates a new CSVQuoter, which uses the defined separator.

Parameters:
separator - the separator.
Throws:
NullPointerException - if the given separator is null.
Method Detail

doQuoting

public String doQuoting(String original)
Encodes the string, so that the string can safely be used in CSV files. If the string does not need quoting, the original string is returned unchanged.

Parameters:
original - the unquoted string.
Returns:
The quoted string

undoQuoting

public String undoQuoting(String nativeString)
Decodes the string, so that all escape sequences get removed. If the string was not quoted, then the string is returned unchanged.

Parameters:
nativeString - the quoted string.
Returns:
The unquoted string.

getSeparator

public String getSeparator()
Gets the separator used in this quoter and the CSV file.

Returns:
the separator (never null).

setSeparator

public void setSeparator(String separator)
Defines the separator, which is used in the CSV file. If you use different separators for quoting and writing, the resulting file will be invalid.

Parameters:
separator - the separator (null not permitted).