diff --git a/.classpath b/.classpath index a6c4fc0..baa80fa 100644 --- a/.classpath +++ b/.classpath @@ -4,5 +4,6 @@ + diff --git a/.gitignore b/.gitignore index 1905ddf..bb52af5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -target -myfile.csv -opencsv.ipr -opencsv.iml -opencsv-2.0.1-SNAPSHOT.patch -pom.xml.cobertura +#ignore class files +*.class +#ignore target directory +target/ +#ignore everything in target just in case... +target/**/* diff --git a/.svnignore b/.svnignore deleted file mode 100644 index 6e7459e..0000000 --- a/.svnignore +++ /dev/null @@ -1,3 +0,0 @@ -build -bin -deploy diff --git a/README b/README deleted file mode 100644 index e69de29..0000000 diff --git a/build.version b/build.version index 9b4cb62..1e82916 100644 --- a/build.version +++ b/build.version @@ -2,6 +2,6 @@ #Wed Aug 23 06:33:41 EST 2006 build.release.major=2 build.number=001 -build.user=Glen -build.release.minor=4 -build.date=2011/04/16 10\:52 +build.user=jokillsya +build.release.minor=5 +build.date=2012/04/16 10\:57 diff --git a/deploy/opencsv-2.5.jar b/deploy/opencsv-2.5.jar new file mode 100644 index 0000000..268624f Binary files /dev/null and b/deploy/opencsv-2.5.jar differ diff --git a/doc/api/allclasses-frame.html b/doc/api/allclasses-frame.html new file mode 100644 index 0000000..c1c22fd --- /dev/null +++ b/doc/api/allclasses-frame.html @@ -0,0 +1,49 @@ + + + + + + +All Classes (opencsv API 2.3) + + + + + + + + + + + +All Classes +
+ + + + + +
ColumnPositionMappingStrategy +
+CSVParser +
+CSVReader +
+CsvToBean +
+CSVWriter +
+HeaderColumnNameMappingStrategy +
+HeaderColumnNameTranslateMappingStrategy +
+MappingStrategy +
+ResultSetHelper +
+ResultSetHelperService +
+
+ + + diff --git a/doc/api/allclasses-noframe.html b/doc/api/allclasses-noframe.html new file mode 100644 index 0000000..d2e26dc --- /dev/null +++ b/doc/api/allclasses-noframe.html @@ -0,0 +1,49 @@ + + + + + + +All Classes (opencsv API 2.3) + + + + + + + + + + + +All Classes +
+ + + + + +
ColumnPositionMappingStrategy +
+CSVParser +
+CSVReader +
+CsvToBean +
+CSVWriter +
+HeaderColumnNameMappingStrategy +
+HeaderColumnNameTranslateMappingStrategy +
+MappingStrategy +
+ResultSetHelper +
+ResultSetHelperService +
+
+ + + diff --git a/doc/api/au/com/bytecode/opencsv/CSVParser.html b/doc/api/au/com/bytecode/opencsv/CSVParser.html new file mode 100644 index 0000000..ad0607e --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/CSVParser.html @@ -0,0 +1,634 @@ + + + + + + +CSVParser (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +au.com.bytecode.opencsv +
+Class CSVParser

+
+java.lang.Object
+  extended by au.com.bytecode.opencsv.CSVParser
+
+
+
+
public class CSVParser
extends java.lang.Object
+ + +

+A very simple CSV parser released under a commercial-friendly license. + This just implements splitting a single line into fields. +

+ +

+

+
Author:
+
Glen Smith, Rainer Pruy
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static charDEFAULT_ESCAPE_CHARACTER + +
+          The default escape character to use if none is supplied to the + constructor.
+static booleanDEFAULT_IGNORE_LEADING_WHITESPACE + +
+          The default leading whitespace behavior to use if none is supplied to the + constructor
+static charDEFAULT_QUOTE_CHARACTER + +
+          The default quote character to use if none is supplied to the + constructor.
+static charDEFAULT_SEPARATOR + +
+          The default separator to use if none is supplied to the constructor.
+static booleanDEFAULT_STRICT_QUOTES + +
+          The default strict quote behavior to use if none is supplied to the + constructor
+static intINITIAL_READ_SIZE + +
+           
+static charNULL_CHARACTER + +
+          This is the "null" character - if a value is set to this then it is ignored.
+  + + + + + + + + + + + + + + + + + + + + + + + + + +
+Constructor Summary
CSVParser() + +
+          Constructs CSVParser using a comma for the separator.
CSVParser(char separator) + +
+          Constructs CSVParser with supplied separator.
CSVParser(char separator, + char quotechar) + +
+          Constructs CSVParser with supplied separator and quote char.
CSVParser(char separator, + char quotechar, + char escape) + +
+          Constructs CSVReader with supplied separator and quote char.
CSVParser(char separator, + char quotechar, + char escape, + boolean strictQuotes) + +
+          Constructs CSVReader with supplied separator and quote char.
CSVParser(char separator, + char quotechar, + char escape, + boolean strictQuotes, + boolean ignoreLeadingWhiteSpace) + +
+          Constructs CSVReader with supplied separator and quote char.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+protected  booleanisAllWhiteSpace(java.lang.CharSequence sb) + +
+          precondition: sb.length() > 0
+protected  booleanisNextCharacterEscapable(java.lang.String nextLine, + boolean inQuotes, + int i) + +
+          precondition: the current character is an escape
+ booleanisPending() + +
+           
+ java.lang.String[]parseLine(java.lang.String nextLine) + +
+           
+ java.lang.String[]parseLineMulti(java.lang.String nextLine) + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+DEFAULT_SEPARATOR

+
+public static final char DEFAULT_SEPARATOR
+
+
The default separator to use if none is supplied to the constructor. +

+

+
See Also:
Constant Field Values
+
+
+ +

+INITIAL_READ_SIZE

+
+public static final int INITIAL_READ_SIZE
+
+
+
See Also:
Constant Field Values
+
+
+ +

+DEFAULT_QUOTE_CHARACTER

+
+public static final char DEFAULT_QUOTE_CHARACTER
+
+
The default quote character to use if none is supplied to the + constructor. +

+

+
See Also:
Constant Field Values
+
+
+ +

+DEFAULT_ESCAPE_CHARACTER

+
+public static final char DEFAULT_ESCAPE_CHARACTER
+
+
The default escape character to use if none is supplied to the + constructor. +

+

+
See Also:
Constant Field Values
+
+
+ +

+DEFAULT_STRICT_QUOTES

+
+public static final boolean DEFAULT_STRICT_QUOTES
+
+
The default strict quote behavior to use if none is supplied to the + constructor +

+

+
See Also:
Constant Field Values
+
+
+ +

+DEFAULT_IGNORE_LEADING_WHITESPACE

+
+public static final boolean DEFAULT_IGNORE_LEADING_WHITESPACE
+
+
The default leading whitespace behavior to use if none is supplied to the + constructor +

+

+
See Also:
Constant Field Values
+
+
+ +

+NULL_CHARACTER

+
+public static final char NULL_CHARACTER
+
+
This is the "null" character - if a value is set to this then it is ignored. + I.E. if the quote character is set to null then there is no quote character. +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+CSVParser

+
+public CSVParser()
+
+
Constructs CSVParser using a comma for the separator. +

+

+
+ +

+CSVParser

+
+public CSVParser(char separator)
+
+
Constructs CSVParser with supplied separator. +

+

+
Parameters:
separator - the delimiter to use for separating entries.
+
+
+ +

+CSVParser

+
+public CSVParser(char separator,
+                 char quotechar)
+
+
Constructs CSVParser with supplied separator and quote char. +

+

+
Parameters:
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements
+
+
+ +

+CSVParser

+
+public CSVParser(char separator,
+                 char quotechar,
+                 char escape)
+
+
Constructs CSVReader with supplied separator and quote char. +

+

+
Parameters:
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements
escape - the character to use for escaping a separator or quote
+
+
+ +

+CSVParser

+
+public CSVParser(char separator,
+                 char quotechar,
+                 char escape,
+                 boolean strictQuotes)
+
+
Constructs CSVReader with supplied separator and quote char. + Allows setting the "strict quotes" flag +

+

+
Parameters:
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements
escape - the character to use for escaping a separator or quote
strictQuotes - if true, characters outside the quotes are ignored
+
+
+ +

+CSVParser

+
+public CSVParser(char separator,
+                 char quotechar,
+                 char escape,
+                 boolean strictQuotes,
+                 boolean ignoreLeadingWhiteSpace)
+
+
Constructs CSVReader with supplied separator and quote char. + Allows setting the "strict quotes" and "ignore leading whitespace" flags +

+

+
Parameters:
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements
escape - the character to use for escaping a separator or quote
strictQuotes - if true, characters outside the quotes are ignored
ignoreLeadingWhiteSpace - if true, white space in front of a quote in a field is ignored
+
+ + + + + + + + +
+Method Detail
+ +

+isPending

+
+public boolean isPending()
+
+
+ +
Returns:
true if something was left over from last call(s)
+
+
+
+ +

+parseLineMulti

+
+public java.lang.String[] parseLineMulti(java.lang.String nextLine)
+                                  throws java.io.IOException
+
+
+ +
Throws: +
java.io.IOException
+
+
+
+ +

+parseLine

+
+public java.lang.String[] parseLine(java.lang.String nextLine)
+                             throws java.io.IOException
+
+
+ +
Throws: +
java.io.IOException
+
+
+
+ +

+isNextCharacterEscapable

+
+protected boolean isNextCharacterEscapable(java.lang.String nextLine,
+                                           boolean inQuotes,
+                                           int i)
+
+
precondition: the current character is an escape +

+

+
Parameters:
nextLine - the current line
inQuotes - true if the current context is quoted
i - current index in line +
Returns:
true if the following character is a quote
+
+
+
+ +

+isAllWhiteSpace

+
+protected boolean isAllWhiteSpace(java.lang.CharSequence sb)
+
+
precondition: sb.length() > 0 +

+

+
Parameters:
sb - A sequence of characters to examine +
Returns:
true if every character in the sequence is whitespace
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/CSVReader.html b/doc/api/au/com/bytecode/opencsv/CSVReader.html new file mode 100644 index 0000000..7eec6ec --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/CSVReader.html @@ -0,0 +1,574 @@ + + + + + + +CSVReader (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +au.com.bytecode.opencsv +
+Class CSVReader

+
+java.lang.Object
+  extended by au.com.bytecode.opencsv.CSVReader
+
+
+
All Implemented Interfaces:
java.io.Closeable
+
+
+
+
public class CSVReader
extends java.lang.Object
implements java.io.Closeable
+ + +

+A very simple CSV reader released under a commercial-friendly license. +

+ +

+

+
Author:
+
Glen Smith
+
+
+ +

+ + + + + + + + + + + +
+Field Summary
+static intDEFAULT_SKIP_LINES + +
+          The default line to start reading.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Constructor Summary
CSVReader(java.io.Reader reader) + +
+          Constructs CSVReader using a comma for the separator.
CSVReader(java.io.Reader reader, + char separator) + +
+          Constructs CSVReader with supplied separator.
CSVReader(java.io.Reader reader, + char separator, + char quotechar) + +
+          Constructs CSVReader with supplied separator and quote char.
CSVReader(java.io.Reader reader, + char separator, + char quotechar, + boolean strictQuotes) + +
+          Constructs CSVReader with supplied separator, quote char and quote handling + behavior.
CSVReader(java.io.Reader reader, + char separator, + char quotechar, + char escape) + +
+          Constructs CSVReader with supplied separator and quote char.
CSVReader(java.io.Reader reader, + char separator, + char quotechar, + char escape, + int line) + +
+          Constructs CSVReader with supplied separator and quote char.
CSVReader(java.io.Reader reader, + char separator, + char quotechar, + char escape, + int line, + boolean strictQuotes) + +
+          Constructs CSVReader with supplied separator and quote char.
CSVReader(java.io.Reader reader, + char separator, + char quotechar, + char escape, + int line, + boolean strictQuotes, + boolean ignoreLeadingWhiteSpace) + +
+          Constructs CSVReader with supplied separator and quote char.
CSVReader(java.io.Reader reader, + char separator, + char quotechar, + int line) + +
+          Constructs CSVReader with supplied separator and quote char.
+  + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidclose() + +
+          Closes the underlying reader.
+ java.util.List<java.lang.String[]>readAll() + +
+          Reads the entire file into a List with each element being a String[] of + tokens.
+ java.lang.String[]readNext() + +
+          Reads the next line from the buffer and converts to a string array.
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+DEFAULT_SKIP_LINES

+
+public static final int DEFAULT_SKIP_LINES
+
+
The default line to start reading. +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+CSVReader

+
+public CSVReader(java.io.Reader reader)
+
+
Constructs CSVReader using a comma for the separator. +

+

+
Parameters:
reader - the reader to an underlying CSV source.
+
+
+ +

+CSVReader

+
+public CSVReader(java.io.Reader reader,
+                 char separator)
+
+
Constructs CSVReader with supplied separator. +

+

+
Parameters:
reader - the reader to an underlying CSV source.
separator - the delimiter to use for separating entries.
+
+
+ +

+CSVReader

+
+public CSVReader(java.io.Reader reader,
+                 char separator,
+                 char quotechar)
+
+
Constructs CSVReader with supplied separator and quote char. +

+

+
Parameters:
reader - the reader to an underlying CSV source.
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements
+
+
+ +

+CSVReader

+
+public CSVReader(java.io.Reader reader,
+                 char separator,
+                 char quotechar,
+                 boolean strictQuotes)
+
+
Constructs CSVReader with supplied separator, quote char and quote handling + behavior. +

+

+
Parameters:
reader - the reader to an underlying CSV source.
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements
strictQuotes - sets if characters outside the quotes are ignored
+
+
+ +

+CSVReader

+
+public CSVReader(java.io.Reader reader,
+                 char separator,
+                 char quotechar,
+                 char escape)
+
+
Constructs CSVReader with supplied separator and quote char. +

+

+
Parameters:
reader - the reader to an underlying CSV source.
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements
escape - the character to use for escaping a separator or quote
+
+
+ +

+CSVReader

+
+public CSVReader(java.io.Reader reader,
+                 char separator,
+                 char quotechar,
+                 int line)
+
+
Constructs CSVReader with supplied separator and quote char. +

+

+
Parameters:
reader - the reader to an underlying CSV source.
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements
line - the line number to skip for start reading
+
+
+ +

+CSVReader

+
+public CSVReader(java.io.Reader reader,
+                 char separator,
+                 char quotechar,
+                 char escape,
+                 int line)
+
+
Constructs CSVReader with supplied separator and quote char. +

+

+
Parameters:
reader - the reader to an underlying CSV source.
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements
escape - the character to use for escaping a separator or quote
line - the line number to skip for start reading
+
+
+ +

+CSVReader

+
+public CSVReader(java.io.Reader reader,
+                 char separator,
+                 char quotechar,
+                 char escape,
+                 int line,
+                 boolean strictQuotes)
+
+
Constructs CSVReader with supplied separator and quote char. +

+

+
Parameters:
reader - the reader to an underlying CSV source.
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements
escape - the character to use for escaping a separator or quote
line - the line number to skip for start reading
strictQuotes - sets if characters outside the quotes are ignored
+
+
+ +

+CSVReader

+
+public CSVReader(java.io.Reader reader,
+                 char separator,
+                 char quotechar,
+                 char escape,
+                 int line,
+                 boolean strictQuotes,
+                 boolean ignoreLeadingWhiteSpace)
+
+
Constructs CSVReader with supplied separator and quote char. +

+

+
Parameters:
reader - the reader to an underlying CSV source.
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements
escape - the character to use for escaping a separator or quote
line - the line number to skip for start reading
strictQuotes - sets if characters outside the quotes are ignored
ignoreLeadingWhiteSpace - it true, parser should ignore white space before a quote in a field
+
+ + + + + + + + +
+Method Detail
+ +

+readAll

+
+public java.util.List<java.lang.String[]> readAll()
+                                           throws java.io.IOException
+
+
Reads the entire file into a List with each element being a String[] of + tokens. +

+

+
+
+
+ +
Returns:
a List of String[], with each String[] representing a line of the + file. +
Throws: +
java.io.IOException - if bad things happen during the read
+
+
+
+ +

+readNext

+
+public java.lang.String[] readNext()
+                            throws java.io.IOException
+
+
Reads the next line from the buffer and converts to a string array. +

+

+
+
+
+ +
Returns:
a string array with each comma-separated element as a separate + entry. +
Throws: +
java.io.IOException - if bad things happen during the read
+
+
+
+ +

+close

+
+public void close()
+           throws java.io.IOException
+
+
Closes the underlying reader. +

+

+
Specified by:
close in interface java.io.Closeable
+
+
+ +
Throws: +
java.io.IOException - if the close fails
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/CSVWriter.html b/doc/api/au/com/bytecode/opencsv/CSVWriter.html new file mode 100644 index 0000000..b9b0d4b --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/CSVWriter.html @@ -0,0 +1,754 @@ + + + + + + +CSVWriter (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +au.com.bytecode.opencsv +
+Class CSVWriter

+
+java.lang.Object
+  extended by au.com.bytecode.opencsv.CSVWriter
+
+
+
All Implemented Interfaces:
java.io.Closeable
+
+
+
+
public class CSVWriter
extends java.lang.Object
implements java.io.Closeable
+ + +

+A very simple CSV writer released under a commercial-friendly license. +

+ +

+

+
Author:
+
Glen Smith
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static charDEFAULT_ESCAPE_CHARACTER + +
+          The character used for escaping quotes.
+static java.lang.StringDEFAULT_LINE_END + +
+          Default line terminator uses platform encoding.
+static charDEFAULT_QUOTE_CHARACTER + +
+          The default quote character to use if none is supplied to the + constructor.
+static charDEFAULT_SEPARATOR + +
+          The default separator to use if none is supplied to the constructor.
+static intINITIAL_STRING_SIZE + +
+           
+static charNO_ESCAPE_CHARACTER + +
+          The escape constant to use when you wish to suppress all escaping.
+static charNO_QUOTE_CHARACTER + +
+          The quote constant to use when you wish to suppress all quoting.
+  + + + + + + + + + + + + + + + + + + + + + + + + + +
+Constructor Summary
CSVWriter(java.io.Writer writer) + +
+          Constructs CSVWriter using a comma for the separator.
CSVWriter(java.io.Writer writer, + char separator) + +
+          Constructs CSVWriter with supplied separator.
CSVWriter(java.io.Writer writer, + char separator, + char quotechar) + +
+          Constructs CSVWriter with supplied separator and quote char.
CSVWriter(java.io.Writer writer, + char separator, + char quotechar, + char escapechar) + +
+          Constructs CSVWriter with supplied separator and quote char.
CSVWriter(java.io.Writer writer, + char separator, + char quotechar, + char escapechar, + java.lang.String lineEnd) + +
+          Constructs CSVWriter with supplied separator, quote char, escape char and line ending.
CSVWriter(java.io.Writer writer, + char separator, + char quotechar, + java.lang.String lineEnd) + +
+          Constructs CSVWriter with supplied separator and quote char.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ booleancheckError() + +
+          Checks to see if the there has been an error in the printstream.
+ voidclose() + +
+          Close the underlying stream writer flushing any buffered content.
+ voidflush() + +
+          Flush underlying stream to writer.
+protected  java.lang.StringBuilderprocessLine(java.lang.String nextElement) + +
+           
+ voidsetResultService(ResultSetHelper resultService) + +
+           
+ voidwriteAll(java.util.List<java.lang.String[]> allLines) + +
+          Writes the entire list to a CSV file.
+ voidwriteAll(java.sql.ResultSet rs, + boolean includeColumnNames) + +
+          Writes the entire ResultSet to a CSV file.
+protected  voidwriteColumnNames(java.sql.ResultSet rs) + +
+           
+ voidwriteNext(java.lang.String[] nextLine) + +
+          Writes the next line to the file.
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+INITIAL_STRING_SIZE

+
+public static final int INITIAL_STRING_SIZE
+
+
+
See Also:
Constant Field Values
+
+
+ +

+DEFAULT_ESCAPE_CHARACTER

+
+public static final char DEFAULT_ESCAPE_CHARACTER
+
+
The character used for escaping quotes. +

+

+
See Also:
Constant Field Values
+
+
+ +

+DEFAULT_SEPARATOR

+
+public static final char DEFAULT_SEPARATOR
+
+
The default separator to use if none is supplied to the constructor. +

+

+
See Also:
Constant Field Values
+
+
+ +

+DEFAULT_QUOTE_CHARACTER

+
+public static final char DEFAULT_QUOTE_CHARACTER
+
+
The default quote character to use if none is supplied to the + constructor. +

+

+
See Also:
Constant Field Values
+
+
+ +

+NO_QUOTE_CHARACTER

+
+public static final char NO_QUOTE_CHARACTER
+
+
The quote constant to use when you wish to suppress all quoting. +

+

+
See Also:
Constant Field Values
+
+
+ +

+NO_ESCAPE_CHARACTER

+
+public static final char NO_ESCAPE_CHARACTER
+
+
The escape constant to use when you wish to suppress all escaping. +

+

+
See Also:
Constant Field Values
+
+
+ +

+DEFAULT_LINE_END

+
+public static final java.lang.String DEFAULT_LINE_END
+
+
Default line terminator uses platform encoding. +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+CSVWriter

+
+public CSVWriter(java.io.Writer writer)
+
+
Constructs CSVWriter using a comma for the separator. +

+

+
Parameters:
writer - the writer to an underlying CSV source.
+
+
+ +

+CSVWriter

+
+public CSVWriter(java.io.Writer writer,
+                 char separator)
+
+
Constructs CSVWriter with supplied separator. +

+

+
Parameters:
writer - the writer to an underlying CSV source.
separator - the delimiter to use for separating entries.
+
+
+ +

+CSVWriter

+
+public CSVWriter(java.io.Writer writer,
+                 char separator,
+                 char quotechar)
+
+
Constructs CSVWriter with supplied separator and quote char. +

+

+
Parameters:
writer - the writer to an underlying CSV source.
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements
+
+
+ +

+CSVWriter

+
+public CSVWriter(java.io.Writer writer,
+                 char separator,
+                 char quotechar,
+                 char escapechar)
+
+
Constructs CSVWriter with supplied separator and quote char. +

+

+
Parameters:
writer - the writer to an underlying CSV source.
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements
escapechar - the character to use for escaping quotechars or escapechars
+
+
+ +

+CSVWriter

+
+public CSVWriter(java.io.Writer writer,
+                 char separator,
+                 char quotechar,
+                 java.lang.String lineEnd)
+
+
Constructs CSVWriter with supplied separator and quote char. +

+

+
Parameters:
writer - the writer to an underlying CSV source.
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements
lineEnd - the line feed terminator to use
+
+
+ +

+CSVWriter

+
+public CSVWriter(java.io.Writer writer,
+                 char separator,
+                 char quotechar,
+                 char escapechar,
+                 java.lang.String lineEnd)
+
+
Constructs CSVWriter with supplied separator, quote char, escape char and line ending. +

+

+
Parameters:
writer - the writer to an underlying CSV source.
separator - the delimiter to use for separating entries
quotechar - the character to use for quoted elements
escapechar - the character to use for escaping quotechars or escapechars
lineEnd - the line feed terminator to use
+
+ + + + + + + + +
+Method Detail
+ +

+writeAll

+
+public void writeAll(java.util.List<java.lang.String[]> allLines)
+
+
Writes the entire list to a CSV file. The list is assumed to be a + String[] +

+

+
+
+
+
Parameters:
allLines - a List of String[], with each String[] representing a line of + the file.
+
+
+
+ +

+writeColumnNames

+
+protected void writeColumnNames(java.sql.ResultSet rs)
+                         throws java.sql.SQLException
+
+
+
+
+
+ +
Throws: +
java.sql.SQLException
+
+
+
+ +

+writeAll

+
+public void writeAll(java.sql.ResultSet rs,
+                     boolean includeColumnNames)
+              throws java.sql.SQLException,
+                     java.io.IOException
+
+
Writes the entire ResultSet to a CSV file. + + The caller is responsible for closing the ResultSet. +

+

+
+
+
+
Parameters:
rs - the recordset to write
includeColumnNames - true if you want column names in the output, false otherwise +
Throws: +
java.io.IOException - thrown by getColumnValue +
java.sql.SQLException - thrown by getColumnValue
+
+
+
+ +

+writeNext

+
+public void writeNext(java.lang.String[] nextLine)
+
+
Writes the next line to the file. +

+

+
+
+
+
Parameters:
nextLine - a string array with each comma-separated element as a separate + entry.
+
+
+
+ +

+processLine

+
+protected java.lang.StringBuilder processLine(java.lang.String nextElement)
+
+
+
+
+
+
+
+
+
+ +

+flush

+
+public void flush()
+           throws java.io.IOException
+
+
Flush underlying stream to writer. +

+

+
+
+
+ +
Throws: +
java.io.IOException - if bad things happen
+
+
+
+ +

+close

+
+public void close()
+           throws java.io.IOException
+
+
Close the underlying stream writer flushing any buffered content. +

+

+
Specified by:
close in interface java.io.Closeable
+
+
+ +
Throws: +
java.io.IOException - if bad things happen
+
+
+
+ +

+checkError

+
+public boolean checkError()
+
+
Checks to see if the there has been an error in the printstream. +

+

+
+
+
+
+
+
+
+ +

+setResultService

+
+public void setResultService(ResultSetHelper resultService)
+
+
+
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/ResultSetHelper.html b/doc/api/au/com/bytecode/opencsv/ResultSetHelper.html new file mode 100644 index 0000000..447b0b4 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/ResultSetHelper.html @@ -0,0 +1,237 @@ + + + + + + +ResultSetHelper (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +au.com.bytecode.opencsv +
+Interface ResultSetHelper

+
+
All Known Implementing Classes:
ResultSetHelperService
+
+
+
+
public interface ResultSetHelper
+ + +

+


+ +

+ + + + + + + + + + + + + + + + +
+Method Summary
+ java.lang.String[]getColumnNames(java.sql.ResultSet rs) + +
+           
+ java.lang.String[]getColumnValues(java.sql.ResultSet rs) + +
+           
+  +

+ + + + + + + + +
+Method Detail
+ +

+getColumnNames

+
+java.lang.String[] getColumnNames(java.sql.ResultSet rs)
+                                  throws java.sql.SQLException
+
+
+ +
Throws: +
java.sql.SQLException
+
+
+
+ +

+getColumnValues

+
+java.lang.String[] getColumnValues(java.sql.ResultSet rs)
+                                   throws java.sql.SQLException,
+                                          java.io.IOException
+
+
+ +
Throws: +
java.sql.SQLException +
java.io.IOException
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/ResultSetHelperService.html b/doc/api/au/com/bytecode/opencsv/ResultSetHelperService.html new file mode 100644 index 0000000..f18c2a8 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/ResultSetHelperService.html @@ -0,0 +1,329 @@ + + + + + + +ResultSetHelperService (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +au.com.bytecode.opencsv +
+Class ResultSetHelperService

+
+java.lang.Object
+  extended by au.com.bytecode.opencsv.ResultSetHelperService
+
+
+
All Implemented Interfaces:
ResultSetHelper
+
+
+
+
public class ResultSetHelperService
extends java.lang.Object
implements ResultSetHelper
+ + +

+helper class for processing JDBC ResultSet objects +

+ +

+


+ +

+ + + + + + + + + + + +
+Field Summary
+static intCLOBBUFFERSIZE + +
+           
+  + + + + + + + + + + +
+Constructor Summary
ResultSetHelperService() + +
+           
+  + + + + + + + + + + + + + + + +
+Method Summary
+ java.lang.String[]getColumnNames(java.sql.ResultSet rs) + +
+           
+ java.lang.String[]getColumnValues(java.sql.ResultSet rs) + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+CLOBBUFFERSIZE

+
+public static final int CLOBBUFFERSIZE
+
+
+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+ResultSetHelperService

+
+public ResultSetHelperService()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getColumnNames

+
+public java.lang.String[] getColumnNames(java.sql.ResultSet rs)
+                                  throws java.sql.SQLException
+
+
+
Specified by:
getColumnNames in interface ResultSetHelper
+
+
+ +
Throws: +
java.sql.SQLException
+
+
+
+ +

+getColumnValues

+
+public java.lang.String[] getColumnValues(java.sql.ResultSet rs)
+                                   throws java.sql.SQLException,
+                                          java.io.IOException
+
+
+
Specified by:
getColumnValues in interface ResultSetHelper
+
+
+ +
Throws: +
java.sql.SQLException +
java.io.IOException
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/bean/ColumnPositionMappingStrategy.html b/doc/api/au/com/bytecode/opencsv/bean/ColumnPositionMappingStrategy.html new file mode 100644 index 0000000..dfa65ea --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/bean/ColumnPositionMappingStrategy.html @@ -0,0 +1,371 @@ + + + + + + +ColumnPositionMappingStrategy (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +au.com.bytecode.opencsv.bean +
+Class ColumnPositionMappingStrategy<T>

+
+java.lang.Object
+  extended by au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy<T>
+      extended by au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy<T>
+
+
+
All Implemented Interfaces:
MappingStrategy<T>
+
+
+
+
public class ColumnPositionMappingStrategy<T>
extends HeaderColumnNameMappingStrategy<T>
+ + +

+Copyright 2007 Kyle Miller. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +

+ +

+


+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy
descriptorMap, header, type
+  + + + + + + + + + + +
+Constructor Summary
ColumnPositionMappingStrategy() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidcaptureHeader(CSVReader reader) + +
+          Implementation of this method can grab the header line before parsing begins to use to map columns + to bean properties.
+ java.lang.String[]getColumnMapping() + +
+           
+protected  java.lang.StringgetColumnName(int col) + +
+           
+ voidsetColumnMapping(java.lang.String[] columnMapping) + +
+           
+ + + + + + + +
Methods inherited from class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy
createBean, findDescriptor, findDescriptor, getType, loadDescriptorMap, matches, setType
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+ColumnPositionMappingStrategy

+
+public ColumnPositionMappingStrategy()
+
+
+ + + + + + + + +
+Method Detail
+ +

+captureHeader

+
+public void captureHeader(CSVReader reader)
+                   throws java.io.IOException
+
+
Description copied from interface: MappingStrategy
+
Implementation of this method can grab the header line before parsing begins to use to map columns + to bean properties. +

+

+
Specified by:
captureHeader in interface MappingStrategy<T>
Overrides:
captureHeader in class HeaderColumnNameMappingStrategy<T>
+
+
+
Parameters:
reader - the CSVReader to use for header parsing +
Throws: +
java.io.IOException - if parsing fails
+
+
+
+ +

+getColumnName

+
+protected java.lang.String getColumnName(int col)
+
+
+
Overrides:
getColumnName in class HeaderColumnNameMappingStrategy<T>
+
+
+
+
+
+
+ +

+getColumnMapping

+
+public java.lang.String[] getColumnMapping()
+
+
+
+
+
+
+ +

+setColumnMapping

+
+public void setColumnMapping(java.lang.String[] columnMapping)
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/bean/CsvToBean.html b/doc/api/au/com/bytecode/opencsv/bean/CsvToBean.html new file mode 100644 index 0000000..1a5e91f --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/bean/CsvToBean.html @@ -0,0 +1,356 @@ + + + + + + +CsvToBean (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +au.com.bytecode.opencsv.bean +
+Class CsvToBean<T>

+
+java.lang.Object
+  extended by au.com.bytecode.opencsv.bean.CsvToBean<T>
+
+
+
+
public class CsvToBean<T>
extends java.lang.Object
+ + +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
CsvToBean() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+protected  java.lang.ObjectconvertValue(java.lang.String value, + java.beans.PropertyDescriptor prop) + +
+           
+protected  java.beans.PropertyEditorgetPropertyEditor(java.beans.PropertyDescriptor desc) + +
+           
+ java.util.List<T>parse(MappingStrategy<T> mapper, + CSVReader csv) + +
+           
+ java.util.List<T>parse(MappingStrategy<T> mapper, + java.io.Reader reader) + +
+           
+protected  TprocessLine(MappingStrategy<T> mapper, + java.lang.String[] line) + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+CsvToBean

+
+public CsvToBean()
+
+
+ + + + + + + + +
+Method Detail
+ +

+parse

+
+public java.util.List<T> parse(MappingStrategy<T> mapper,
+                               java.io.Reader reader)
+
+
+
+
+
+
+ +

+parse

+
+public java.util.List<T> parse(MappingStrategy<T> mapper,
+                               CSVReader csv)
+
+
+
+
+
+
+ +

+processLine

+
+protected T processLine(MappingStrategy<T> mapper,
+                        java.lang.String[] line)
+                 throws java.lang.IllegalAccessException,
+                        java.lang.reflect.InvocationTargetException,
+                        java.lang.InstantiationException,
+                        java.beans.IntrospectionException
+
+
+ +
Throws: +
java.lang.IllegalAccessException +
java.lang.reflect.InvocationTargetException +
java.lang.InstantiationException +
java.beans.IntrospectionException
+
+
+
+ +

+convertValue

+
+protected java.lang.Object convertValue(java.lang.String value,
+                                        java.beans.PropertyDescriptor prop)
+                                 throws java.lang.InstantiationException,
+                                        java.lang.IllegalAccessException
+
+
+ +
Throws: +
java.lang.InstantiationException +
java.lang.IllegalAccessException
+
+
+
+ +

+getPropertyEditor

+
+protected java.beans.PropertyEditor getPropertyEditor(java.beans.PropertyDescriptor desc)
+                                               throws java.lang.InstantiationException,
+                                                      java.lang.IllegalAccessException
+
+
+ +
Throws: +
java.lang.InstantiationException +
java.lang.IllegalAccessException
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/bean/HeaderColumnNameMappingStrategy.html b/doc/api/au/com/bytecode/opencsv/bean/HeaderColumnNameMappingStrategy.html new file mode 100644 index 0000000..7f62faf --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/bean/HeaderColumnNameMappingStrategy.html @@ -0,0 +1,554 @@ + + + + + + +HeaderColumnNameMappingStrategy (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +au.com.bytecode.opencsv.bean +
+Class HeaderColumnNameMappingStrategy<T>

+
+java.lang.Object
+  extended by au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy<T>
+
+
+
All Implemented Interfaces:
MappingStrategy<T>
+
+
+
Direct Known Subclasses:
ColumnPositionMappingStrategy, HeaderColumnNameTranslateMappingStrategy
+
+
+
+
public class HeaderColumnNameMappingStrategy<T>
extends java.lang.Object
implements MappingStrategy<T>
+ + +

+Copyright 2007 Kyle Miller. +

+ Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at +

+ http://www.apache.org/licenses/LICENSE-2.0 +

+ Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + +
+Field Summary
+protected  java.util.Map<java.lang.String,java.beans.PropertyDescriptor>descriptorMap + +
+           
+protected  java.lang.String[]header + +
+           
+protected  java.lang.Class<T>type + +
+           
+  + + + + + + + + + + +
+Constructor Summary
HeaderColumnNameMappingStrategy() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidcaptureHeader(CSVReader reader) + +
+          Implementation of this method can grab the header line before parsing begins to use to map columns + to bean properties.
+ TcreateBean() + +
+           
+ java.beans.PropertyDescriptorfindDescriptor(int col) + +
+          Implementation will have to return a property descriptor from a bean based on the current column.
+protected  java.beans.PropertyDescriptorfindDescriptor(java.lang.String name) + +
+           
+protected  java.lang.StringgetColumnName(int col) + +
+           
+ java.lang.Class<T>getType() + +
+           
+protected  java.util.Map<java.lang.String,java.beans.PropertyDescriptor>loadDescriptorMap(java.lang.Class<T> cls) + +
+           
+protected  booleanmatches(java.lang.String name, + java.beans.PropertyDescriptor desc) + +
+           
+ voidsetType(java.lang.Class<T> type) + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+header

+
+protected java.lang.String[] header
+
+
+
+
+
+ +

+descriptorMap

+
+protected java.util.Map<java.lang.String,java.beans.PropertyDescriptor> descriptorMap
+
+
+
+
+
+ +

+type

+
+protected java.lang.Class<T> type
+
+
+
+
+ + + + + + + + +
+Constructor Detail
+ +

+HeaderColumnNameMappingStrategy

+
+public HeaderColumnNameMappingStrategy()
+
+
+ + + + + + + + +
+Method Detail
+ +

+captureHeader

+
+public void captureHeader(CSVReader reader)
+                   throws java.io.IOException
+
+
Description copied from interface: MappingStrategy
+
Implementation of this method can grab the header line before parsing begins to use to map columns + to bean properties. +

+

+
Specified by:
captureHeader in interface MappingStrategy<T>
+
+
+
Parameters:
reader - the CSVReader to use for header parsing +
Throws: +
java.io.IOException - if parsing fails
+
+
+
+ +

+findDescriptor

+
+public java.beans.PropertyDescriptor findDescriptor(int col)
+                                             throws java.beans.IntrospectionException
+
+
Description copied from interface: MappingStrategy
+
Implementation will have to return a property descriptor from a bean based on the current column. +

+

+
Specified by:
findDescriptor in interface MappingStrategy<T>
+
+
+
Parameters:
col - the column to find the description for +
Returns:
the related PropertyDescriptor +
Throws: +
java.beans.IntrospectionException
+
+
+
+ +

+getColumnName

+
+protected java.lang.String getColumnName(int col)
+
+
+
+
+
+
+
+
+
+ +

+findDescriptor

+
+protected java.beans.PropertyDescriptor findDescriptor(java.lang.String name)
+                                                throws java.beans.IntrospectionException
+
+
+
+
+
+ +
Throws: +
java.beans.IntrospectionException
+
+
+
+ +

+matches

+
+protected boolean matches(java.lang.String name,
+                          java.beans.PropertyDescriptor desc)
+
+
+
+
+
+
+
+
+
+ +

+loadDescriptorMap

+
+protected java.util.Map<java.lang.String,java.beans.PropertyDescriptor> loadDescriptorMap(java.lang.Class<T> cls)
+                                                                                   throws java.beans.IntrospectionException
+
+
+
+
+
+ +
Throws: +
java.beans.IntrospectionException
+
+
+
+ +

+createBean

+
+public T createBean()
+             throws java.lang.InstantiationException,
+                    java.lang.IllegalAccessException
+
+
+
Specified by:
createBean in interface MappingStrategy<T>
+
+
+ +
Throws: +
java.lang.InstantiationException +
java.lang.IllegalAccessException
+
+
+
+ +

+getType

+
+public java.lang.Class<T> getType()
+
+
+
+
+
+
+
+
+
+ +

+setType

+
+public void setType(java.lang.Class<T> type)
+
+
+
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/bean/HeaderColumnNameTranslateMappingStrategy.html b/doc/api/au/com/bytecode/opencsv/bean/HeaderColumnNameTranslateMappingStrategy.html new file mode 100644 index 0000000..8798441 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/bean/HeaderColumnNameTranslateMappingStrategy.html @@ -0,0 +1,341 @@ + + + + + + +HeaderColumnNameTranslateMappingStrategy (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +au.com.bytecode.opencsv.bean +
+Class HeaderColumnNameTranslateMappingStrategy<T>

+
+java.lang.Object
+  extended by au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy<T>
+      extended by au.com.bytecode.opencsv.bean.HeaderColumnNameTranslateMappingStrategy<T>
+
+
+
All Implemented Interfaces:
MappingStrategy<T>
+
+
+
+
public class HeaderColumnNameTranslateMappingStrategy<T>
extends HeaderColumnNameMappingStrategy<T>
+ + +

+Copyright 2007,2010 Kyle Miller. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +

+ +

+


+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy
descriptorMap, header, type
+  + + + + + + + + + + +
+Constructor Summary
HeaderColumnNameTranslateMappingStrategy() + +
+           
+  + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ java.util.Map<java.lang.String,java.lang.String>getColumnMapping() + +
+           
+protected  java.lang.StringgetColumnName(int col) + +
+           
+ voidsetColumnMapping(java.util.Map<java.lang.String,java.lang.String> columnMapping) + +
+           
+ + + + + + + +
Methods inherited from class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy
captureHeader, createBean, findDescriptor, findDescriptor, getType, loadDescriptorMap, matches, setType
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+HeaderColumnNameTranslateMappingStrategy

+
+public HeaderColumnNameTranslateMappingStrategy()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getColumnName

+
+protected java.lang.String getColumnName(int col)
+
+
+
Overrides:
getColumnName in class HeaderColumnNameMappingStrategy<T>
+
+
+
+
+
+
+ +

+getColumnMapping

+
+public java.util.Map<java.lang.String,java.lang.String> getColumnMapping()
+
+
+
+
+
+
+ +

+setColumnMapping

+
+public void setColumnMapping(java.util.Map<java.lang.String,java.lang.String> columnMapping)
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/bean/MappingStrategy.html b/doc/api/au/com/bytecode/opencsv/bean/MappingStrategy.html new file mode 100644 index 0000000..82da663 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/bean/MappingStrategy.html @@ -0,0 +1,266 @@ + + + + + + +MappingStrategy (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +au.com.bytecode.opencsv.bean +
+Interface MappingStrategy<T>

+
+
All Known Implementing Classes:
ColumnPositionMappingStrategy, HeaderColumnNameMappingStrategy, HeaderColumnNameTranslateMappingStrategy
+
+
+
+
public interface MappingStrategy<T>
+ + +

+


+ +

+ + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidcaptureHeader(CSVReader reader) + +
+          Implementation of this method can grab the header line before parsing begins to use to map columns + to bean properties.
+ TcreateBean() + +
+           
+ java.beans.PropertyDescriptorfindDescriptor(int col) + +
+          Implementation will have to return a property descriptor from a bean based on the current column.
+  +

+ + + + + + + + +
+Method Detail
+ +

+findDescriptor

+
+java.beans.PropertyDescriptor findDescriptor(int col)
+                                             throws java.beans.IntrospectionException
+
+
Implementation will have to return a property descriptor from a bean based on the current column. +

+

+
Parameters:
col - the column to find the description for +
Returns:
the related PropertyDescriptor +
Throws: +
java.beans.IntrospectionException
+
+
+
+ +

+createBean

+
+T createBean()
+             throws java.lang.InstantiationException,
+                    java.lang.IllegalAccessException
+
+
+ +
Throws: +
java.lang.InstantiationException +
java.lang.IllegalAccessException
+
+
+
+ +

+captureHeader

+
+void captureHeader(CSVReader reader)
+                   throws java.io.IOException
+
+
Implementation of this method can grab the header line before parsing begins to use to map columns + to bean properties. +

+

+
Parameters:
reader - the CSVReader to use for header parsing +
Throws: +
java.io.IOException - if parsing fails
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/bean/class-use/ColumnPositionMappingStrategy.html b/doc/api/au/com/bytecode/opencsv/bean/class-use/ColumnPositionMappingStrategy.html new file mode 100644 index 0000000..6c779c7 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/bean/class-use/ColumnPositionMappingStrategy.html @@ -0,0 +1,145 @@ + + + + + + +Uses of Class au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy

+
+No usage of au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/bean/class-use/CsvToBean.html b/doc/api/au/com/bytecode/opencsv/bean/class-use/CsvToBean.html new file mode 100644 index 0000000..0cbde33 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/bean/class-use/CsvToBean.html @@ -0,0 +1,145 @@ + + + + + + +Uses of Class au.com.bytecode.opencsv.bean.CsvToBean (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
au.com.bytecode.opencsv.bean.CsvToBean

+
+No usage of au.com.bytecode.opencsv.bean.CsvToBean +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/bean/class-use/HeaderColumnNameMappingStrategy.html b/doc/api/au/com/bytecode/opencsv/bean/class-use/HeaderColumnNameMappingStrategy.html new file mode 100644 index 0000000..76a7417 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/bean/class-use/HeaderColumnNameMappingStrategy.html @@ -0,0 +1,190 @@ + + + + + + +Uses of Class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy

+
+ + + + + + + + + +
+Packages that use HeaderColumnNameMappingStrategy
au.com.bytecode.opencsv.bean +A simple bean binding interface for use with opencsv. 
+  +

+ + + + + +
+Uses of HeaderColumnNameMappingStrategy in au.com.bytecode.opencsv.bean
+  +

+ + + + + + + + + + + + + +
Subclasses of HeaderColumnNameMappingStrategy in au.com.bytecode.opencsv.bean
+ classColumnPositionMappingStrategy<T> + +
+          Copyright 2007 Kyle Miller.
+ classHeaderColumnNameTranslateMappingStrategy<T> + +
+          Copyright 2007,2010 Kyle Miller.
+  +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/bean/class-use/HeaderColumnNameTranslateMappingStrategy.html b/doc/api/au/com/bytecode/opencsv/bean/class-use/HeaderColumnNameTranslateMappingStrategy.html new file mode 100644 index 0000000..a1c8c57 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/bean/class-use/HeaderColumnNameTranslateMappingStrategy.html @@ -0,0 +1,145 @@ + + + + + + +Uses of Class au.com.bytecode.opencsv.bean.HeaderColumnNameTranslateMappingStrategy (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
au.com.bytecode.opencsv.bean.HeaderColumnNameTranslateMappingStrategy

+
+No usage of au.com.bytecode.opencsv.bean.HeaderColumnNameTranslateMappingStrategy +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/bean/class-use/MappingStrategy.html b/doc/api/au/com/bytecode/opencsv/bean/class-use/MappingStrategy.html new file mode 100644 index 0000000..f232338 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/bean/class-use/MappingStrategy.html @@ -0,0 +1,233 @@ + + + + + + +Uses of Interface au.com.bytecode.opencsv.bean.MappingStrategy (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Interface
au.com.bytecode.opencsv.bean.MappingStrategy

+
+ + + + + + + + + +
+Packages that use MappingStrategy
au.com.bytecode.opencsv.bean +A simple bean binding interface for use with opencsv. 
+  +

+ + + + + +
+Uses of MappingStrategy in au.com.bytecode.opencsv.bean
+  +

+ + + + + + + + + + + + + + + + + +
Classes in au.com.bytecode.opencsv.bean that implement MappingStrategy
+ classColumnPositionMappingStrategy<T> + +
+          Copyright 2007 Kyle Miller.
+ classHeaderColumnNameMappingStrategy<T> + +
+          Copyright 2007 Kyle Miller.
+ classHeaderColumnNameTranslateMappingStrategy<T> + +
+          Copyright 2007,2010 Kyle Miller.
+  +

+ + + + + + + + + + + + + + + + + +
Methods in au.com.bytecode.opencsv.bean with parameters of type MappingStrategy
+ java.util.List<T>CsvToBean.parse(MappingStrategy<T> mapper, + CSVReader csv) + +
+           
+ java.util.List<T>CsvToBean.parse(MappingStrategy<T> mapper, + java.io.Reader reader) + +
+           
+protected  TCsvToBean.processLine(MappingStrategy<T> mapper, + java.lang.String[] line) + +
+           
+  +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/bean/package-frame.html b/doc/api/au/com/bytecode/opencsv/bean/package-frame.html new file mode 100644 index 0000000..ae2b5fb --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/bean/package-frame.html @@ -0,0 +1,49 @@ + + + + + + +au.com.bytecode.opencsv.bean (opencsv API 2.3) + + + + + + + + + + + +au.com.bytecode.opencsv.bean + + + + +
+Interfaces  + +
+MappingStrategy
+ + + + + + +
+Classes  + +
+ColumnPositionMappingStrategy +
+CsvToBean +
+HeaderColumnNameMappingStrategy +
+HeaderColumnNameTranslateMappingStrategy
+ + + + diff --git a/doc/api/au/com/bytecode/opencsv/bean/package-summary.html b/doc/api/au/com/bytecode/opencsv/bean/package-summary.html new file mode 100644 index 0000000..6569d66 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/bean/package-summary.html @@ -0,0 +1,204 @@ + + + + + + +au.com.bytecode.opencsv.bean (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package au.com.bytecode.opencsv.bean +

+ +A simple bean binding interface for use with opencsv. +

+See: +
+          Description +

+ + + + + + + + + +
+Interface Summary
MappingStrategy<T> 
+  + +

+ + + + + + + + + + + + + + + + + + + + + +
+Class Summary
ColumnPositionMappingStrategy<T>Copyright 2007 Kyle Miller.
CsvToBean<T> 
HeaderColumnNameMappingStrategy<T>Copyright 2007 Kyle Miller.
HeaderColumnNameTranslateMappingStrategy<T>Copyright 2007,2010 Kyle Miller.
+  + +

+

+Package au.com.bytecode.opencsv.bean Description +

+ +

+

+A simple bean binding interface for use with opencsv. +

+
+opencsv.sourceforge.net +

+ +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/bean/package-tree.html b/doc/api/au/com/bytecode/opencsv/bean/package-tree.html new file mode 100644 index 0000000..631bb01 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/bean/package-tree.html @@ -0,0 +1,162 @@ + + + + + + +au.com.bytecode.opencsv.bean Class Hierarchy (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package au.com.bytecode.opencsv.bean +

+
+
+
Package Hierarchies:
All Packages
+
+

+Class Hierarchy +

+ +

+Interface Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/bean/package-use.html b/doc/api/au/com/bytecode/opencsv/bean/package-use.html new file mode 100644 index 0000000..94386be --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/bean/package-use.html @@ -0,0 +1,178 @@ + + + + + + +Uses of Package au.com.bytecode.opencsv.bean (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Package
au.com.bytecode.opencsv.bean

+
+ + + + + + + + + +
+Packages that use au.com.bytecode.opencsv.bean
au.com.bytecode.opencsv.bean +A simple bean binding interface for use with opencsv. 
+  +

+ + + + + + + + + + + +
+Classes in au.com.bytecode.opencsv.bean used by au.com.bytecode.opencsv.bean
HeaderColumnNameMappingStrategy + +
+          Copyright 2007 Kyle Miller.
MappingStrategy + +
+           
+  +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/class-use/CSVParser.html b/doc/api/au/com/bytecode/opencsv/class-use/CSVParser.html new file mode 100644 index 0000000..b0b7069 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/class-use/CSVParser.html @@ -0,0 +1,145 @@ + + + + + + +Uses of Class au.com.bytecode.opencsv.CSVParser (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
au.com.bytecode.opencsv.CSVParser

+
+No usage of au.com.bytecode.opencsv.CSVParser +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/class-use/CSVReader.html b/doc/api/au/com/bytecode/opencsv/class-use/CSVReader.html new file mode 100644 index 0000000..0c9ff69 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/class-use/CSVReader.html @@ -0,0 +1,208 @@ + + + + + + +Uses of Class au.com.bytecode.opencsv.CSVReader (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
au.com.bytecode.opencsv.CSVReader

+
+ + + + + + + + + +
+Packages that use CSVReader
au.com.bytecode.opencsv.bean +A simple bean binding interface for use with opencsv. 
+  +

+ + + + + +
+Uses of CSVReader in au.com.bytecode.opencsv.bean
+  +

+ + + + + + + + + + + + + + + + + + + + + +
Methods in au.com.bytecode.opencsv.bean with parameters of type CSVReader
+ voidHeaderColumnNameMappingStrategy.captureHeader(CSVReader reader) + +
+           
+ voidColumnPositionMappingStrategy.captureHeader(CSVReader reader) + +
+           
+ voidMappingStrategy.captureHeader(CSVReader reader) + +
+          Implementation of this method can grab the header line before parsing begins to use to map columns + to bean properties.
+ java.util.List<T>CsvToBean.parse(MappingStrategy<T> mapper, + CSVReader csv) + +
+           
+  +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/class-use/CSVWriter.html b/doc/api/au/com/bytecode/opencsv/class-use/CSVWriter.html new file mode 100644 index 0000000..01ec694 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/class-use/CSVWriter.html @@ -0,0 +1,145 @@ + + + + + + +Uses of Class au.com.bytecode.opencsv.CSVWriter (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
au.com.bytecode.opencsv.CSVWriter

+
+No usage of au.com.bytecode.opencsv.CSVWriter +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/class-use/ResultSetHelper.html b/doc/api/au/com/bytecode/opencsv/class-use/ResultSetHelper.html new file mode 100644 index 0000000..b7beda9 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/class-use/ResultSetHelper.html @@ -0,0 +1,198 @@ + + + + + + +Uses of Interface au.com.bytecode.opencsv.ResultSetHelper (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Interface
au.com.bytecode.opencsv.ResultSetHelper

+
+ + + + + + + + + +
+Packages that use ResultSetHelper
au.com.bytecode.opencsv +A very simple CSV parser for Java released under a commercial-friendly license. 
+  +

+ + + + + +
+Uses of ResultSetHelper in au.com.bytecode.opencsv
+  +

+ + + + + + + + + +
Classes in au.com.bytecode.opencsv that implement ResultSetHelper
+ classResultSetHelperService + +
+          helper class for processing JDBC ResultSet objects
+  +

+ + + + + + + + + +
Methods in au.com.bytecode.opencsv with parameters of type ResultSetHelper
+ voidCSVWriter.setResultService(ResultSetHelper resultService) + +
+           
+  +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/class-use/ResultSetHelperService.html b/doc/api/au/com/bytecode/opencsv/class-use/ResultSetHelperService.html new file mode 100644 index 0000000..008153a --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/class-use/ResultSetHelperService.html @@ -0,0 +1,145 @@ + + + + + + +Uses of Class au.com.bytecode.opencsv.ResultSetHelperService (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
au.com.bytecode.opencsv.ResultSetHelperService

+
+No usage of au.com.bytecode.opencsv.ResultSetHelperService +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/package-frame.html b/doc/api/au/com/bytecode/opencsv/package-frame.html new file mode 100644 index 0000000..5d7a4f8 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/package-frame.html @@ -0,0 +1,49 @@ + + + + + + +au.com.bytecode.opencsv (opencsv API 2.3) + + + + + + + + + + + +au.com.bytecode.opencsv + + + + +
+Interfaces  + +
+ResultSetHelper
+ + + + + + +
+Classes  + +
+CSVParser +
+CSVReader +
+CSVWriter +
+ResultSetHelperService
+ + + + diff --git a/doc/api/au/com/bytecode/opencsv/package-summary.html b/doc/api/au/com/bytecode/opencsv/package-summary.html new file mode 100644 index 0000000..1b35ee5 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/package-summary.html @@ -0,0 +1,204 @@ + + + + + + +au.com.bytecode.opencsv (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package au.com.bytecode.opencsv +

+ +A very simple CSV parser for Java released under a commercial-friendly license. +

+See: +
+          Description +

+ + + + + + + + + +
+Interface Summary
ResultSetHelper 
+  + +

+ + + + + + + + + + + + + + + + + + + + + +
+Class Summary
CSVParserA very simple CSV parser released under a commercial-friendly license.
CSVReaderA very simple CSV reader released under a commercial-friendly license.
CSVWriterA very simple CSV writer released under a commercial-friendly license.
ResultSetHelperServicehelper class for processing JDBC ResultSet objects
+  + +

+

+Package au.com.bytecode.opencsv Description +

+ +

+

+A very simple CSV parser for Java released under a commercial-friendly license. +

+
+opencsv.sourceforge.net +

+ +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/package-tree.html b/doc/api/au/com/bytecode/opencsv/package-tree.html new file mode 100644 index 0000000..e8b44c6 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/package-tree.html @@ -0,0 +1,162 @@ + + + + + + +au.com.bytecode.opencsv Class Hierarchy (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package au.com.bytecode.opencsv +

+
+
+
Package Hierarchies:
All Packages
+
+

+Class Hierarchy +

+ +

+Interface Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/au/com/bytecode/opencsv/package-use.html b/doc/api/au/com/bytecode/opencsv/package-use.html new file mode 100644 index 0000000..9ff1653 --- /dev/null +++ b/doc/api/au/com/bytecode/opencsv/package-use.html @@ -0,0 +1,192 @@ + + + + + + +Uses of Package au.com.bytecode.opencsv (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Package
au.com.bytecode.opencsv

+
+ + + + + + + + + + + + + +
+Packages that use au.com.bytecode.opencsv
au.com.bytecode.opencsv +A very simple CSV parser for Java released under a commercial-friendly license. 
au.com.bytecode.opencsv.bean +A simple bean binding interface for use with opencsv. 
+  +

+ + + + + + + + +
+Classes in au.com.bytecode.opencsv used by au.com.bytecode.opencsv
ResultSetHelper + +
+           
+  +

+ + + + + + + + +
+Classes in au.com.bytecode.opencsv used by au.com.bytecode.opencsv.bean
CSVReader + +
+          A very simple CSV reader released under a commercial-friendly license.
+  +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/constant-values.html b/doc/api/constant-values.html new file mode 100644 index 0000000..412da50 --- /dev/null +++ b/doc/api/constant-values.html @@ -0,0 +1,301 @@ + + + + + + +Constant Field Values (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Constant Field Values

+
+
+Contents + + + + + + +
+au.com.*
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
au.com.bytecode.opencsv.CSVParser
+public static final charDEFAULT_ESCAPE_CHARACTER92
+public static final booleanDEFAULT_IGNORE_LEADING_WHITESPACEtrue
+public static final charDEFAULT_QUOTE_CHARACTER34
+public static final charDEFAULT_SEPARATOR44
+public static final booleanDEFAULT_STRICT_QUOTESfalse
+public static final intINITIAL_READ_SIZE128
+public static final charNULL_CHARACTER0
+ +

+ +

+ + + + + + + + + + + + +
au.com.bytecode.opencsv.CSVReader
+public static final intDEFAULT_SKIP_LINES0
+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
au.com.bytecode.opencsv.CSVWriter
+public static final charDEFAULT_ESCAPE_CHARACTER34
+public static final java.lang.StringDEFAULT_LINE_END"\n"
+public static final charDEFAULT_QUOTE_CHARACTER34
+public static final charDEFAULT_SEPARATOR44
+public static final intINITIAL_STRING_SIZE128
+public static final charNO_ESCAPE_CHARACTER0
+public static final charNO_QUOTE_CHARACTER0
+ +

+ +

+ + + + + + + + + + + + +
au.com.bytecode.opencsv.ResultSetHelperService
+public static final intCLOBBUFFERSIZE2048
+ +

+ +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/deprecated-list.html b/doc/api/deprecated-list.html new file mode 100644 index 0000000..186ead5 --- /dev/null +++ b/doc/api/deprecated-list.html @@ -0,0 +1,147 @@ + + + + + + +Deprecated List (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Deprecated API

+
+
+Contents
    +
+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/help-doc.html b/doc/api/help-doc.html new file mode 100644 index 0000000..059a013 --- /dev/null +++ b/doc/api/help-doc.html @@ -0,0 +1,224 @@ + + + + + + +API Help (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+How This API Document Is Organized

+
+This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

+Overview

+
+ +

+The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

+

+Package

+
+ +

+Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

    +
  • Interfaces (italic)
  • Classes
  • Enums
  • Exceptions
  • Errors
  • Annotation Types
+
+

+Class/Interface

+
+ +

+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    +
  • Class inheritance diagram
  • Direct Subclasses
  • All Known Subinterfaces
  • All Known Implementing Classes
  • Class/interface declaration
  • Class/interface description +

    +

  • Nested Class Summary
  • Field Summary
  • Constructor Summary
  • Method Summary +

    +

  • Field Detail
  • Constructor Detail
  • Method Detail
+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+ +

+Annotation Type

+
+ +

+Each annotation type has its own separate page with the following sections:

    +
  • Annotation Type declaration
  • Annotation Type description
  • Required Element Summary
  • Optional Element Summary
  • Element Detail
+
+ +

+Enum

+
+ +

+Each enum has its own separate page with the following sections:

    +
  • Enum declaration
  • Enum description
  • Enum Constant Summary
  • Enum Constant Detail
+
+

+Use

+
+Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
+

+Tree (Class Hierarchy)

+
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
    +
  • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
  • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
+
+

+Deprecated API

+
+The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+

+Index

+
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+

+Prev/Next

+These links take you to the next or previous class, interface, package, or related page.

+Frames/No Frames

+These links show and hide the HTML frames. All pages are available with or without frames. +

+

+Serialized Form

+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. +

+

+Constant Field Values

+The Constant Field Values page lists the static final fields and their values. +

+ + +This help file applies to API documentation generated using the standard doclet. + +
+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/index-all.html b/doc/api/index-all.html new file mode 100644 index 0000000..a5c8f18 --- /dev/null +++ b/doc/api/index-all.html @@ -0,0 +1,493 @@ + + + + + + +Index (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +A C D F G H I L M N P R S T W
+

+A

+
+
au.com.bytecode.opencsv - package au.com.bytecode.opencsv
+A very simple CSV parser for Java released under a commercial-friendly license.
au.com.bytecode.opencsv.bean - package au.com.bytecode.opencsv.bean
+A simple bean binding interface for use with opencsv.
+
+

+C

+
+
captureHeader(CSVReader) - +Method in class au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy +
  +
captureHeader(CSVReader) - +Method in class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy +
  +
captureHeader(CSVReader) - +Method in interface au.com.bytecode.opencsv.bean.MappingStrategy +
Implementation of this method can grab the header line before parsing begins to use to map columns + to bean properties. +
checkError() - +Method in class au.com.bytecode.opencsv.CSVWriter +
Checks to see if the there has been an error in the printstream. +
CLOBBUFFERSIZE - +Static variable in class au.com.bytecode.opencsv.ResultSetHelperService +
  +
close() - +Method in class au.com.bytecode.opencsv.CSVReader +
Closes the underlying reader. +
close() - +Method in class au.com.bytecode.opencsv.CSVWriter +
Close the underlying stream writer flushing any buffered content. +
ColumnPositionMappingStrategy<T> - Class in au.com.bytecode.opencsv.bean
Copyright 2007 Kyle Miller.
ColumnPositionMappingStrategy() - +Constructor for class au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy +
  +
convertValue(String, PropertyDescriptor) - +Method in class au.com.bytecode.opencsv.bean.CsvToBean +
  +
createBean() - +Method in class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy +
  +
createBean() - +Method in interface au.com.bytecode.opencsv.bean.MappingStrategy +
  +
CSVParser - Class in au.com.bytecode.opencsv
A very simple CSV parser released under a commercial-friendly license.
CSVParser() - +Constructor for class au.com.bytecode.opencsv.CSVParser +
Constructs CSVParser using a comma for the separator. +
CSVParser(char) - +Constructor for class au.com.bytecode.opencsv.CSVParser +
Constructs CSVParser with supplied separator. +
CSVParser(char, char) - +Constructor for class au.com.bytecode.opencsv.CSVParser +
Constructs CSVParser with supplied separator and quote char. +
CSVParser(char, char, char) - +Constructor for class au.com.bytecode.opencsv.CSVParser +
Constructs CSVReader with supplied separator and quote char. +
CSVParser(char, char, char, boolean) - +Constructor for class au.com.bytecode.opencsv.CSVParser +
Constructs CSVReader with supplied separator and quote char. +
CSVParser(char, char, char, boolean, boolean) - +Constructor for class au.com.bytecode.opencsv.CSVParser +
Constructs CSVReader with supplied separator and quote char. +
CSVReader - Class in au.com.bytecode.opencsv
A very simple CSV reader released under a commercial-friendly license.
CSVReader(Reader) - +Constructor for class au.com.bytecode.opencsv.CSVReader +
Constructs CSVReader using a comma for the separator. +
CSVReader(Reader, char) - +Constructor for class au.com.bytecode.opencsv.CSVReader +
Constructs CSVReader with supplied separator. +
CSVReader(Reader, char, char) - +Constructor for class au.com.bytecode.opencsv.CSVReader +
Constructs CSVReader with supplied separator and quote char. +
CSVReader(Reader, char, char, boolean) - +Constructor for class au.com.bytecode.opencsv.CSVReader +
Constructs CSVReader with supplied separator, quote char and quote handling + behavior. +
CSVReader(Reader, char, char, char) - +Constructor for class au.com.bytecode.opencsv.CSVReader +
Constructs CSVReader with supplied separator and quote char. +
CSVReader(Reader, char, char, int) - +Constructor for class au.com.bytecode.opencsv.CSVReader +
Constructs CSVReader with supplied separator and quote char. +
CSVReader(Reader, char, char, char, int) - +Constructor for class au.com.bytecode.opencsv.CSVReader +
Constructs CSVReader with supplied separator and quote char. +
CSVReader(Reader, char, char, char, int, boolean) - +Constructor for class au.com.bytecode.opencsv.CSVReader +
Constructs CSVReader with supplied separator and quote char. +
CSVReader(Reader, char, char, char, int, boolean, boolean) - +Constructor for class au.com.bytecode.opencsv.CSVReader +
Constructs CSVReader with supplied separator and quote char. +
CsvToBean<T> - Class in au.com.bytecode.opencsv.bean
 
CsvToBean() - +Constructor for class au.com.bytecode.opencsv.bean.CsvToBean +
  +
CSVWriter - Class in au.com.bytecode.opencsv
A very simple CSV writer released under a commercial-friendly license.
CSVWriter(Writer) - +Constructor for class au.com.bytecode.opencsv.CSVWriter +
Constructs CSVWriter using a comma for the separator. +
CSVWriter(Writer, char) - +Constructor for class au.com.bytecode.opencsv.CSVWriter +
Constructs CSVWriter with supplied separator. +
CSVWriter(Writer, char, char) - +Constructor for class au.com.bytecode.opencsv.CSVWriter +
Constructs CSVWriter with supplied separator and quote char. +
CSVWriter(Writer, char, char, char) - +Constructor for class au.com.bytecode.opencsv.CSVWriter +
Constructs CSVWriter with supplied separator and quote char. +
CSVWriter(Writer, char, char, String) - +Constructor for class au.com.bytecode.opencsv.CSVWriter +
Constructs CSVWriter with supplied separator and quote char. +
CSVWriter(Writer, char, char, char, String) - +Constructor for class au.com.bytecode.opencsv.CSVWriter +
Constructs CSVWriter with supplied separator, quote char, escape char and line ending. +
+
+

+D

+
+
DEFAULT_ESCAPE_CHARACTER - +Static variable in class au.com.bytecode.opencsv.CSVParser +
The default escape character to use if none is supplied to the + constructor. +
DEFAULT_ESCAPE_CHARACTER - +Static variable in class au.com.bytecode.opencsv.CSVWriter +
The character used for escaping quotes. +
DEFAULT_IGNORE_LEADING_WHITESPACE - +Static variable in class au.com.bytecode.opencsv.CSVParser +
The default leading whitespace behavior to use if none is supplied to the + constructor +
DEFAULT_LINE_END - +Static variable in class au.com.bytecode.opencsv.CSVWriter +
Default line terminator uses platform encoding. +
DEFAULT_QUOTE_CHARACTER - +Static variable in class au.com.bytecode.opencsv.CSVParser +
The default quote character to use if none is supplied to the + constructor. +
DEFAULT_QUOTE_CHARACTER - +Static variable in class au.com.bytecode.opencsv.CSVWriter +
The default quote character to use if none is supplied to the + constructor. +
DEFAULT_SEPARATOR - +Static variable in class au.com.bytecode.opencsv.CSVParser +
The default separator to use if none is supplied to the constructor. +
DEFAULT_SEPARATOR - +Static variable in class au.com.bytecode.opencsv.CSVWriter +
The default separator to use if none is supplied to the constructor. +
DEFAULT_SKIP_LINES - +Static variable in class au.com.bytecode.opencsv.CSVReader +
The default line to start reading. +
DEFAULT_STRICT_QUOTES - +Static variable in class au.com.bytecode.opencsv.CSVParser +
The default strict quote behavior to use if none is supplied to the + constructor +
descriptorMap - +Variable in class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy +
  +
+
+

+F

+
+
findDescriptor(int) - +Method in class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy +
  +
findDescriptor(String) - +Method in class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy +
  +
findDescriptor(int) - +Method in interface au.com.bytecode.opencsv.bean.MappingStrategy +
Implementation will have to return a property descriptor from a bean based on the current column. +
flush() - +Method in class au.com.bytecode.opencsv.CSVWriter +
Flush underlying stream to writer. +
+
+

+G

+
+
getColumnMapping() - +Method in class au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy +
  +
getColumnMapping() - +Method in class au.com.bytecode.opencsv.bean.HeaderColumnNameTranslateMappingStrategy +
  +
getColumnName(int) - +Method in class au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy +
  +
getColumnName(int) - +Method in class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy +
  +
getColumnName(int) - +Method in class au.com.bytecode.opencsv.bean.HeaderColumnNameTranslateMappingStrategy +
  +
getColumnNames(ResultSet) - +Method in interface au.com.bytecode.opencsv.ResultSetHelper +
  +
getColumnNames(ResultSet) - +Method in class au.com.bytecode.opencsv.ResultSetHelperService +
  +
getColumnValues(ResultSet) - +Method in interface au.com.bytecode.opencsv.ResultSetHelper +
  +
getColumnValues(ResultSet) - +Method in class au.com.bytecode.opencsv.ResultSetHelperService +
  +
getPropertyEditor(PropertyDescriptor) - +Method in class au.com.bytecode.opencsv.bean.CsvToBean +
  +
getType() - +Method in class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy +
  +
+
+

+H

+
+
header - +Variable in class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy +
  +
HeaderColumnNameMappingStrategy<T> - Class in au.com.bytecode.opencsv.bean
Copyright 2007 Kyle Miller.
HeaderColumnNameMappingStrategy() - +Constructor for class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy +
  +
HeaderColumnNameTranslateMappingStrategy<T> - Class in au.com.bytecode.opencsv.bean
Copyright 2007,2010 Kyle Miller.
HeaderColumnNameTranslateMappingStrategy() - +Constructor for class au.com.bytecode.opencsv.bean.HeaderColumnNameTranslateMappingStrategy +
  +
+
+

+I

+
+
INITIAL_READ_SIZE - +Static variable in class au.com.bytecode.opencsv.CSVParser +
  +
INITIAL_STRING_SIZE - +Static variable in class au.com.bytecode.opencsv.CSVWriter +
  +
isAllWhiteSpace(CharSequence) - +Method in class au.com.bytecode.opencsv.CSVParser +
precondition: sb.length() > 0 +
isNextCharacterEscapable(String, boolean, int) - +Method in class au.com.bytecode.opencsv.CSVParser +
precondition: the current character is an escape +
isPending() - +Method in class au.com.bytecode.opencsv.CSVParser +
  +
+
+

+L

+
+
loadDescriptorMap(Class<T>) - +Method in class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy +
  +
+
+

+M

+
+
MappingStrategy<T> - Interface in au.com.bytecode.opencsv.bean
 
matches(String, PropertyDescriptor) - +Method in class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy +
  +
+
+

+N

+
+
NO_ESCAPE_CHARACTER - +Static variable in class au.com.bytecode.opencsv.CSVWriter +
The escape constant to use when you wish to suppress all escaping. +
NO_QUOTE_CHARACTER - +Static variable in class au.com.bytecode.opencsv.CSVWriter +
The quote constant to use when you wish to suppress all quoting. +
NULL_CHARACTER - +Static variable in class au.com.bytecode.opencsv.CSVParser +
This is the "null" character - if a value is set to this then it is ignored. +
+
+

+P

+
+
parse(MappingStrategy<T>, Reader) - +Method in class au.com.bytecode.opencsv.bean.CsvToBean +
  +
parse(MappingStrategy<T>, CSVReader) - +Method in class au.com.bytecode.opencsv.bean.CsvToBean +
  +
parseLine(String) - +Method in class au.com.bytecode.opencsv.CSVParser +
  +
parseLineMulti(String) - +Method in class au.com.bytecode.opencsv.CSVParser +
  +
processLine(MappingStrategy<T>, String[]) - +Method in class au.com.bytecode.opencsv.bean.CsvToBean +
  +
processLine(String) - +Method in class au.com.bytecode.opencsv.CSVWriter +
  +
+
+

+R

+
+
readAll() - +Method in class au.com.bytecode.opencsv.CSVReader +
Reads the entire file into a List with each element being a String[] of + tokens. +
readNext() - +Method in class au.com.bytecode.opencsv.CSVReader +
Reads the next line from the buffer and converts to a string array. +
ResultSetHelper - Interface in au.com.bytecode.opencsv
 
ResultSetHelperService - Class in au.com.bytecode.opencsv
helper class for processing JDBC ResultSet objects
ResultSetHelperService() - +Constructor for class au.com.bytecode.opencsv.ResultSetHelperService +
  +
+
+

+S

+
+
setColumnMapping(String[]) - +Method in class au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy +
  +
setColumnMapping(Map<String, String>) - +Method in class au.com.bytecode.opencsv.bean.HeaderColumnNameTranslateMappingStrategy +
  +
setResultService(ResultSetHelper) - +Method in class au.com.bytecode.opencsv.CSVWriter +
  +
setType(Class<T>) - +Method in class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy +
  +
+
+

+T

+
+
type - +Variable in class au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy +
  +
+
+

+W

+
+
writeAll(List<String[]>) - +Method in class au.com.bytecode.opencsv.CSVWriter +
Writes the entire list to a CSV file. +
writeAll(ResultSet, boolean) - +Method in class au.com.bytecode.opencsv.CSVWriter +
Writes the entire ResultSet to a CSV file. +
writeColumnNames(ResultSet) - +Method in class au.com.bytecode.opencsv.CSVWriter +
  +
writeNext(String[]) - +Method in class au.com.bytecode.opencsv.CSVWriter +
Writes the next line to the file. +
+
+A C D F G H I L M N P R S T W + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/index.html b/doc/api/index.html new file mode 100644 index 0000000..48d2ac8 --- /dev/null +++ b/doc/api/index.html @@ -0,0 +1,39 @@ + + + + + + +opencsv API 2.3 + + + + + + + + + + + +<H2> +Frame Alert</H2> + +<P> +This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. +<BR> +Link to<A HREF="overview-summary.html">Non-frame version.</A> + + + diff --git a/doc/api/overview-frame.html b/doc/api/overview-frame.html new file mode 100644 index 0000000..db1e4f2 --- /dev/null +++ b/doc/api/overview-frame.html @@ -0,0 +1,44 @@ + + + + + + +Overview List (opencsv API 2.3) + + + + + + + + + + + + + + + +
+
+ + + + + +
All Classes +

+ +Packages +
+au.com.bytecode.opencsv +
+au.com.bytecode.opencsv.bean +
+

+ +

+  + + diff --git a/doc/api/overview-summary.html b/doc/api/overview-summary.html new file mode 100644 index 0000000..9a529fe --- /dev/null +++ b/doc/api/overview-summary.html @@ -0,0 +1,164 @@ + + + + + + +Overview (opencsv API 2.3) + + + + + + + + + + + + +


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+

opencsv

+ + +
+ + + + + + + + + + + + + +
+Packages
au.com.bytecode.opencsv +A very simple CSV parser for Java released under a commercial-friendly license.
au.com.bytecode.opencsv.bean +A simple bean binding interface for use with opencsv.
+ +


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/overview-tree.html b/doc/api/overview-tree.html new file mode 100644 index 0000000..cb273d7 --- /dev/null +++ b/doc/api/overview-tree.html @@ -0,0 +1,164 @@ + + + + + + +Class Hierarchy (opencsv API 2.3) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For All Packages

+
+
+
Package Hierarchies:
au.com.bytecode.opencsv, au.com.bytecode.opencsv.bean
+
+

+Class Hierarchy +

+ +

+Interface Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2005-2007 Bytecode Pty Ltd. + + + diff --git a/doc/api/resources/inherit.gif b/doc/api/resources/inherit.gif new file mode 100644 index 0000000..c814867 Binary files /dev/null and b/doc/api/resources/inherit.gif differ diff --git a/doc/api/stylesheet.css b/doc/api/stylesheet.css new file mode 100644 index 0000000..6ea9e51 --- /dev/null +++ b/doc/api/stylesheet.css @@ -0,0 +1,29 @@ +/* Javadoc style sheet */ + +/* Define colors, fonts and other style attributes here to override the defaults */ + +/* Page background color */ +body { background-color: #FFFFFF; color:#000000 } + +/* Headings */ +h1 { font-size: 145% } + +/* Table colors */ +.TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ +.TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ +.TableRowColor { background: #FFFFFF; color:#000000 } /* White */ + +/* Font used in left-hand frame lists */ +.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } +.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } +.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } + +/* Navigation bar fonts and colors */ +.NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ +.NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ +.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} +.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} + +.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} +.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} + diff --git a/doc/site/fml/index.fml b/doc/site/fml/index.fml index 4ba7159..a07e2e9 100644 --- a/doc/site/fml/index.fml +++ b/doc/site/fml/index.fml @@ -210,21 +210,7 @@ List list = csv.parse(strat, yourReader); opencsv Development Stuff Is there a snapshot Maven repo for opencsv? - Yes. We're using a repo provided by the good folk at Sonatype. - - - - I'm an opencsv developer, how do you go about releasing a new version? - Here's the general process for a release: -
    -
  • First you talk to everyone else on the team to make sure they're on the same page.
  • -
  • After that you can follow the detailed instructions found on the Sonatype site to get a JIRA username/password
  • -
  • As part of that process, you'll need to add your JIRA account name as a comment to our existing JIRA ticket.
  • -
  • Once you have access, change your Maven settings.xml on your local machine per Step 7a.1. in the Sonatype setup doc.
  • -
  • With all that in place, you can do a "mvn deploy" to release snapshots, or if you're ready to release, create a new branch, set the version in the POM, and "mvn release" again.
  • -
  • For prod releases, the release process puts things in the staging Nexus at Sonatype. It's a manual step from there to release (see step 8 of the Sonatype setup doc). First you have to "Close" the release in the staging repo (which checks the signatures and metadata), then they sent you an email, then you have to "Release" the release to central.
  • -
  • Finally, update the Sourceforge website with the latest Javadoc by using a "mvn site:deploy" (Details here)
  • -
+ Yes. We're using a repo provided by the good folk at Sonatype.
diff --git a/examples/JdbcExample.java b/examples/JdbcExample.java new file mode 100644 index 0000000..49925fc --- /dev/null +++ b/examples/JdbcExample.java @@ -0,0 +1,56 @@ +/* + * + * + */ + +import au.com.bytecode.opencsv.CSVWriter; + +import java.io.StringWriter; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class JdbcExample +{ + + public static void main(String[] args) + { + ResultSet rs = null; + + try + { + rs = getResultSet(); + + StringWriter sw = new StringWriter(); + + CSVWriter writer = new CSVWriter(sw); + writer.writeAll(rs, false); + writer.close(); + + System.out.println(sw); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + finally + { + if (rs != null) + { + try + { + rs.close(); + } + catch (SQLException ignore) + { + // ignore + } + } + } + + } + + private static ResultSet getResultSet() + { + return new MockResultSet(10); + } +} diff --git a/examples/MockResultSet.java b/examples/MockResultSet.java new file mode 100644 index 0000000..32e37db --- /dev/null +++ b/examples/MockResultSet.java @@ -0,0 +1,1374 @@ +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.MalformedURLException; +import java.net.URL; +import java.sql.*; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Map; + +/** + * + * + * mock ResultSet + * + * + * + */ +public class MockResultSet implements ResultSet +{ + private int currentRow = -1; + private int rowCount = 0; + private MockResultSetMetaData metadata; + private long currentTime = System.currentTimeMillis(); + + public MockResultSet(int rows) + { + this(rows, MockResultSetMetaData.getDefaultMetaData()); + } + + public MockResultSet(int rows, MockResultSetMetaData meta) + { + rowCount = rows; + metadata = meta; + } + + public MockResultSet() + { + metadata = MockResultSetMetaData.getDefaultMetaData(); + } + + public int getRowCount() + { + return rowCount; + } + + public boolean next() throws SQLException + { + if (currentRow + 1 >= rowCount) + { + return false; + } + else + { + currentRow++; + return true; + } + + + } + + public void close() throws SQLException + { + } + + public boolean wasNull() throws SQLException + { + return false; + } + + protected MockColumn getColumn(int columnIndex) + { + return metadata.getColumn(columnIndex); + } + + public String getString(int columnIndex) throws SQLException + { + return "string-" + getCurrentRow(); + } + + public boolean getBoolean(int columnIndex) throws SQLException + { + return ((getCurrentRow() % 2) == 0); + } + + public byte getByte(int columnIndex) throws SQLException + { + return 0; + } + + public short getShort(int columnIndex) throws SQLException + { + return (short) getCurrentRow(); + } + + public int getInt(int columnIndex) throws SQLException + { + return getCurrentRow(); + } + + public long getLong(int columnIndex) throws SQLException + { + return getCurrentRow(); + } + + public float getFloat(int columnIndex) throws SQLException + { + return getCurrentRow() + 0.25f; + } + + public double getDouble(int columnIndex) throws SQLException + { + return getCurrentRow() + 0.33d; + } + + public BigDecimal getBigDecimal(int columnIndex, int scale) + throws SQLException + { + return new BigDecimal(getCurrentRow() + 0.44d); + } + + public byte[] getBytes(int columnIndex) throws SQLException + { + return "foo".getBytes(); + } + + public Date getDate(int columnIndex) throws SQLException + { + return new Date(currentTime); + } + + public Time getTime(int columnIndex) throws SQLException + { + return new java.sql.Time(currentTime); + } + + public Timestamp getTimestamp(int columnIndex) throws SQLException + { + return new Timestamp(currentTime); + } + + public InputStream getAsciiStream(int columnIndex) throws SQLException + { + return null; // todo + } + + public InputStream getUnicodeStream(int columnIndex) throws SQLException + { + return null; + } + + public InputStream getBinaryStream(int columnIndex) throws SQLException + { + return null; + } + + public String getString(String columnName) throws SQLException + { + return columnName + getCurrentRow(); + } + + public boolean getBoolean(String columnName) throws SQLException + { + return ((getCurrentRow() % 2) == 0); + } + + public byte getByte(String columnName) throws SQLException + { + return 0; + } + + public short getShort(String columnName) throws SQLException + { + return (short) getCurrentRow(); + } + + public int getInt(String columnName) throws SQLException + { + return getCurrentRow(); + } + + public long getLong(String columnName) throws SQLException + { + return (long) getCurrentRow(); + } + + public float getFloat(String columnName) throws SQLException + { + return (float) getCurrentRow() + 0.01f; + } + + public double getDouble(String columnName) throws SQLException + { + return (double) getCurrentRow() + 0.05d; + } + + public BigDecimal getBigDecimal(String columnName, int scale) + throws SQLException + { + return new java.math.BigDecimal(getCurrentRow() + 0.25); + } + + public byte[] getBytes(String columnName) throws SQLException + { + return columnName.getBytes(); + } + + public Date getDate(String columnName) throws SQLException + { + return new Date(currentTime); + } + + public Time getTime(String columnName) throws SQLException + { + return new java.sql.Time(currentTime); + } + + public Timestamp getTimestamp(String columnName) throws SQLException + { + return new Timestamp(currentTime); + } + + public InputStream getAsciiStream(String columnName) throws SQLException + { + return null; + } + + public InputStream getUnicodeStream(String columnName) throws SQLException + { + return null; + } + + public InputStream getBinaryStream(String columnName) throws SQLException + { + return null; + } + + public SQLWarning getWarnings() throws SQLException + { + return null; + } + + public void clearWarnings() throws SQLException + { + } + + public String getCursorName() throws SQLException + { + return "CursorName"; + } + + public ResultSetMetaData getMetaData() throws SQLException + { + return metadata; + } + + public Object getObject(int columnIndex) throws SQLException + { + return new StringBuilder("Object[row " + + getCurrentRow() + + ", column " + + columnIndex + + "]"); + } + + public Object getObject(String columnName) throws SQLException + { + return new StringBuilder("Object-" + getCurrentRow()); + } + + public int findColumn(String columnName) throws SQLException + { + return 0; // todo ? + } + + public Reader getCharacterStream(int columnIndex) throws SQLException + { + return null; // todo ? + } + + public Reader getCharacterStream(String columnName) throws SQLException + { + return null; // todo ? + } + + public BigDecimal getBigDecimal(int columnIndex) throws SQLException + { + return new BigDecimal(getCurrentRow() + 0.25d); + } + + public BigDecimal getBigDecimal(String columnName) throws SQLException + { + return new BigDecimal(getCurrentRow() + 0.25d); + } + + public boolean isBeforeFirst() throws SQLException + { + return (getCurrentRow() < 0); + } + + public boolean isAfterLast() throws SQLException + { + return (getCurrentRow() >= getRowCount()); + } + + public boolean isFirst() throws SQLException + { + return (getCurrentRow() == 0); + } + + public boolean isLast() throws SQLException + { + return (getCurrentRow() == (getRowCount() - 1)); + } + + public void beforeFirst() throws SQLException + { + currentRow = -1; + } + + public void afterLast() throws SQLException + { + throw new SQLException("not implemented"); + } + + public boolean first() throws SQLException + { + currentRow = 0; + return true; + } + + public boolean last() throws SQLException + { + currentRow = getRowCount() - 1; + return true; + } + + public int getRow() throws SQLException + { + return currentRow; + } + + public boolean absolute(int row) throws SQLException + { + throw new SQLException("not implemented"); + } + + public boolean relative(int rows) throws SQLException + { + throw new SQLException("not implemented"); + } + + public boolean previous() throws SQLException + { + throw new SQLException("not implemented"); + } + + public void setFetchDirection(int direction) throws SQLException + { + throw new SQLException("not implemented"); + } + + public int getFetchDirection() throws SQLException + { + throw new SQLException("not implemented"); + } + + public void setFetchSize(int rows) throws SQLException + { + throw new SQLException("not implemented"); + } + + public int getFetchSize() throws SQLException + { + throw new SQLException("not implemented"); + } + + public int getType() throws SQLException + { + throw new SQLException("not implemented"); + } + + public int getConcurrency() throws SQLException + { + throw new SQLException("not implemented"); + } + + public boolean rowUpdated() throws SQLException + { + throw new SQLException("not implemented"); + } + + public boolean rowInserted() throws SQLException + { + throw new SQLException("not implemented"); + } + + public boolean rowDeleted() throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateNull(int columnIndex) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateBoolean(int columnIndex, boolean x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateByte(int columnIndex, byte x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateShort(int columnIndex, short x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateInt(int columnIndex, int x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateLong(int columnIndex, long x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateFloat(int columnIndex, float x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateDouble(int columnIndex, double x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateBigDecimal(int columnIndex, BigDecimal x) + throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateString(int columnIndex, String x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateBytes(int columnIndex, byte[] x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateDate(int columnIndex, Date x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateTime(int columnIndex, Time x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateTimestamp(int columnIndex, Timestamp x) + throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateAsciiStream(int columnIndex, InputStream x, int length) + throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateBinaryStream(int columnIndex, InputStream x, int length) + throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateCharacterStream(int columnIndex, Reader x, int length) + throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateObject(int columnIndex, Object x, int scale) + throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateObject(int columnIndex, Object x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateNull(String columnName) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateBoolean(String columnName, boolean x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateByte(String columnName, byte x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateShort(String columnName, short x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateInt(String columnName, int x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateLong(String columnName, long x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateFloat(String columnName, float x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateDouble(String columnName, double x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateBigDecimal(String columnName, BigDecimal x) + throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateString(String columnName, String x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateBytes(String columnName, byte[] x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateDate(String columnName, Date x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateTime(String columnName, Time x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateTimestamp(String columnName, Timestamp x) + throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateAsciiStream(String columnName, InputStream x, int length) + throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateBinaryStream(String columnName, InputStream x, int length) + throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateCharacterStream(String columnName, Reader reader, + int length) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateObject(String columnName, Object x, int scale) + throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateObject(String columnName, Object x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void insertRow() throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateRow() throws SQLException + { + throw new SQLException("not implemented"); + } + + public void deleteRow() throws SQLException + { + throw new SQLException("not implemented"); + } + + public void refreshRow() throws SQLException + { + throw new SQLException("not implemented"); + } + + public void cancelRowUpdates() throws SQLException + { + throw new SQLException("not implemented"); + } + + public void moveToInsertRow() throws SQLException + { + throw new SQLException("not implemented"); + } + + public void moveToCurrentRow() throws SQLException + { + throw new SQLException("not implemented"); + } + + public Statement getStatement() throws SQLException + { + throw new SQLException("not implemented"); + } + + public Object getObject(int arg0, Map> arg1) + throws SQLException + { + throw new SQLException("not implemented"); + } + + public Ref getRef(int i) throws SQLException + { + throw new SQLException("not implemented"); + } + + public Blob getBlob(int i) throws SQLException + { + throw new SQLException("not implemented"); + } + + public Clob getClob(int i) throws SQLException + { + // TODO Auto-generated method stub + return null; + } + + public Array getArray(int i) throws SQLException + { + throw new SQLException("not implemented"); + } + + public Object getObject(String arg0, Map> arg1) + throws SQLException + { + throw new SQLException("not implemented"); + } + + public Ref getRef(String colName) throws SQLException + { + // TODO Auto-generated method stub + return null; + } + + public Blob getBlob(String colName) throws SQLException + { + throw new SQLException("not implemented"); + } + + public Clob getClob(String colName) throws SQLException + { + // TODO Auto-generated method stub + return null; + } + + public Array getArray(String colName) throws SQLException + { + throw new SQLException("not implemented"); + } + + public Date getDate(int columnIndex, Calendar cal) throws SQLException + { + return new Date(currentTime); + } + + public Date getDate(String columnName, Calendar cal) throws SQLException + { + return new Date(currentTime); + } + + public Time getTime(int columnIndex, Calendar cal) throws SQLException + { + return new Time(currentTime); + } + + public Time getTime(String columnName, Calendar cal) throws SQLException + { + return new Time(currentTime); + } + + public Timestamp getTimestamp(int columnIndex, Calendar cal) + throws SQLException + { + return new Timestamp(currentTime); + } + + public Timestamp getTimestamp(String columnName, Calendar cal) + throws SQLException + { + return new Timestamp(currentTime); + } + + public URL getURL(int columnIndex) throws SQLException + { + try + { + return new URL("http://www.google.com/"); + } + catch (MalformedURLException ex) + { + throw new SQLException(); + } + } + + public URL getURL(String columnName) throws SQLException + { + try + { + return new URL("http://www.google.com/"); + } + catch (MalformedURLException ex) + { + throw new SQLException(); + } + } + + public void updateRef(int columnIndex, Ref x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateRef(String columnName, Ref x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateBlob(int columnIndex, Blob x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateBlob(String columnName, Blob x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateClob(int columnIndex, Clob x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateClob(String columnName, Clob x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateArray(int columnIndex, Array x) throws SQLException + { + throw new SQLException("not implemented"); + } + + public void updateArray(String columnName, Array x) throws SQLException + { + throw new SQLException("not implemented"); + } + + protected int getCurrentRow() + { + return currentRow; + } + + @Override + public int getHoldability() throws SQLException + { + // TODO Auto-generated method stub + return 0; + } + + @Override + public Reader getNCharacterStream(int arg0) throws SQLException + { + // TODO Auto-generated method stub + return null; + } + + @Override + public Reader getNCharacterStream(String arg0) throws SQLException + { + // TODO Auto-generated method stub + return null; + } + + @Override + public NClob getNClob(int arg0) throws SQLException + { + // TODO Auto-generated method stub + return null; + } + + @Override + public NClob getNClob(String arg0) throws SQLException + { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getNString(int arg0) throws SQLException + { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getNString(String arg0) throws SQLException + { + // TODO Auto-generated method stub + return null; + } + + @Override + public RowId getRowId(int arg0) throws SQLException + { + // TODO Auto-generated method stub + return null; + } + + @Override + public RowId getRowId(String arg0) throws SQLException + { + // TODO Auto-generated method stub + return null; + } + + @Override + public SQLXML getSQLXML(int arg0) throws SQLException + { + // TODO Auto-generated method stub + return null; + } + + @Override + public SQLXML getSQLXML(String arg0) throws SQLException + { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isClosed() throws SQLException + { + // TODO Auto-generated method stub + return false; + } + + @Override + public void updateAsciiStream(int arg0, InputStream arg1) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateAsciiStream(String arg0, InputStream arg1) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateAsciiStream(int arg0, InputStream arg1, long arg2) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateAsciiStream(String arg0, InputStream arg1, long arg2) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(int arg0, InputStream arg1) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(String arg0, InputStream arg1) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(int arg0, InputStream arg1, long arg2) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateBinaryStream(String arg0, InputStream arg1, long arg2) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(int arg0, InputStream arg1) throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(String arg0, InputStream arg1) throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(int arg0, InputStream arg1, long arg2) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateBlob(String arg0, InputStream arg1, long arg2) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(int arg0, Reader arg1) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(String arg0, Reader arg1) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(int arg0, Reader arg1, long arg2) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateCharacterStream(String arg0, Reader arg1, long arg2) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(int arg0, Reader arg1) throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(String arg0, Reader arg1) throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(int arg0, Reader arg1, long arg2) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateClob(String arg0, Reader arg1, long arg2) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateNCharacterStream(int arg0, Reader arg1) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateNCharacterStream(String arg0, Reader arg1) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateNCharacterStream(int arg0, Reader arg1, long arg2) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateNCharacterStream(String arg0, Reader arg1, long arg2) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(int arg0, NClob arg1) throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(String arg0, NClob arg1) throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(int arg0, Reader arg1) throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(String arg0, Reader arg1) throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(int arg0, Reader arg1, long arg2) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateNClob(String arg0, Reader arg1, long arg2) + throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateNString(int arg0, String arg1) throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateNString(String arg0, String arg1) throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateRowId(int arg0, RowId arg1) throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateRowId(String arg0, RowId arg1) throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateSQLXML(int arg0, SQLXML arg1) throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public void updateSQLXML(String arg0, SQLXML arg1) throws SQLException + { + // TODO Auto-generated method stub + + } + + @Override + public boolean isWrapperFor(Class arg0) throws SQLException + { + // TODO Auto-generated method stub + return false; + } + + @Override + public T unwrap(Class arg0) throws SQLException + { + // TODO Auto-generated method stub + return null; + } +} + + +class MockColumn +{ + private String columnName; + private int type; + + + public MockColumn(int type, String name) + { + this.columnName = name; + this.type = type; + } + + public int getDisplaySize() + { + return 10; + } + + public String getName() + { + return this.columnName; + } + + public int getType() + { + return type; + } + + public String toString() + { + return this.getName(); + } +} + +class MockResultSetMetaData implements ResultSetMetaData +{ + + public static MockResultSetMetaData getDefaultMetaData() + { + MockResultSetMetaData meta = new MockResultSetMetaData(); + + meta.addColumn(new MockColumn(Types.VARCHAR, "VarcharColumn")); + meta.addColumn(new MockColumn(Types.BOOLEAN, "BooleanColumn")); + meta.addColumn(new MockColumn(Types.INTEGER, "IntegerColumn")); + meta.addColumn(new MockColumn(Types.DOUBLE, "DoubleColumn")); + meta.addColumn(new MockColumn(Types.TIME, "TimeColumn")); + meta.addColumn(new MockColumn(Types.DATE, "DateColumn")); + meta.addColumn(new MockColumn(Types.CHAR, "CharColumn")); + meta.addColumn(new MockColumn(Types.JAVA_OBJECT, "JavaObjectColumn")); + meta.addColumn(new MockColumn(Types.TIMESTAMP, "TimeStampColumn")); + meta.addColumn(new MockColumn(Types.NUMERIC, "NumericColumn")); + meta.addColumn(new MockColumn(Types.DECIMAL, "DecimalColumn")); + meta.addColumn(new MockColumn(Types.BIGINT, "BigIntegerColumn")); + + return meta; + } + + private ArrayList columns = new ArrayList(); + + public MockResultSetMetaData() + { + + } + + public void clear() + { + columns.clear(); + } + + public void addColumn(MockColumn c) + { + columns.add(c); + } + + + public int getColumnCount() throws SQLException + { + return columns.size(); + } + + public boolean isAutoIncrement(int column) throws SQLException + { + return false; + } + + public boolean isCaseSensitive(int column) throws SQLException + { + return false; + } + + public boolean isSearchable(int column) throws SQLException + { + return false; + } + + public boolean isCurrency(int column) throws SQLException + { + return false; + } + + public int isNullable(int column) throws SQLException + { + return ResultSetMetaData.columnNoNulls; + } + + public boolean isSigned(int column) throws SQLException + { + return false; + } + + public MockColumn getColumn(int column) + { + return columns.get(column - 1); + + } + public int getColumnDisplaySize(int column) throws SQLException + { + return getColumn(column).getDisplaySize(); + } + + public String getColumnLabel(int column) throws SQLException + { + return this.getColumnName(column); + } + + public String getColumnName(int column) throws SQLException + { + return getColumn(column).getName(); + } + + public String getSchemaName(int column) throws SQLException + { + return "SchemaName"; + } + + public int getPrecision(int column) throws SQLException + { + return 0; + } + + public int getScale(int column) throws SQLException + { + return 0; + } + + public String getTableName(int column) throws SQLException + { + return "Table" + column; + } + + public String getCatalogName(int column) throws SQLException + { + return "Catalog" + column; + } + + public int getColumnType(int column) throws SQLException + { + return getColumn(column).getType(); + } + + public String getColumnTypeName(int column) throws SQLException + { + return "ColumnTypeName" + column; + } + + public boolean isReadOnly(int column) throws SQLException + { + return false; + } + + public boolean isWritable(int column) throws SQLException + { + return false; + } + + public boolean isDefinitelyWritable(int column) throws SQLException + { + return false; + } + + public String getColumnClassName(int column) throws SQLException + { + return "ColumnClassName" + column; + } + + @Override + public boolean isWrapperFor(Class arg0) throws SQLException + { + // TODO Auto-generated method stub + return false; + } + + @Override + public T unwrap(Class arg0) throws SQLException + { + // TODO Auto-generated method stub + return null; + } + +} + diff --git a/gplv3.txt b/gplv3.txt new file mode 100644 index 0000000..20d40b6 --- /dev/null +++ b/gplv3.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file diff --git a/myfile.csv b/myfile.csv new file mode 100644 index 0000000..6df1b33 --- /dev/null +++ b/myfile.csv @@ -0,0 +1 @@ +"aaaa","bbbb","cccc","dddd" diff --git a/pom.xml b/pom.xml deleted file mode 100644 index be27d53..0000000 --- a/pom.xml +++ /dev/null @@ -1,219 +0,0 @@ - - 4.0.0 - net.sf.opencsv - opencsv - bundle - 2.4-SNAPSHOT - opencsv - A simple library for reading and writing CSV in Java - http://opencsv.sf.net - - org.sonatype.oss - oss-parent - 7 - - - - Apache 2 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - A business-friendly OSS license - - - - scm:svn:https://opencsv.svn.sourceforge.net/svnroot/opencsv/trunk - scm:svn:https://opencsv.svn.sourceforge.net/svnroot/opencsv/trunk - http://opencsv.svn.sourceforge.net/viewvc/opencsv/ - - - - glen-smith - Glen Smith - glen_a_smith@users.sourceforge.net - http://blogs.bytecode.com.au/glen - +10 - - - sean-sullivan - Sean Sullivan - sullis@users.sourceforge.net - - - scott_conway - Scott Conway - sconway@users.sourceforge.net - - - - Sourceforge - http://sourceforge.net/tracker/?group_id=148905 - - - src - test - - - maven-compiler-plugin - 2.3.2 - - 1.5 - 1.5 - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.8.1 - - - **/Test*.java - - - - - org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - - attach-sources - package - - jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.7 - - - attach-javadocs - package - - jar - - - - - - maven-assembly-plugin - 2.2.1 - - - project - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.2 - - - sign-artifacts - verify - - sign - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - 1.0-beta-1 - - - enforce-versions - install - - enforce - - - - - [1.5,1.6) - - - - - - - - org.apache.felix - maven-bundle-plugin - 2.3.4 - true - - - J2SE-1.5,JavaSE-1.6 - au.com.bytecode.opencsv.*;version="${project.version}" - - - - - - - - junit - junit - 4.8.2 - test - - - org.mockito - mockito-core - 1.8.1 - test - - - - - - org.codehaus.mojo - cobertura-maven-plugin - 2.4 - - - org.codehaus.mojo - findbugs-maven-plugin - 2.3.2 - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.7 - - - org.apache.maven.plugins - maven-jxr-plugin - 2.2 - - - org.apache.maven.plugins - maven-site-plugin - 2.2 - - doc/site - - - - - - - - opencsv.sf.net - scp://shell.sourceforge.net/home/project-web/opencsv/htdocs - - - diff --git a/src/au/com/bytecode/opencsv/CSVIterator.java b/src/au/com/bytecode/opencsv/CSVIterator.java deleted file mode 100644 index 2db4992..0000000 --- a/src/au/com/bytecode/opencsv/CSVIterator.java +++ /dev/null @@ -1,32 +0,0 @@ -package au.com.bytecode.opencsv; - -import java.io.IOException; -import java.util.Iterator; - -public class CSVIterator implements Iterator { - private CSVReader reader; - private String[] nextLine; - - public CSVIterator(CSVReader reader) throws IOException { - this.reader = reader; - nextLine = reader.readNext(); - } - - public boolean hasNext() { - return nextLine != null; - } - - public String[] next() { - String[] temp = nextLine; - try { - nextLine = reader.readNext(); - } catch (IOException e) { - throw new RuntimeException(e); - } - return temp; - } - - public void remove() { - throw new UnsupportedOperationException("This is a read only iterator."); - } -} diff --git a/src/au/com/bytecode/opencsv/CSVParser.java b/src/au/com/bytecode/opencsv/CSVParser.java index f2a9a34..6ae036f 100644 --- a/src/au/com/bytecode/opencsv/CSVParser.java +++ b/src/au/com/bytecode/opencsv/CSVParser.java @@ -29,20 +29,18 @@ */ public class CSVParser { - final char separator; + private final char separator; - final char quotechar; + private final char quotechar; - final char escape; + private final char escape; - final boolean strictQuotes; + private final boolean strictQuotes; private String pending; private boolean inField = false; - final boolean ignoreLeadingWhiteSpace; - - final boolean ignoreQuotations; + private final boolean ignoreLeadingWhiteSpace; /** * The default separator to use if none is supplied to the constructor. @@ -76,15 +74,11 @@ public class CSVParser { */ public static final boolean DEFAULT_IGNORE_LEADING_WHITESPACE = true; - /** - * I.E. if the quote character is set to null then there is no quote character. - */ - public static final boolean DEFAULT_IGNORE_QUOTATIONS = false; - /** * This is the "null" character - if a value is set to this then it is ignored. + * I.E. if the quote character is set to null then there is no quote character. */ - static final char NULL_CHARACTER = '\0'; + public static final char NULL_CHARACTER = '\0'; /** * Constructs CSVParser using a comma for the separator. @@ -125,7 +119,7 @@ public CSVParser(char separator, char quotechar, char escape) { } /** - * Constructs CSVParser with supplied separator and quote char. + * Constructs CSVReader with supplied separator and quote char. * Allows setting the "strict quotes" flag * * @param separator the delimiter to use for separating entries @@ -138,7 +132,7 @@ public CSVParser(char separator, char quotechar, char escape, boolean strictQuot } /** - * Constructs CSVParser with supplied separator and quote char. + * Constructs CSVReader with supplied separator and quote char. * Allows setting the "strict quotes" and "ignore leading whitespace" flags * * @param separator the delimiter to use for separating entries @@ -148,21 +142,6 @@ public CSVParser(char separator, char quotechar, char escape, boolean strictQuot * @param ignoreLeadingWhiteSpace if true, white space in front of a quote in a field is ignored */ public CSVParser(char separator, char quotechar, char escape, boolean strictQuotes, boolean ignoreLeadingWhiteSpace) { - this(separator, quotechar, escape, strictQuotes, ignoreLeadingWhiteSpace, DEFAULT_IGNORE_QUOTATIONS); - } - - /** - * Constructs CSVParser with supplied separator and quote char. - * Allows setting the "strict quotes" and "ignore leading whitespace" flags - * - * @param separator the delimiter to use for separating entries - * @param quotechar the character to use for quoted elements - * @param escape the character to use for escaping a separator or quote - * @param strictQuotes if true, characters outside the quotes are ignored - * @param ignoreLeadingWhiteSpace if true, white space in front of a quote in a field is ignored - */ - public CSVParser(char separator, char quotechar, char escape, boolean strictQuotes, boolean ignoreLeadingWhiteSpace, - boolean ignoreQuotations) { if (anyCharactersAreTheSame(separator, quotechar, escape)) { throw new UnsupportedOperationException("The separator, quote, and escape characters must be different!"); } @@ -174,7 +153,6 @@ public CSVParser(char separator, char quotechar, char escape, boolean strictQuot this.escape = escape; this.strictQuotes = strictQuotes; this.ignoreLeadingWhiteSpace = ignoreLeadingWhiteSpace; - this.ignoreQuotations = ignoreQuotations; } private boolean anyCharactersAreTheSame(char separator, char quotechar, char escape) { @@ -230,22 +208,22 @@ private String[] parseLine(String nextLine, boolean multi) throws IOException { if (pending != null) { sb.append(pending); pending = null; - inQuotes = !this.ignoreQuotations;//true; + inQuotes = true; } for (int i = 0; i < nextLine.length(); i++) { char c = nextLine.charAt(i); if (c == this.escape) { - if (isNextCharacterEscapable(nextLine, (inQuotes && !ignoreQuotations) || inField, i)) { + if (isNextCharacterEscapable(nextLine, inQuotes || inField, i)) { sb.append(nextLine.charAt(i + 1)); i++; } } else if (c == quotechar) { - if (isNextCharacterEscapedQuote(nextLine, (inQuotes && !ignoreQuotations) || inField, i)) { + if (isNextCharacterEscapedQuote(nextLine, inQuotes || inField, i)) { sb.append(nextLine.charAt(i + 1)); i++; } else { - inQuotes = !inQuotes; + //inQuotes = !inQuotes; // the tricky case of an embedded quote in the middle: a,bc"d"ef,g if (!strictQuotes) { @@ -256,28 +234,31 @@ private String[] parseLine(String nextLine, boolean multi) throws IOException { ) { if (ignoreLeadingWhiteSpace && sb.length() > 0 && isAllWhiteSpace(sb)) { - sb = new StringBuilder(INITIAL_READ_SIZE); //discard white space leading up to quote + sb.setLength(0); //discard white space leading up to quote } else { sb.append(c); + //continue; } } } + + inQuotes = !inQuotes; } inField = !inField; - } else if (c == separator && !(inQuotes && !ignoreQuotations)) { + } else if (c == separator && !inQuotes) { tokensOnThisLine.add(sb.toString()); - sb = new StringBuilder(INITIAL_READ_SIZE); // start work on next token + sb.setLength(0); // start work on next token inField = false; } else { - if (!strictQuotes || (inQuotes && !ignoreQuotations)) { + if (!strictQuotes || inQuotes) { sb.append(c); inField = true; } } } // line is done - check status - if ((inQuotes && !ignoreQuotations)) { + if (inQuotes) { if (multi) { // continuing a quoted section, re-append newline sb.append("\n"); diff --git a/src/au/com/bytecode/opencsv/CSVParserBuilder.java b/src/au/com/bytecode/opencsv/CSVParserBuilder.java deleted file mode 100644 index 9c9377c..0000000 --- a/src/au/com/bytecode/opencsv/CSVParserBuilder.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - Copyright 2005 Bytecode Pty Ltd. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ -package au.com.bytecode.opencsv; - -/** - * Builder for creating a CSVParser. - *

- * - * final CSVParser parser = - * new CSVParserBuilder() - * .withSeparator('\t') - * .withIgnoreQuotations(true) - * .build(); - * - * - * @see CSVParser - */ -public class CSVParserBuilder { - - char separator = CSVParser.DEFAULT_SEPARATOR; - char quoteChar = CSVParser.DEFAULT_QUOTE_CHARACTER; - char escapeChar = CSVParser.DEFAULT_ESCAPE_CHARACTER; - boolean strictQuotes = CSVParser.DEFAULT_STRICT_QUOTES; - ; - boolean ignoreLeadingWhiteSpace = - CSVParser.DEFAULT_IGNORE_LEADING_WHITESPACE; - boolean ignoreQuotations = CSVParser.DEFAULT_IGNORE_QUOTATIONS; - - /** - * Sets the delimiter to use for separating entries - * - * @param separator the delimiter to use for separating entries - */ - CSVParserBuilder withSeparator( - final char separator) { - this.separator = separator; - return this; - } - - - /** - * Sets the character to use for quoted elements - * - * @param quotechar the character to use for quoted elements - */ - CSVParserBuilder withQuoteChar( - final char quoteChar) { - this.quoteChar = quoteChar; - return this; - } - - - /** - * Sets the character to use for escaping a separator or quote - * - * @param escape the character to use for escaping a separator or quote - */ - CSVParserBuilder withEscapeChar( - final char escapeChar) { - this.escapeChar = escapeChar; - return this; - } - - - /** - * Sets the strict quotes setting - if true, characters - * outside the quotes are ignored - * - * @param strictQuotes if true, characters outside the quotes are ignored - */ - CSVParserBuilder withStrictQuotes( - final boolean strictQuotes) { - this.strictQuotes = strictQuotes; - return this; - } - - /** - * Sets the ignore leading whitespace setting - if true, white space - * in front of a quote in a field is ignored - * - * @param ignoreLeadingWhiteSpace if true, white space in front of a quote in a field is ignored - */ - CSVParserBuilder withIgnoreLeadingWhiteSpace( - final boolean ignoreLeadingWhiteSpace) { - this.ignoreLeadingWhiteSpace = ignoreLeadingWhiteSpace; - return this; - } - - /** - * Sets the ignore quotations mode - if true, quotations are ignored - * - * @param ignoreQuotations if true, quotations are ignored - */ - CSVParserBuilder withIgnoreQuotations( - final boolean ignoreQuotations) { - this.ignoreQuotations = ignoreQuotations; - return this; - } - - /** - * Constructs CSVParser - */ - CSVParser build() { - return new CSVParser( - separator, - quoteChar, - escapeChar, - strictQuotes, - ignoreLeadingWhiteSpace, - ignoreQuotations); - } -} diff --git a/src/au/com/bytecode/opencsv/CSVReader.java b/src/au/com/bytecode/opencsv/CSVReader.java index 5fcc25d..1cd0d04 100644 --- a/src/au/com/bytecode/opencsv/CSVReader.java +++ b/src/au/com/bytecode/opencsv/CSVReader.java @@ -21,23 +21,23 @@ import java.io.IOException; import java.io.Reader; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; /** * A very simple CSV reader released under a commercial-friendly license. - * + * * @author Glen Smith + * */ -public class CSVReader implements Closeable, Iterable { +public class CSVReader implements Closeable { private BufferedReader br; private boolean hasNext = true; - CSVParser parser; - - int skipLines; + private CSVParser parser; + + private int skipLines; private boolean linesSkiped; @@ -48,8 +48,9 @@ public class CSVReader implements Closeable, Iterable { /** * Constructs CSVReader using a comma for the separator. - * - * @param reader the reader to an underlying CSV source. + * + * @param reader + * the reader to an underlying CSV source. */ public CSVReader(Reader reader) { this(reader, CSVParser.DEFAULT_SEPARATOR, CSVParser.DEFAULT_QUOTE_CHARACTER, CSVParser.DEFAULT_ESCAPE_CHARACTER); @@ -57,9 +58,11 @@ public CSVReader(Reader reader) { /** * Constructs CSVReader with supplied separator. - * - * @param reader the reader to an underlying CSV source. - * @param separator the delimiter to use for separating entries. + * + * @param reader + * the reader to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries. */ public CSVReader(Reader reader, char separator) { this(reader, separator, CSVParser.DEFAULT_QUOTE_CHARACTER, CSVParser.DEFAULT_ESCAPE_CHARACTER); @@ -67,10 +70,13 @@ public CSVReader(Reader reader, char separator) { /** * Constructs CSVReader with supplied separator and quote char. - * - * @param reader the reader to an underlying CSV source. - * @param separator the delimiter to use for separating entries - * @param quotechar the character to use for quoted elements + * + * @param reader + * the reader to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries + * @param quotechar + * the character to use for quoted elements */ public CSVReader(Reader reader, char separator, char quotechar) { this(reader, separator, quotechar, CSVParser.DEFAULT_ESCAPE_CHARACTER, DEFAULT_SKIP_LINES, CSVParser.DEFAULT_STRICT_QUOTES); @@ -80,36 +86,48 @@ public CSVReader(Reader reader, char separator, char quotechar) { * Constructs CSVReader with supplied separator, quote char and quote handling * behavior. * - * @param reader the reader to an underlying CSV source. - * @param separator the delimiter to use for separating entries - * @param quotechar the character to use for quoted elements - * @param strictQuotes sets if characters outside the quotes are ignored + * @param reader + * the reader to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries + * @param quotechar + * the character to use for quoted elements + * @param strictQuotes + * sets if characters outside the quotes are ignored */ public CSVReader(Reader reader, char separator, char quotechar, boolean strictQuotes) { this(reader, separator, quotechar, CSVParser.DEFAULT_ESCAPE_CHARACTER, DEFAULT_SKIP_LINES, strictQuotes); } - /** + /** * Constructs CSVReader with supplied separator and quote char. * - * @param reader the reader to an underlying CSV source. - * @param separator the delimiter to use for separating entries - * @param quotechar the character to use for quoted elements - * @param escape the character to use for escaping a separator or quote + * @param reader + * the reader to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries + * @param quotechar + * the character to use for quoted elements + * @param escape + * the character to use for escaping a separator or quote */ public CSVReader(Reader reader, char separator, - char quotechar, char escape) { + char quotechar, char escape) { this(reader, separator, quotechar, escape, DEFAULT_SKIP_LINES, CSVParser.DEFAULT_STRICT_QUOTES); - } - + } + /** * Constructs CSVReader with supplied separator and quote char. - * - * @param reader the reader to an underlying CSV source. - * @param separator the delimiter to use for separating entries - * @param quotechar the character to use for quoted elements - * @param line the line number to skip for start reading + * + * @param reader + * the reader to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries + * @param quotechar + * the character to use for quoted elements + * @param line + * the line number to skip for start reading */ public CSVReader(Reader reader, char separator, char quotechar, int line) { this(reader, separator, quotechar, CSVParser.DEFAULT_ESCAPE_CHARACTER, line, CSVParser.DEFAULT_STRICT_QUOTES); @@ -118,25 +136,36 @@ public CSVReader(Reader reader, char separator, char quotechar, int line) { /** * Constructs CSVReader with supplied separator and quote char. * - * @param reader the reader to an underlying CSV source. - * @param separator the delimiter to use for separating entries - * @param quotechar the character to use for quoted elements - * @param escape the character to use for escaping a separator or quote - * @param line the line number to skip for start reading + * @param reader + * the reader to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries + * @param quotechar + * the character to use for quoted elements + * @param escape + * the character to use for escaping a separator or quote + * @param line + * the line number to skip for start reading */ public CSVReader(Reader reader, char separator, char quotechar, char escape, int line) { this(reader, separator, quotechar, escape, line, CSVParser.DEFAULT_STRICT_QUOTES); } - + /** * Constructs CSVReader with supplied separator and quote char. - * - * @param reader the reader to an underlying CSV source. - * @param separator the delimiter to use for separating entries - * @param quotechar the character to use for quoted elements - * @param escape the character to use for escaping a separator or quote - * @param line the line number to skip for start reading - * @param strictQuotes sets if characters outside the quotes are ignored + * + * @param reader + * the reader to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries + * @param quotechar + * the character to use for quoted elements + * @param escape + * the character to use for escaping a separator or quote + * @param line + * the line number to skip for start reading + * @param strictQuotes + * sets if characters outside the quotes are ignored */ public CSVReader(Reader reader, char separator, char quotechar, char escape, int line, boolean strictQuotes) { this(reader, separator, quotechar, escape, line, strictQuotes, CSVParser.DEFAULT_IGNORE_LEADING_WHITESPACE); @@ -144,44 +173,37 @@ public CSVReader(Reader reader, char separator, char quotechar, char escape, int /** * Constructs CSVReader with supplied separator and quote char. - * - * @param reader the reader to an underlying CSV source. - * @param separator the delimiter to use for separating entries - * @param quotechar the character to use for quoted elements - * @param escape the character to use for escaping a separator or quote - * @param line the line number to skip for start reading - * @param strictQuotes sets if characters outside the quotes are ignored - * @param ignoreLeadingWhiteSpace it true, parser should ignore white space before a quote in a field + * + * @param reader + * the reader to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries + * @param quotechar + * the character to use for quoted elements + * @param escape + * the character to use for escaping a separator or quote + * @param line + * the line number to skip for start reading + * @param strictQuotes + * sets if characters outside the quotes are ignored + * @param ignoreLeadingWhiteSpace + * it true, parser should ignore white space before a quote in a field */ public CSVReader(Reader reader, char separator, char quotechar, char escape, int line, boolean strictQuotes, boolean ignoreLeadingWhiteSpace) { - this(reader, - line, - new CSVParser(separator, quotechar, escape, strictQuotes, ignoreLeadingWhiteSpace)); - } - - /** - * Constructs CSVReader with supplied separator and quote char. - * - * @param reader the reader to an underlying CSV source. - * @param line the line number to skip for start reading - * @param csvParser the parser to use to parse input - */ - public CSVReader(Reader reader, int line, CSVParser csvParser) { - this.br = - (reader instanceof BufferedReader ? - (BufferedReader) reader : - new BufferedReader(reader)); + this.br = new BufferedReader(reader); + this.parser = new CSVParser(separator, quotechar, escape, strictQuotes, ignoreLeadingWhiteSpace); this.skipLines = line; - this.parser = csvParser; } - /** + /** * Reads the entire file into a List with each element being a String[] of * tokens. - * + * * @return a List of String[], with each String[] representing a line of the * file. - * @throws IOException if bad things happen during the read + * + * @throws IOException + * if bad things happen during the read */ public List readAll() throws IOException { @@ -197,42 +219,45 @@ public List readAll() throws IOException { /** * Reads the next line from the buffer and converts to a string array. - * + * * @return a string array with each comma-separated element as a separate * entry. - * @throws IOException if bad things happen during the read + * + * @throws IOException + * if bad things happen during the read */ public String[] readNext() throws IOException { - - String[] result = null; - do { - String nextLine = getNextLine(); - if (!hasNext) { - return result; // should throw if still pending? - } - String[] r = parser.parseLineMulti(nextLine); - if (r.length > 0) { - if (result == null) { - result = r; - } else { - String[] t = new String[result.length + r.length]; - System.arraycopy(result, 0, t, 0, result.length); - System.arraycopy(r, 0, t, result.length, r.length); - result = t; - } - } - } while (parser.isPending()); - return result; + + String[] result = null; + do { + String nextLine = getNextLine(); + if (!hasNext) { + return result; // should throw if still pending? + } + String[] r = parser.parseLineMulti(nextLine); + if (r.length > 0) { + if (result == null) { + result = r; + } else { + String[] t = new String[result.length+r.length]; + System.arraycopy(result, 0, t, 0, result.length); + System.arraycopy(r, 0, t, result.length, r.length); + result = t; + } + } + } while (parser.isPending()); + return result; } /** * Reads the next line from the file. - * + * * @return the next line from the file without trailing newline - * @throws IOException if bad things happen during the read + * @throws IOException + * if bad things happen during the read */ private String getNextLine() throws IOException { - if (!this.linesSkiped) { + if (!this.linesSkiped) { for (int i = 0; i < skipLines; i++) { br.readLine(); } @@ -247,18 +272,11 @@ private String getNextLine() throws IOException { /** * Closes the underlying reader. - * + * * @throws IOException if the close fails */ - public void close() throws IOException { - br.close(); - } - - public Iterator iterator() { - try { - return new CSVIterator(this); - } catch (IOException e) { - throw new RuntimeException(e); - } + public void close() throws IOException{ + br.close(); } + } diff --git a/src/au/com/bytecode/opencsv/CSVReaderBuilder.java b/src/au/com/bytecode/opencsv/CSVReaderBuilder.java deleted file mode 100644 index 39bb69b..0000000 --- a/src/au/com/bytecode/opencsv/CSVReaderBuilder.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - Copyright 2005 Bytecode Pty Ltd. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ -package au.com.bytecode.opencsv; - - -import java.io.Reader; - -/** - * Builder for creating a CSVReader. - *

- * - * final CSVParser parser = - * new CSVParserBuilder() - * .withSeparator('\t') - * .withIgnoreQuotations(true) - * .build(); - * final CSVReader reader = - * new CSVReaderBuilder(new StringReader(csv)) - * .withSkipLines(1) - * .withCSVParser(parser) - * .build(); - * - * - * @see CSVReader - */ -public class CSVReaderBuilder { - - final Reader reader; - int skipLines = CSVReader.DEFAULT_SKIP_LINES; - CSVParserBuilder csvParserBuilder = new CSVParserBuilder(); - /*@Nullable*/ CSVParser csvParser = null; - - /** - * Sets the reader to an underlying CSV source - * - * @param reader the reader to an underlying CSV source. - */ - CSVReaderBuilder( - final Reader reader) { - if (reader == null) { - throw new IllegalArgumentException("Reader may not be null"); - } - this.reader = reader; - } - - /** - * Sets the line number to skip for start reading - * - * @param skipLines the line number to skip for start reading - */ - CSVReaderBuilder withSkipLines( - final int skipLines) { - this.skipLines = (skipLines <= 0 ? 0 : skipLines); - return this; - } - - - /** - * Sets the parser to use to parse the input - * - * @param csvParser the parser to use to parse the input - */ - CSVReaderBuilder withCSVParser( - final /*@Nullable*/ CSVParser csvParser) { - this.csvParser = csvParser; - return this; - } - - - /** - * Constructs CSVReader - */ - CSVReader build() { - final CSVParser parser = - (csvParser != null ? csvParser : new CSVParser()); - return new CSVReader(reader, skipLines, parser); - } -} diff --git a/src/au/com/bytecode/opencsv/CSVWriter.java b/src/au/com/bytecode/opencsv/CSVWriter.java index 81d1ca7..32e617a 100644 --- a/src/au/com/bytecode/opencsv/CSVWriter.java +++ b/src/au/com/bytecode/opencsv/CSVWriter.java @@ -16,7 +16,10 @@ limitations under the License. */ -import java.io.*; +import java.io.Closeable; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.Writer; import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; @@ -25,31 +28,28 @@ * A very simple CSV writer released under a commercial-friendly license. * * @author Glen Smith + * */ -public class CSVWriter implements Closeable, Flushable { - +public class CSVWriter implements Closeable { + public static final int INITIAL_STRING_SIZE = 128; - private Writer rawWriter; + private Writer rawWriter; private PrintWriter pw; private char separator; private char quotechar; - + private char escapechar; - + private String lineEnd; - /** - * The character used for escaping quotes. - */ + /** The character used for escaping quotes. */ public static final char DEFAULT_ESCAPE_CHARACTER = '"'; - /** - * The default separator to use if none is supplied to the constructor. - */ + /** The default separator to use if none is supplied to the constructor. */ public static final char DEFAULT_SEPARATOR = ','; /** @@ -57,28 +57,23 @@ public class CSVWriter implements Closeable, Flushable { * constructor. */ public static final char DEFAULT_QUOTE_CHARACTER = '"'; - - /** - * The quote constant to use when you wish to suppress all quoting. - */ + + /** The quote constant to use when you wish to suppress all quoting. */ public static final char NO_QUOTE_CHARACTER = '\u0000'; - - /** - * The escape constant to use when you wish to suppress all escaping. - */ + + /** The escape constant to use when you wish to suppress all escaping. */ public static final char NO_ESCAPE_CHARACTER = '\u0000'; - - /** - * Default line terminator uses platform encoding. - */ + + /** Default line terminator uses platform encoding. */ public static final String DEFAULT_LINE_END = "\n"; private ResultSetHelper resultService = new ResultSetHelperService(); - + /** * Constructs CSVWriter using a comma for the separator. * - * @param writer the writer to an underlying CSV source. + * @param writer + * the writer to an underlying CSV source. */ public CSVWriter(Writer writer) { this(writer, DEFAULT_SEPARATOR); @@ -87,8 +82,10 @@ public CSVWriter(Writer writer) { /** * Constructs CSVWriter with supplied separator. * - * @param writer the writer to an underlying CSV source. - * @param separator the delimiter to use for separating entries. + * @param writer + * the writer to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries. */ public CSVWriter(Writer writer, char separator) { this(writer, separator, DEFAULT_QUOTE_CHARACTER); @@ -97,48 +94,65 @@ public CSVWriter(Writer writer, char separator) { /** * Constructs CSVWriter with supplied separator and quote char. * - * @param writer the writer to an underlying CSV source. - * @param separator the delimiter to use for separating entries - * @param quotechar the character to use for quoted elements + * @param writer + * the writer to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries + * @param quotechar + * the character to use for quoted elements */ public CSVWriter(Writer writer, char separator, char quotechar) { - this(writer, separator, quotechar, DEFAULT_ESCAPE_CHARACTER); + this(writer, separator, quotechar, DEFAULT_ESCAPE_CHARACTER); } /** * Constructs CSVWriter with supplied separator and quote char. * - * @param writer the writer to an underlying CSV source. - * @param separator the delimiter to use for separating entries - * @param quotechar the character to use for quoted elements - * @param escapechar the character to use for escaping quotechars or escapechars + * @param writer + * the writer to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries + * @param quotechar + * the character to use for quoted elements + * @param escapechar + * the character to use for escaping quotechars or escapechars */ public CSVWriter(Writer writer, char separator, char quotechar, char escapechar) { this(writer, separator, quotechar, escapechar, DEFAULT_LINE_END); } - - + + /** * Constructs CSVWriter with supplied separator and quote char. * - * @param writer the writer to an underlying CSV source. - * @param separator the delimiter to use for separating entries - * @param quotechar the character to use for quoted elements - * @param lineEnd the line feed terminator to use + * @param writer + * the writer to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries + * @param quotechar + * the character to use for quoted elements + * @param lineEnd + * the line feed terminator to use */ public CSVWriter(Writer writer, char separator, char quotechar, String lineEnd) { this(writer, separator, quotechar, DEFAULT_ESCAPE_CHARACTER, lineEnd); - } - - + } + + + /** * Constructs CSVWriter with supplied separator, quote char, escape char and line ending. * - * @param writer the writer to an underlying CSV source. - * @param separator the delimiter to use for separating entries - * @param quotechar the character to use for quoted elements - * @param escapechar the character to use for escaping quotechars or escapechars - * @param lineEnd the line feed terminator to use + * @param writer + * the writer to an underlying CSV source. + * @param separator + * the delimiter to use for separating entries + * @param quotechar + * the character to use for quoted elements + * @param escapechar + * the character to use for escaping quotechars or escapechars + * @param lineEnd + * the line feed terminator to use */ public CSVWriter(Writer writer, char separator, char quotechar, char escapechar, String lineEnd) { this.rawWriter = writer; @@ -148,89 +162,64 @@ public CSVWriter(Writer writer, char separator, char quotechar, char escapechar, this.escapechar = escapechar; this.lineEnd = lineEnd; } - - /** - * Writes the entire list to a CSV file. The list is assumed to be a - * String[] - * - * @param allLines a List of String[], with each String[] representing a line of - * the file. - * @param applyQuotesToAll true if all values are to be quoted. false if quotes only - * to be applied to values which contain the separator, escape, - * quote or new line characters. - */ - public void writeAll(List allLines, boolean applyQuotesToAll) { - for (String[] line : allLines) { - writeNext(line, applyQuotesToAll); - } - } - + /** * Writes the entire list to a CSV file. The list is assumed to be a * String[] * - * @param allLines a List of String[], with each String[] representing a line of - * the file. + * @param allLines + * a List of String[], with each String[] representing a line of + * the file. */ - public void writeAll(List allLines) { - for (String[] line : allLines) { - writeNext(line); - } + public void writeAll(List allLines) { + for (String[] line : allLines) { + writeNext(line); + } } protected void writeColumnNames(ResultSet rs) - throws SQLException { + throws SQLException { - writeNext(resultService.getColumnNames(rs)); + writeNext(resultService.getColumnNames(rs)); } - + /** * Writes the entire ResultSet to a CSV file. - *

+ * * The caller is responsible for closing the ResultSet. * - * @param rs the recordset to write + * @param rs the recordset to write * @param includeColumnNames true if you want column names in the output, false otherwise - * @throws java.io.IOException thrown by getColumnValue - * @throws java.sql.SQLException thrown by getColumnValue - */ - public void writeAll(java.sql.ResultSet rs, boolean includeColumnNames) throws SQLException, IOException { - writeAll(rs, includeColumnNames, false); - } - - /** - * Writes the entire ResultSet to a CSV file. - *

- * The caller is responsible for closing the ResultSet. * - * @throws java.io.IOException thrown by getColumnValue + * @throws java.io.IOException thrown by getColumnValue * @throws java.sql.SQLException thrown by getColumnValue */ - public void writeAll(java.sql.ResultSet rs, boolean includeColumnNames, boolean trim) throws SQLException, IOException { - - - if (includeColumnNames) { - writeColumnNames(rs); - } - - while (rs.next()) { - writeNext(resultService.getColumnValues(rs, trim)); - } + public void writeAll(java.sql.ResultSet rs, boolean includeColumnNames) throws SQLException, IOException { + + + if (includeColumnNames) { + writeColumnNames(rs); + } + + while (rs.next()) + { + writeNext(resultService.getColumnValues(rs)); + } } + /** * Writes the next line to the file. * - * @param nextLine a string array with each comma-separated element as a separate - * entry. - * @param applyQuotesToAll true if all values are to be quoted. false applies quotes only - * to values which contain the separator, escape, quote or new line characters. + * @param nextLine + * a string array with each comma-separated element as a separate + * entry. */ - public void writeNext(String[] nextLine, boolean applyQuotesToAll) { - - if (nextLine == null) - return; - + public void writeNext(String[] nextLine) { + + if (nextLine == null) + return; + StringBuilder sb = new StringBuilder(INITIAL_STRING_SIZE); for (int i = 0; i < nextLine.length; i++) { @@ -239,74 +228,59 @@ public void writeNext(String[] nextLine, boolean applyQuotesToAll) { } String nextElement = nextLine[i]; - if (nextElement == null) continue; + if (quotechar != NO_QUOTE_CHARACTER) + sb.append(quotechar); + + sb.append(stringContainsSpecialCharacters(nextElement) ? processLine(nextElement) : nextElement); - Boolean stringContainsSpecialCharacters = stringContainsSpecialCharacters(nextElement); - - if ((applyQuotesToAll || stringContainsSpecialCharacters) && quotechar != NO_QUOTE_CHARACTER) - sb.append(quotechar); - - if (stringContainsSpecialCharacters) { - sb.append(processLine(nextElement)); - } else { - sb.append(nextElement); - } - - if ((applyQuotesToAll || stringContainsSpecialCharacters) && quotechar != NO_QUOTE_CHARACTER) - sb.append(quotechar); + if (quotechar != NO_QUOTE_CHARACTER) + sb.append(quotechar); } - + sb.append(lineEnd); pw.write(sb.toString()); - } - /** - * Writes the next line to the file. - * - * @param nextLine a string array with each comma-separated element as a separate - * entry. - */ - public void writeNext(String[] nextLine) { - writeNext(nextLine, true); } - private boolean stringContainsSpecialCharacters(String line) { - return line.indexOf(quotechar) != -1 || line.indexOf(escapechar) != -1 || line.indexOf(separator) != -1 || line.indexOf("\n") != -1 || line.indexOf("\r") != -1; + private boolean stringContainsSpecialCharacters(String line) { + return line.indexOf(quotechar) != -1 || line.indexOf(escapechar) != -1; } - protected StringBuilder processLine(String nextElement) { - StringBuilder sb = new StringBuilder(INITIAL_STRING_SIZE); - for (int j = 0; j < nextElement.length(); j++) { - char nextChar = nextElement.charAt(j); - if (escapechar != NO_ESCAPE_CHARACTER && nextChar == quotechar) { - sb.append(escapechar).append(nextChar); - } else if (escapechar != NO_ESCAPE_CHARACTER && nextChar == escapechar) { - sb.append(escapechar).append(nextChar); - } else { - sb.append(nextChar); - } - } - - return sb; + protected StringBuilder processLine(String nextElement) + { + StringBuilder sb = new StringBuilder(INITIAL_STRING_SIZE); + for (int j = 0; j < nextElement.length(); j++) { + char nextChar = nextElement.charAt(j); + if (escapechar != NO_ESCAPE_CHARACTER && nextChar == quotechar) { + sb.append(escapechar).append(nextChar); + } else if (escapechar != NO_ESCAPE_CHARACTER && nextChar == escapechar) { + sb.append(escapechar).append(nextChar); + } else { + sb.append(nextChar); + } + } + + return sb; } /** * Flush underlying stream to writer. - * + * * @throws IOException if bad things happen */ public void flush() throws IOException { pw.flush(); - } + } /** * Close the underlying stream writer flushing any buffered content. * * @throws IOException if bad things happen + * */ public void close() throws IOException { flush(); @@ -315,7 +289,7 @@ public void close() throws IOException { } /** - * Checks to see if the there has been an error in the printstream. + * Checks to see if the there has been an error in the printstream. */ public boolean checkError() { return pw.checkError(); @@ -325,11 +299,4 @@ public void setResultService(ResultSetHelper resultService) { this.resultService = resultService; } - public void flushQuietly() { - try { - flush(); - } catch (IOException e) { - // catch exception and ignore. - } - } } diff --git a/src/au/com/bytecode/opencsv/IterableCSVToBeanReader.java b/src/au/com/bytecode/opencsv/IterableCSVToBeanReader.java new file mode 100644 index 0000000..aa81032 --- /dev/null +++ b/src/au/com/bytecode/opencsv/IterableCSVToBeanReader.java @@ -0,0 +1,83 @@ +package au.com.bytecode.opencsv; + +import java.io.IOException; +import java.io.Reader; +import java.util.Iterator; + +import au.com.bytecode.opencsv.bean.CsvToBeanIterator; +import au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy; +import au.com.bytecode.opencsv.exception.CSVRuntimeException; + +public class IterableCSVToBeanReader extends CSVReader implements Iterable { + + private ColumnPositionMappingStrategy mapper; + + public IterableCSVToBeanReader(ColumnPositionMappingStrategy _mapper, Reader reader) { + super(reader); + this.mapper = _mapper; + } + + public IterableCSVToBeanReader(ColumnPositionMappingStrategy _mapper, Reader reader, char separator, char quotechar, + boolean strictQuotes) { + super(reader, separator, quotechar, strictQuotes); + this.mapper = _mapper; + } + + public IterableCSVToBeanReader(ColumnPositionMappingStrategy _mapper, Reader reader, char separator, char quotechar, + char escape, int line, boolean strictQuotes, + boolean ignoreLeadingWhiteSpace) { + super(reader, separator, quotechar, escape, line, strictQuotes, + ignoreLeadingWhiteSpace); + this.mapper = _mapper; + } + + public IterableCSVToBeanReader(ColumnPositionMappingStrategy _mapper, Reader reader, char separator, char quotechar, + char escape, int line, boolean strictQuotes) { + super(reader, separator, quotechar, escape, line, strictQuotes); + this.mapper = _mapper; + } + + public IterableCSVToBeanReader(ColumnPositionMappingStrategy _mapper, Reader reader, char separator, char quotechar, + char escape, int line) { + super(reader, separator, quotechar, escape, line); + this.mapper = _mapper; + } + + public IterableCSVToBeanReader(ColumnPositionMappingStrategy _mapper, Reader reader, char separator, char quotechar, + char escape) { + super(reader, separator, quotechar, escape); + this.mapper = _mapper; + } + + public IterableCSVToBeanReader(ColumnPositionMappingStrategy _mapper, Reader reader, char separator, char quotechar, + int line) { + super(reader, separator, quotechar, line); + this.mapper = _mapper; + } + + public IterableCSVToBeanReader(ColumnPositionMappingStrategy _mapper, Reader reader, char separator, char quotechar) { + super(reader, separator, quotechar); + this.mapper = _mapper; + } + + public IterableCSVToBeanReader(ColumnPositionMappingStrategy _mapper, Reader reader, char separator) { + super(reader, separator); + this.mapper = _mapper; + } + + @Override + public Iterator iterator() { + + try { + + return new CsvToBeanIterator(mapper, this); + + } catch (IOException e) { + + throw new CSVRuntimeException(e); + + } + + } + +} diff --git a/src/au/com/bytecode/opencsv/ResultSetHelper.java b/src/au/com/bytecode/opencsv/ResultSetHelper.java index 2b1d366..aa61d4a 100644 --- a/src/au/com/bytecode/opencsv/ResultSetHelper.java +++ b/src/au/com/bytecode/opencsv/ResultSetHelper.java @@ -20,19 +20,14 @@ import java.sql.SQLException; /** - * - * - * - * - * + * + * + * + * + * */ public interface ResultSetHelper { public String[] getColumnNames(ResultSet rs) throws SQLException; public String[] getColumnValues(ResultSet rs) throws SQLException, IOException; - - public String[] getColumnValues(ResultSet rs, boolean trim) throws SQLException, IOException; - - public String[] getColumnValues(ResultSet rs, boolean trim, String dateFormatString, String timeFormatString) - throws SQLException, IOException; } diff --git a/src/au/com/bytecode/opencsv/ResultSetHelperService.java b/src/au/com/bytecode/opencsv/ResultSetHelperService.java index 46bd580..23d9661 100644 --- a/src/au/com/bytecode/opencsv/ResultSetHelperService.java +++ b/src/au/com/bytecode/opencsv/ResultSetHelperService.java @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ - import java.io.IOException; import java.io.Reader; import java.math.BigDecimal; @@ -24,27 +23,28 @@ import java.util.List; /** - * helper class for processing JDBC ResultSet objects + * + * + * helper class for processing JDBC ResultSet objects + * + * */ public class ResultSetHelperService implements ResultSetHelper { public static final int CLOBBUFFERSIZE = 2048; - + // note: we want to maintain compatibility with Java 5 VM's // These types don't exist in Java 5 - static final int NVARCHAR = -9; - static final int NCHAR = -15; - static final int LONGNVARCHAR = -16; - static final int NCLOB = 2011; - - static final String DEFAULT_DATE_FORMAT = "dd-MMM-yyyy"; - static final String DEFAULT_TIMESTAMP_FORMAT = "dd-MMM-yyyy HH:mm:ss"; + private static final int NVARCHAR = -9; + private static final int NCHAR = -15; + private static final int LONGNVARCHAR = -16; + private static final int NCLOB = 2011; public String[] getColumnNames(ResultSet rs) throws SQLException { List names = new ArrayList(); ResultSetMetaData metadata = rs.getMetaData(); for (int i = 0; i < metadata.getColumnCount(); i++) { - names.add(metadata.getColumnName(i + 1)); + names.add(metadata.getColumnName(i+1)); } String[] nameArray = new String[names.size()]; @@ -52,26 +52,19 @@ public String[] getColumnNames(ResultSet rs) throws SQLException { } public String[] getColumnValues(ResultSet rs) throws SQLException, IOException { - return this.getColumnValues(rs, false, DEFAULT_DATE_FORMAT, DEFAULT_TIMESTAMP_FORMAT); - } - public String[] getColumnValues(ResultSet rs, boolean trim) throws SQLException, IOException { - return this.getColumnValues(rs, trim, DEFAULT_DATE_FORMAT, DEFAULT_TIMESTAMP_FORMAT); - } - - public String[] getColumnValues(ResultSet rs, boolean trim, String dateFormatString, String timeFormatString) throws SQLException, IOException { List values = new ArrayList(); ResultSetMetaData metadata = rs.getMetaData(); for (int i = 0; i < metadata.getColumnCount(); i++) { - values.add(getColumnValue(rs, metadata.getColumnType(i + 1), i + 1, trim, dateFormatString, timeFormatString)); + values.add(getColumnValue(rs, metadata.getColumnType(i + 1), i + 1)); } String[] valueArray = new String[values.size()]; return values.toArray(valueArray); } - private String handleObject(Object obj) { + private String handleObject(Object obj){ return obj == null ? "" : String.valueOf(obj); } @@ -89,12 +82,12 @@ private String handleInteger(ResultSet rs, int columnIndex) throws SQLException return rs.wasNull() ? "" : Integer.toString(i); } - private String handleDate(ResultSet rs, int columnIndex, String dateFormatString) throws SQLException { + private String handleDate(ResultSet rs, int columnIndex) throws SQLException { java.sql.Date date = rs.getDate(columnIndex); String value = null; if (date != null) { - SimpleDateFormat dateFormat = new SimpleDateFormat(dateFormatString); - value = dateFormat.format(date); + SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy"); + value = dateFormat.format(date); } return value; } @@ -103,91 +96,88 @@ private String handleTime(Time time) { return time == null ? null : time.toString(); } - private String handleTimestamp(Timestamp timestamp, String timestampFormatString) { - SimpleDateFormat timeFormat = new SimpleDateFormat(timestampFormatString); + private String handleTimestamp(Timestamp timestamp) { + SimpleDateFormat timeFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); return timestamp == null ? null : timeFormat.format(timestamp); } - private String getColumnValue(ResultSet rs, int colType, int colIndex, boolean trim, String dateFormatString, String timestampFormatString) - throws SQLException, IOException { + private String getColumnValue(ResultSet rs, int colType, int colIndex) + throws SQLException, IOException { - String value = ""; + String value = ""; - switch (colType) { - case Types.BIT: + switch (colType) + { + case Types.BIT: case Types.JAVA_OBJECT: - value = handleObject(rs.getObject(colIndex)); - break; - case Types.BOOLEAN: - boolean b = rs.getBoolean(colIndex); - value = Boolean.valueOf(b).toString(); - break; - case NCLOB: // todo : use rs.getNClob - case Types.CLOB: - Clob c = rs.getClob(colIndex); - if (c != null) { - value = read(c); - } - break; - case Types.BIGINT: - value = handleLong(rs, colIndex); - break; - case Types.DECIMAL: - case Types.DOUBLE: - case Types.FLOAT: - case Types.REAL: - case Types.NUMERIC: - value = handleBigDecimal(rs.getBigDecimal(colIndex)); - break; - case Types.INTEGER: - case Types.TINYINT: - case Types.SMALLINT: + value = handleObject(rs.getObject(colIndex)); + break; + case Types.BOOLEAN: + boolean b = rs.getBoolean(colIndex); + value = Boolean.valueOf(b).toString(); + break; + case NCLOB: // todo : use rs.getNClob + case Types.CLOB: + Clob c = rs.getClob(colIndex); + if (c != null) { + value = read(c); + } + break; + case Types.BIGINT: + value = handleLong(rs, colIndex); + break; + case Types.DECIMAL: + case Types.DOUBLE: + case Types.FLOAT: + case Types.REAL: + case Types.NUMERIC: + value = handleBigDecimal(rs.getBigDecimal(colIndex)); + break; + case Types.INTEGER: + case Types.TINYINT: + case Types.SMALLINT: value = handleInteger(rs, colIndex); - break; - case Types.DATE: - value = handleDate(rs, colIndex, dateFormatString); - break; - case Types.TIME: - value = handleTime(rs.getTime(colIndex)); - break; - case Types.TIMESTAMP: - value = handleTimestamp(rs.getTimestamp(colIndex), timestampFormatString); - break; - case NVARCHAR: // todo : use rs.getNString - case NCHAR: // todo : use rs.getNString - case LONGNVARCHAR: // todo : use rs.getNString - case Types.LONGVARCHAR: - case Types.VARCHAR: - case Types.CHAR: - String columnValue = rs.getString(colIndex); - if (trim && columnValue != null) { - value = columnValue.trim(); - } else { - value = columnValue; - } - break; - default: - value = ""; - } - + break; + case Types.DATE: + value = handleDate(rs, colIndex); + break; + case Types.TIME: + value = handleTime(rs.getTime(colIndex)); + break; + case Types.TIMESTAMP: + value = handleTimestamp(rs.getTimestamp(colIndex)); + break; + case NVARCHAR: // todo : use rs.getNString + case NCHAR: // todo : use rs.getNString + case LONGNVARCHAR: // todo : use rs.getNString + case Types.LONGVARCHAR: + case Types.VARCHAR: + case Types.CHAR: + value = rs.getString(colIndex); + break; + default: + value = ""; + } + + + if (value == null) + { + value = ""; + } + + return value; - if (value == null) { - value = ""; - } - - return value; - - } - - private static String read(Clob c) throws SQLException, IOException { - StringBuilder sb = new StringBuilder((int) c.length()); - Reader r = c.getCharacterStream(); - char[] cbuf = new char[CLOBBUFFERSIZE]; - int n; - while ((n = r.read(cbuf, 0, cbuf.length)) != -1) { - sb.append(cbuf, 0, n); - } - return sb.toString(); } + private static String read(Clob c) throws SQLException, IOException + { + StringBuilder sb = new StringBuilder( (int) c.length()); + Reader r = c.getCharacterStream(); + char[] cbuf = new char[CLOBBUFFERSIZE]; + int n; + while ((n = r.read(cbuf, 0, cbuf.length)) != -1) { + sb.append(cbuf, 0, n); + } + return sb.toString(); + } } diff --git a/src/au/com/bytecode/opencsv/bean/BeanToCsv.java b/src/au/com/bytecode/opencsv/bean/BeanToCsv.java deleted file mode 100644 index c19bd9e..0000000 --- a/src/au/com/bytecode/opencsv/bean/BeanToCsv.java +++ /dev/null @@ -1,107 +0,0 @@ -package au.com.bytecode.opencsv.bean; - -/** - Copyright 2007 Kyle Miller. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -import au.com.bytecode.opencsv.CSVWriter; - -import java.beans.IntrospectionException; -import java.beans.PropertyDescriptor; -import java.io.Writer; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -/** - * Allows to export Java beans content to a new CSV spreadsheet file. - * - * @author Kali <kali.tystrit@gmail.com> - */ -public class BeanToCsv { - - public BeanToCsv() { - } - - public boolean write(MappingStrategy mapper, Writer writer, - List objects) { - return write(mapper, new CSVWriter(writer), objects); - } - - public boolean write(MappingStrategy mapper, CSVWriter csv, - List objects) { - if (objects == null || objects.isEmpty()) - return false; - - try { - csv.writeNext(processHeader(mapper)); - List getters = findGetters(mapper); - for (Object obj : objects) { - String[] line = processObject(getters, obj); - csv.writeNext(line); - } - return true; - } catch (Exception e) { - throw new RuntimeException("Error writing CSV !", e); - } - } - - protected String[] processHeader(MappingStrategy mapper) - throws IntrospectionException { - List values = new ArrayList(); - int i = 0; - PropertyDescriptor prop = mapper.findDescriptor(i); - while (prop != null) { - values.add(prop.getName()); - i++; - prop = mapper.findDescriptor(i); - } - return values.toArray(new String[0]); - } - - protected String[] processObject(List getters, Object bean) - throws IntrospectionException, IllegalArgumentException, - IllegalAccessException, InvocationTargetException { - List values = new ArrayList(); - // retrieve bean values - for (Method getter : getters) { - Object value = getter.invoke(bean, (Object[]) null); - if (value == null) { - values.add("null"); - } else { - values.add(value.toString()); - } - } - return values.toArray(new String[0]); - } - - /** - * Build getters list from provided mapper. - */ - private List findGetters(MappingStrategy mapper) - throws IntrospectionException { - int i = 0; - PropertyDescriptor prop = mapper.findDescriptor(i); - // build getters methods list - List readers = new ArrayList(); - while (prop != null) { - readers.add(prop.getReadMethod()); - i++; - prop = mapper.findDescriptor(i); - } - return readers; - } -} diff --git a/src/au/com/bytecode/opencsv/bean/ColumnPositionMappingStrategy.java b/src/au/com/bytecode/opencsv/bean/ColumnPositionMappingStrategy.java index 2ff2186..86db1d1 100644 --- a/src/au/com/bytecode/opencsv/bean/ColumnPositionMappingStrategy.java +++ b/src/au/com/bytecode/opencsv/bean/ColumnPositionMappingStrategy.java @@ -5,37 +5,33 @@ import java.io.IOException; /** - * Copyright 2007 Kyle Miller. - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + Copyright 2007 Kyle Miller. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ public class ColumnPositionMappingStrategy extends HeaderColumnNameMappingStrategy { - private String[] columnMapping = new String[]{}; - + private String[] columnMapping = new String[] {}; public void captureHeader(CSVReader reader) throws IOException { //do nothing, first line is not header } - protected String getColumnName(int col) { - return col < columnMapping.length ? columnMapping[col] : null; + return (null != columnMapping && col < columnMapping.length) ? columnMapping[col] : null ; } - public String[] getColumnMapping() { - return columnMapping.clone(); + return columnMapping != null ? columnMapping.clone() : null; } - - public void setColumnMapping(String... columnMapping) { - this.columnMapping = columnMapping != null ? columnMapping.clone() : new String[]{}; + public void setColumnMapping(String[] columnMapping) { + this.columnMapping = columnMapping != null ? columnMapping.clone() : null; } } diff --git a/src/au/com/bytecode/opencsv/bean/CsvToBeanIterator.java b/src/au/com/bytecode/opencsv/bean/CsvToBeanIterator.java new file mode 100644 index 0000000..9ea70fe --- /dev/null +++ b/src/au/com/bytecode/opencsv/bean/CsvToBeanIterator.java @@ -0,0 +1,99 @@ +package au.com.bytecode.opencsv.bean; + +import java.beans.IntrospectionException; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.Iterator; + +import au.com.bytecode.opencsv.CSVReader; +import au.com.bytecode.opencsv.exception.CSVRuntimeException; + +/** + * Somewhat better on memory when mapping massive CSV files -- which I have to do... + * + * @author bothajo + * + * @param + * + */ +public class CsvToBeanIterator extends CsvToBean implements Iterator { + + private MappingStrategy mapper; + private CSVReader reader; + private String[] nextLine; + + public CsvToBeanIterator(MappingStrategy _mapper, CSVReader csv) throws IOException { + + super(); + + reader = csv; + mapper = _mapper; + mapper.captureHeader(reader); + + } + + @Override + public boolean hasNext() { + + boolean ret = true; + + try { + + if ((nextLine = reader.readNext()) == null) { + + ret = false; + + } + + } catch (IOException e) { + + //redundant + ret = false; + + throw new CSVRuntimeException(e); + + } + + return ret; + + } + + @Override + public T next() { + + T obj = null; + + try { + + obj = processLine(mapper, nextLine); + + } catch (IllegalAccessException e) { + + throw new CSVRuntimeException(e); + + } catch (InvocationTargetException e) { + + throw new CSVRuntimeException(e); + + } catch (InstantiationException e) { + + throw new CSVRuntimeException(e); + + } catch (IntrospectionException e) { + + throw new CSVRuntimeException(e); + + } + + return obj; + + } + + @Override + public void remove() { + + throw new UnsupportedOperationException("There is no underlying collection associated with this Iterable class."); + + } + +} \ No newline at end of file diff --git a/src/au/com/bytecode/opencsv/exception/CSVRuntimeException.java b/src/au/com/bytecode/opencsv/exception/CSVRuntimeException.java new file mode 100644 index 0000000..b89a535 --- /dev/null +++ b/src/au/com/bytecode/opencsv/exception/CSVRuntimeException.java @@ -0,0 +1,29 @@ +package au.com.bytecode.opencsv.exception; + +/** + * I apologize for this class -- haven't figured out + * a cleaner way of making the CsvToBeanIterator work... + * @author bothajo + * + */ +public class CSVRuntimeException extends RuntimeException { + + private static final long serialVersionUID = 7303281195236049701L; + + public CSVRuntimeException() { + super(); + } + + public CSVRuntimeException(String message, Throwable cause) { + super(message, cause); + } + + public CSVRuntimeException(String message) { + super(message); + } + + public CSVRuntimeException(Throwable cause) { + super(cause); + } + +} diff --git a/test/au/com/bytecode/opencsv/CSVIteratorTest.java b/test/au/com/bytecode/opencsv/CSVIteratorTest.java deleted file mode 100644 index acf0f65..0000000 --- a/test/au/com/bytecode/opencsv/CSVIteratorTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package au.com.bytecode.opencsv; - -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * Created by IntelliJ IDEA. - * User: sconway - * Date: 10/29/11 - * Time: 12:41 PM - * To change this template use File | Settings | File Templates. - */ -public class CSVIteratorTest { - private CSVIterator iterator; - private CSVReader mockReader; - private static final String[] STRINGS = {"test1", "test2"}; - - @Before - public void setUp() throws IOException { - mockReader = mock(CSVReader.class); - when(mockReader.readNext()).thenReturn(STRINGS); - iterator = new CSVIterator(mockReader); - } - - @Test(expected = RuntimeException.class) - public void readerExceptionCausesRunTimeException() throws IOException { - when(mockReader.readNext()).thenThrow(new IOException("reader threw test exception")); - String[] stuff = iterator.next(); - } - - @Test(expected = UnsupportedOperationException.class) - public void removethrowsUnsupportedOperationException() { - iterator.remove(); - } - - @Test - public void initialReadReturnsStrings() { - assertArrayEquals(STRINGS, iterator.next()); - } - - @Test - public void hasNextWorks() throws IOException { - when(mockReader.readNext()).thenReturn(null); - assertTrue(iterator.hasNext()); // initial read from constructor - String[] stuff = iterator.next(); - assertFalse(iterator.hasNext()); - } -} diff --git a/test/au/com/bytecode/opencsv/CSVParserBuilderTest.java b/test/au/com/bytecode/opencsv/CSVParserBuilderTest.java deleted file mode 100644 index d975ea2..0000000 --- a/test/au/com/bytecode/opencsv/CSVParserBuilderTest.java +++ /dev/null @@ -1,107 +0,0 @@ -package au.com.bytecode.opencsv; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class CSVParserBuilderTest { - - private CSVParserBuilder builder; - - @Before - public void setUp() throws Exception { - builder = new CSVParserBuilder(); - } - - @Test - public void testDefaultBuilder() { - assertEquals( - CSVParser.DEFAULT_SEPARATOR, - builder.separator); - assertEquals( - CSVParser.DEFAULT_QUOTE_CHARACTER, - builder.quoteChar); - assertEquals( - CSVParser.DEFAULT_ESCAPE_CHARACTER, - builder.escapeChar); - assertEquals( - CSVParser.DEFAULT_STRICT_QUOTES, - builder.strictQuotes); - assertEquals( - CSVParser.DEFAULT_IGNORE_LEADING_WHITESPACE, - builder.ignoreLeadingWhiteSpace); - assertEquals( - CSVParser.DEFAULT_IGNORE_QUOTATIONS, - builder.ignoreQuotations); - - CSVParser parser = builder.build(); - assertEquals( - CSVParser.DEFAULT_SEPARATOR, - parser.separator); - assertEquals( - CSVParser.DEFAULT_QUOTE_CHARACTER, - parser.quotechar); - assertEquals( - CSVParser.DEFAULT_ESCAPE_CHARACTER, - parser.escape); - assertEquals( - CSVParser.DEFAULT_STRICT_QUOTES, - parser.strictQuotes); - assertEquals( - CSVParser.DEFAULT_IGNORE_LEADING_WHITESPACE, - parser.ignoreLeadingWhiteSpace); - assertEquals( - CSVParser.DEFAULT_IGNORE_QUOTATIONS, - parser.ignoreQuotations); - } - - @Test - public void testWithSeparator() { - final char expected = '1'; - builder.withSeparator(expected); - assertEquals(expected, builder.separator); - assertEquals(expected, builder.build().separator); - } - - @Test - public void testWithQuoteChar() { - final char expected = '2'; - builder.withQuoteChar(expected); - assertEquals(expected, builder.quoteChar); - assertEquals(expected, builder.build().quotechar); - } - - @Test - public void testWithEscapeChar() { - final char expected = '3'; - builder.withEscapeChar(expected); - assertEquals(expected, builder.escapeChar); - assertEquals(expected, builder.build().escape); - } - - @Test - public void testWithStrictQuotes() { - final boolean expected = true; - builder.withStrictQuotes(expected); - assertEquals(expected, builder.strictQuotes); - assertEquals(expected, builder.build().strictQuotes); - } - - @Test - public void testWithIgnoreLeadingWhiteSpace() { - final boolean expected = true; - builder.withIgnoreLeadingWhiteSpace(expected); - assertEquals(expected, builder.ignoreLeadingWhiteSpace); - assertEquals(expected, builder.build().ignoreLeadingWhiteSpace); - } - - @Test - public void testWithIgnoreQuotations() { - final boolean expected = true; - builder.withIgnoreQuotations(expected); - assertEquals(expected, builder.ignoreQuotations); - assertEquals(expected, builder.build().ignoreQuotations); - } - -} diff --git a/test/au/com/bytecode/opencsv/CSVParserTest.java b/test/au/com/bytecode/opencsv/CSVParserTest.java index e177a49..2d6544b 100644 --- a/test/au/com/bytecode/opencsv/CSVParserTest.java +++ b/test/au/com/bytecode/opencsv/CSVParserTest.java @@ -44,30 +44,6 @@ public void parseSimpleString() throws IOException { assertFalse(csvParser.isPending()); } - @Test - public void parseSimpleQuotedString() throws IOException { - - String[] nextLine = csvParser.parseLine("\"a\",\"b\",\"c\""); - assertEquals(3, nextLine.length); - assertEquals("a", nextLine[0]); - assertEquals("b", nextLine[1]); - assertEquals("c", nextLine[2]); - assertFalse(csvParser.isPending()); - } - - @Test - public void parseSimpleQuotedStringWithSpaces() throws IOException { - CSVParser parser = new CSVParser(CSVParser.DEFAULT_SEPARATOR, CSVParser.DEFAULT_QUOTE_CHARACTER, CSVParser.DEFAULT_ESCAPE_CHARACTER, - true, false); - - String[] nextLine = parser.parseLine(" \"a\" , \"b\" , \"c\" "); - assertEquals(3, nextLine.length); - assertEquals("a", nextLine[0]); - assertEquals("b", nextLine[1]); - assertEquals("c", nextLine[2]); - assertFalse(parser.isPending()); - } - /** * Tests quotes in the middle of an element. * @@ -160,6 +136,16 @@ public void testEscapedDoubleQuoteAsDataElement() throws IOException { } +// @Test +// public void testEscapingSeparator() throws IOException { +// String[] nextLine = csvParser.parseLine("test,this\\,test\\,is\\,good"); // "test","this,test,is,good","\"test\",\"quote\"" +// +// assertEquals(2, nextLine.length); +// +// assertEquals("test", nextLine[0]); +// assertEquals("this,test,is,good", nextLine[1]); +// } + @Test public void parseQuotedQuoteCharacters() throws IOException { String[] nextLine = csvParser.parseLineMulti("\"Glen \"\"The Man\"\" Smith\",Athlete,Developer\n"); @@ -243,57 +229,6 @@ public void testStrictQuoteWithGarbage() throws IOException { assertEquals("", nextLine[2]); } - @Test - public void testCanIgnoreQuotations() throws IOException { - csvParser = new CSVParser(CSVParser.DEFAULT_SEPARATOR, - CSVParser.DEFAULT_QUOTE_CHARACTER, - CSVParser.DEFAULT_ESCAPE_CHARACTER, - CSVParser.DEFAULT_STRICT_QUOTES, - CSVParser.DEFAULT_IGNORE_LEADING_WHITESPACE, - true); - String testString = "Bob,test\",Beaumont,TX"; - - String[] nextLine = csvParser.parseLine(testString); - assertEquals(4, nextLine.length); - assertEquals("Bob", nextLine[0]); - assertEquals("test", nextLine[1]); - assertEquals("Beaumont", nextLine[2]); - assertEquals("TX", nextLine[3]); - } - - /** - * This is an interesting issue where the data does not use quotes but IS using a quote within the field as a - * inch symbol. So we want to keep that quote as part of the field and not as the start or end of a field. - * - * Test data is as follows. - * - * RPO;2012;P; ; ; ;SDX;ACCESSORY WHEEL, 16", ALUMINUM, DESIGN 1 - * RPO;2012;P; ; ; ;SDZ;ACCESSORY WHEEL - 17" - ALLOY - DESIGN 1 - * - * @throws IOException - */ - @Test - public void testIssue3314579() throws IOException { - csvParser = new CSVParser(';', - CSVParser.DEFAULT_QUOTE_CHARACTER, - CSVParser.DEFAULT_ESCAPE_CHARACTER, - CSVParser.DEFAULT_STRICT_QUOTES, - CSVParser.DEFAULT_IGNORE_LEADING_WHITESPACE, - true); - String testString = "RPO;2012;P; ; ; ;SDX;ACCESSORY WHEEL, 16\", ALUMINUM, DESIGN 1"; - - String[] nextLine = csvParser.parseLine(testString); - assertEquals(8, nextLine.length); - assertEquals("RPO", nextLine[0]); - assertEquals("2012", nextLine[1]); - assertEquals("P", nextLine[2]); - assertEquals(" ", nextLine[3]); - assertEquals(" ", nextLine[4]); - assertEquals(" ", nextLine[5]); - assertEquals("SDX", nextLine[6]); - assertEquals("ACCESSORY WHEEL, 16\", ALUMINUM, DESIGN 1", nextLine[7]); - } - /** * Test issue 2263439 where an escaped quote was causing the parse to fail. *

diff --git a/test/au/com/bytecode/opencsv/CSVReaderBuilderTest.java b/test/au/com/bytecode/opencsv/CSVReaderBuilderTest.java deleted file mode 100644 index 1c37c43..0000000 --- a/test/au/com/bytecode/opencsv/CSVReaderBuilderTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package au.com.bytecode.opencsv; - -import org.junit.Before; -import org.junit.Test; - -import java.io.Reader; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; - -public class CSVReaderBuilderTest { - - private CSVReaderBuilder builder; - private Reader reader; - - @Before - public void setUp() throws Exception { - reader = mock(Reader.class); - builder = new CSVReaderBuilder(reader); - } - - @Test - public void testDefaultBuilder() { - assertSame(reader, builder.reader); - assertNotNull(builder.csvParserBuilder); - assertNull(builder.csvParser); - assertEquals( - CSVReader.DEFAULT_SKIP_LINES, - builder.skipLines); - - final CSVReader csvReader = builder.build(); - assertSame( - CSVReader.DEFAULT_SKIP_LINES, - csvReader.skipLines); - } - - @Test(expected = IllegalArgumentException.class) - public void testNullReader() { - builder = new CSVReaderBuilder(null); - } - - @Test - public void testWithCSVParserNull() { - builder.withCSVParser(mock(CSVParser.class)); - builder.withCSVParser(null); - assertNull(builder.csvParser); - } - - @Test - public void testWithCSVParser() { - final CSVParser csvParser = mock(CSVParser.class); - - builder.withCSVParser(csvParser); - - assertSame(csvParser, builder.csvParser); - - final CSVReader actual = builder.build(); - assertSame(csvParser, actual.parser); - } - - @Test - public void testWithSkipLines() { - builder.withSkipLines(99); - - assertEquals(99, builder.skipLines); - - final CSVReader actual = builder.build(); - assertSame(99, actual.skipLines); - } - - @Test - public void testWithSkipLinesZero() { - builder.withSkipLines(0); - - assertEquals(0, builder.skipLines); - - final CSVReader actual = builder.build(); - assertSame(0, actual.skipLines); - } - - @Test - public void testWithSkipLinesNegative() { - builder.withSkipLines(-1); - - assertEquals(0, builder.skipLines); - - final CSVReader actual = builder.build(); - assertSame(0, actual.skipLines); - } - -} diff --git a/test/au/com/bytecode/opencsv/CSVReaderTest.java b/test/au/com/bytecode/opencsv/CSVReaderTest.java index c5ca597..34f2bcc 100644 --- a/test/au/com/bytecode/opencsv/CSVReaderTest.java +++ b/test/au/com/bytecode/opencsv/CSVReaderTest.java @@ -18,19 +18,11 @@ import org.junit.Before; import org.junit.Test; -import org.mockito.Matchers; import java.io.IOException; -import java.io.Reader; import java.io.StringReader; -import java.nio.CharBuffer; -import java.util.Iterator; import static org.junit.Assert.*; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.notNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; public class CSVReaderTest { @@ -453,47 +445,4 @@ public void separatorAndQuoteMustBeDifferent() { CSVReader c = new CSVReader(new StringReader(sb.toString()), CSVParser.DEFAULT_SEPARATOR, CSVParser.DEFAULT_SEPARATOR, CSVParser.DEFAULT_ESCAPE_CHARACTER, CSVReader.DEFAULT_SKIP_LINES, CSVParser.DEFAULT_STRICT_QUOTES, CSVParser.DEFAULT_IGNORE_LEADING_WHITESPACE); } - /** - * Tests iterating over a reader. - * - * @throws IOException if the reader fails. - */ - @Test - public void testIteratorFunctionality() throws IOException { - String[][] expectedResult = new String[7][]; - expectedResult[0] = new String[]{"a", "b", "c"}; - expectedResult[1] = new String[]{"a", "b,b,b", "c"}; - expectedResult[2] = new String[]{"", "", ""}; - expectedResult[3] = new String[]{"a", "PO Box 123,\nKippax,ACT. 2615.\nAustralia", "d."}; - expectedResult[4] = new String[]{"Glen \"The Man\" Smith", "Athlete", "Developer"}; - expectedResult[5] = new String[]{"\"\"", "test"}; - expectedResult[6] = new String[]{"a\nb", "b", "\nd", "e"}; - int idx = 0; - for (String[] line : csvr) { - String[] expectedLine = expectedResult[idx++]; - assertArrayEquals(expectedLine, line); - } - } - - @Test - public void canCloseReader() throws IOException { - csvr.close(); - } - - @Test - public void canCreateIteratorFromReader() { - assertNotNull(csvr.iterator()); - } - - @Test(expected = RuntimeException.class) - public void creatingIteratorForReaderWithNullDataThrowsRuntimeException() throws IOException { - Reader mockReader = mock(Reader.class); - when(mockReader.read(Matchers.any())).thenThrow(new IOException("test io exception")); - when(mockReader.read()).thenThrow(new IOException("test io exception")); - when(mockReader.read((char[]) notNull())).thenThrow(new IOException("test io exception")); - when(mockReader.read((char[]) notNull(), anyInt(), anyInt())).thenThrow(new IOException("test io exception")); - csvr = new CSVReader(mockReader); - Iterator iterator = csvr.iterator(); - } - } diff --git a/test/au/com/bytecode/opencsv/CSVWriterExceptionThrower.java b/test/au/com/bytecode/opencsv/CSVWriterExceptionThrower.java deleted file mode 100644 index 3351a6d..0000000 --- a/test/au/com/bytecode/opencsv/CSVWriterExceptionThrower.java +++ /dev/null @@ -1,22 +0,0 @@ -package au.com.bytecode.opencsv; - -import java.io.IOException; -import java.io.Writer; - -/** - * Created by IntelliJ IDEA. - * User: sconway - * Date: 6/5/11 - * Time: 7:08 PM - * To change this template use File | Settings | File Templates. - */ -public class CSVWriterExceptionThrower extends CSVWriter { - public CSVWriterExceptionThrower(Writer writer) { - super(writer); - } - - @Override - public void flush() throws IOException { - throw new IOException("Exception thrown from Mock test flush method"); - } -} diff --git a/test/au/com/bytecode/opencsv/CSVWriterTest.java b/test/au/com/bytecode/opencsv/CSVWriterTest.java index 519b8dc..fc96be5 100644 --- a/test/au/com/bytecode/opencsv/CSVWriterTest.java +++ b/test/au/com/bytecode/opencsv/CSVWriterTest.java @@ -19,7 +19,6 @@ import org.junit.Test; import java.io.*; -import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; @@ -32,88 +31,75 @@ public class CSVWriterTest { /** * Test routine for converting output to a string. * - * @param args the elements of a line of the cvs file + * @param args + * the elements of a line of the cvs file * @return a String version - * @throws IOException if there are problems writing + * @throws IOException + * if there are problems writing */ private String invokeWriter(String[] args) throws IOException { StringWriter sw = new StringWriter(); - CSVWriter csvw = new CSVWriter(sw, ',', '\''); + CSVWriter csvw = new CSVWriter(sw,',','\''); csvw.writeNext(args); return sw.toString(); } - + private String invokeNoEscapeWriter(String[] args) throws IOException { StringWriter sw = new StringWriter(); - CSVWriter csvw = new CSVWriter(sw, CSVWriter.DEFAULT_SEPARATOR, '\'', CSVWriter.NO_ESCAPE_CHARACTER); + CSVWriter csvw = new CSVWriter(sw,CSVWriter.DEFAULT_SEPARATOR,'\'', CSVWriter.NO_ESCAPE_CHARACTER); csvw.writeNext(args); return sw.toString(); } @Test - public void correctlyParseNullString() { + public void correctlyParseNullString(){ StringWriter sw = new StringWriter(); - CSVWriter csvw = new CSVWriter(sw, ',', '\''); + CSVWriter csvw = new CSVWriter(sw,',','\''); csvw.writeNext(null); assertEquals(0, sw.toString().length()); } - @Test - public void correctlyParserNullObject() { - StringWriter sw = new StringWriter(); - CSVWriter csvw = new CSVWriter(sw, ',', '\''); - csvw.writeNext(null, false); - assertEquals(0, sw.toString().length()); - } - /** * Tests parsing individual lines. * - * @throws IOException if the reader fails. + * @throws IOException + * if the reader fails. */ @Test public void testParseLine() throws IOException { // test normal case - String[] normal = {"a", "b", "c"}; + String[] normal = { "a", "b", "c" }; String output = invokeWriter(normal); assertEquals("'a','b','c'\n", output); // test quoted commas - String[] quoted = {"a", "b,b,b", "c"}; + String[] quoted = { "a", "b,b,b", "c" }; output = invokeWriter(quoted); assertEquals("'a','b,b,b','c'\n", output); // test empty elements - String[] empty = {,}; + String[] empty = { , }; output = invokeWriter(empty); assertEquals("\n", output); // test multiline quoted - String[] multiline = {"This is a \n multiline entry", "so is \n this"}; + String[] multiline = { "This is a \n multiline entry", "so is \n this" }; output = invokeWriter(multiline); assertEquals("'This is a \n multiline entry','so is \n this'\n", output); // test quoted line - String[] quoteLine = {"This is a \" multiline entry", "so is \n this"}; + String[] quoteLine = { "This is a \" multiline entry", "so is \n this" }; output = invokeWriter(quoteLine); assertEquals("'This is a \"\" multiline entry','so is \n this'\n", output); } - @Test - public void testSpecialCharacters() throws IOException { - // test quoted line - String[] quoteLine = {"This is a \r multiline entry", "so is \n this"}; - String output = invokeWriter(quoteLine); - assertEquals("'This is a \r multiline entry','so is \n this'\n", output); - } - @Test public void parseLineWithBothEscapeAndQuoteChar() throws IOException { // test quoted line - String[] quoteLine = {"This is a 'multiline' entry", "so is \n this"}; + String[] quoteLine = { "This is a 'multiline' entry", "so is \n this" }; String output = invokeWriter(quoteLine); assertEquals("'This is a \"'multiline\"' entry','so is \n this'\n", output); } @@ -121,28 +107,29 @@ public void parseLineWithBothEscapeAndQuoteChar() throws IOException { /** * Tests parsing individual lines. * - * @throws IOException if the reader fails. + * @throws IOException + * if the reader fails. */ @Test public void testParseLineWithNoEscapeChar() throws IOException { // test normal case - String[] normal = {"a", "b", "c"}; + String[] normal = { "a", "b", "c" }; String output = invokeNoEscapeWriter(normal); assertEquals("'a','b','c'\n", output); // test quoted commas - String[] quoted = {"a", "b,b,b", "c"}; + String[] quoted = { "a", "b,b,b", "c" }; output = invokeNoEscapeWriter(quoted); assertEquals("'a','b,b,b','c'\n", output); // test empty elements - String[] empty = {,}; + String[] empty = { , }; output = invokeNoEscapeWriter(empty); assertEquals("\n", output); // test multiline quoted - String[] multiline = {"This is a \n multiline entry", "so is \n this"}; + String[] multiline = { "This is a \n multiline entry", "so is \n this" }; output = invokeNoEscapeWriter(multiline); assertEquals("'This is a \n multiline entry','so is \n this'\n", output); @@ -150,19 +137,20 @@ public void testParseLineWithNoEscapeChar() throws IOException { @Test public void parseLineWithNoEscapeCharAndQuotes() throws IOException { - String[] quoteLine = {"This is a \" 'multiline' entry", "so is \n this"}; + String[] quoteLine = { "This is a \" 'multiline' entry", "so is \n this" }; String output = invokeNoEscapeWriter(quoteLine); assertEquals("'This is a \" 'multiline' entry','so is \n this'\n", output); } /** - * Test writing to a list. + * Test parsing from to a list. * - * @throws IOException if the reader fails. + * @throws IOException + * if the reader fails. */ @Test - public void testWriteAll() throws IOException { + public void testParseAll() throws IOException { List allElements = new ArrayList(); String[] line1 = "Name#Phone#Email".split("#"); @@ -183,50 +171,21 @@ public void testWriteAll() throws IOException { } - /** - * Test writing from a list. - * - * @throws IOException if the reader fails. - */ - @Test - public void testWriteAllObjects() throws IOException { - - List allElements = new ArrayList(3); - String[] line1 = "Name#Phone#Email".split("#"); - String[] line2 = "Glen#1234#glen@abcd.com".split("#"); - String[] line3 = "John#5678#john@efgh.com".split("#"); - allElements.add(line1); - allElements.add(line2); - allElements.add(line3); - - StringWriter sw = new StringWriter(); - CSVWriter csvw = new CSVWriter(sw); - csvw.writeAll(allElements, false); - - String result = sw.toString(); - String[] lines = result.split("\n"); - - assertEquals(3, lines.length); - - String[] values = lines[1].split(","); - assertEquals("1234", values[1]); - } - /** * Tests the option of having omitting quotes in the output stream. - * + * * @throws IOException if bad things happen */ @Test public void testNoQuoteChars() throws IOException { - - String[] line = {"Foo", "Bar", "Baz"}; + + String[] line = {"Foo","Bar","Baz"}; StringWriter sw = new StringWriter(); CSVWriter csvw = new CSVWriter(sw, CSVWriter.DEFAULT_SEPARATOR, CSVWriter.NO_QUOTE_CHARACTER); csvw.writeNext(line); String result = sw.toString(); - assertEquals("Foo,Bar,Baz\n", result); + assertEquals("Foo,Bar,Baz\n",result); } /** @@ -237,30 +196,16 @@ public void testNoQuoteChars() throws IOException { @Test public void testNoQuoteCharsAndNoEscapeChars() throws IOException { - String[] line = {"Foo", "Bar", "Baz"}; + String[] line = {"Foo","Bar","Baz"}; StringWriter sw = new StringWriter(); CSVWriter csvw = new CSVWriter(sw, CSVWriter.DEFAULT_SEPARATOR, CSVWriter.NO_QUOTE_CHARACTER, CSVWriter.NO_ESCAPE_CHARACTER); csvw.writeNext(line); String result = sw.toString(); - assertEquals("Foo,Bar,Baz\n", result); - } - - /** - * Tests the ability for the writer to apply quotes only where strings contain the separator, escape, quote or new line characters. - */ - @Test - public void testIntelligentQuotes() { - String[] line = {"1", "Foo", "With,Separator", "Line\nBreak", "Hello \"Foo Bar\" World", "Bar"}; - StringWriter sw = new StringWriter(); - CSVWriter csvw = new CSVWriter(sw, CSVWriter.DEFAULT_SEPARATOR, CSVWriter.DEFAULT_QUOTE_CHARACTER, CSVWriter.DEFAULT_ESCAPE_CHARACTER); - csvw.writeNext(line, false); - String result = sw.toString(); - - assertEquals("1,Foo,\"With,Separator\",\"Line\nBreak\",\"Hello \"\"Foo Bar\"\" World\",Bar\n", result); + assertEquals("Foo,Bar,Baz\n",result); } - + /** * Test null values. * @@ -269,22 +214,22 @@ public void testIntelligentQuotes() { @Test public void testNullValues() throws IOException { - String[] line = {"Foo", null, "Bar", "baz"}; + String[] line = {"Foo",null,"Bar","baz"}; StringWriter sw = new StringWriter(); CSVWriter csvw = new CSVWriter(sw); csvw.writeNext(line); String result = sw.toString(); - assertEquals("\"Foo\",,\"Bar\",\"baz\"\n", result); + assertEquals("\"Foo\",,\"Bar\",\"baz\"\n",result); } - + @Test public void testStreamFlushing() throws IOException { String WRITE_FILE = "myfile.csv"; - String[] nextLine = new String[]{"aaaa", "bbbb", "cccc", "dddd"}; + String[] nextLine = new String[]{"aaaa", "bbbb","cccc","dddd"}; FileWriter fileWriter = new FileWriter(WRITE_FILE); CSVWriter writer = new CSVWriter(fileWriter); @@ -295,95 +240,76 @@ public void testStreamFlushing() throws IOException { writer.close(); } - - @Test(expected = IOException.class) - public void flushWillThrowIOException() throws IOException { - String[] line = {"Foo", "bar's"}; - StringWriter sw = new StringWriter(); - CSVWriter csvw = new CSVWriterExceptionThrower(sw); - csvw.writeNext(line); - csvw.flush(); - } - - @Test - public void flushQuietlyWillNotThrowException() { - String[] line = {"Foo", "bar's"}; - StringWriter sw = new StringWriter(); - CSVWriter csvw = new CSVWriterExceptionThrower(sw); - csvw.writeNext(line); - csvw.flushQuietly(); - } - - + @Test public void testAlternateEscapeChar() { - String[] line = {"Foo", "bar's"}; + String[] line = {"Foo","bar's"}; StringWriter sw = new StringWriter(); - CSVWriter csvw = new CSVWriter(sw, CSVWriter.DEFAULT_SEPARATOR, CSVWriter.DEFAULT_QUOTE_CHARACTER, '\''); + CSVWriter csvw = new CSVWriter(sw,CSVWriter.DEFAULT_SEPARATOR,CSVWriter.DEFAULT_QUOTE_CHARACTER,'\''); csvw.writeNext(line); - assertEquals("\"Foo\",\"bar''s\"\n", sw.toString()); + assertEquals("\"Foo\",\"bar''s\"\n",sw.toString()); } - + @Test public void testNoQuotingNoEscaping() { String[] line = {"\"Foo\",\"Bar\""}; StringWriter sw = new StringWriter(); - CSVWriter csvw = new CSVWriter(sw, CSVWriter.DEFAULT_SEPARATOR, CSVWriter.NO_QUOTE_CHARACTER, CSVWriter.NO_ESCAPE_CHARACTER); + CSVWriter csvw = new CSVWriter(sw,CSVWriter.DEFAULT_SEPARATOR,CSVWriter.NO_QUOTE_CHARACTER,CSVWriter.NO_ESCAPE_CHARACTER); csvw.writeNext(line); - assertEquals("\"Foo\",\"Bar\"\n", sw.toString()); + assertEquals("\"Foo\",\"Bar\"\n",sw.toString()); } - + @Test - public void testNestedQuotes() { + public void testNestedQuotes(){ String[] data = new String[]{"\"\"", "test"}; String oracle = new String("\"\"\"\"\"\",\"test\"\n"); - CSVWriter writer = null; - File tempFile = null; - FileWriter fwriter = null; + CSVWriter writer=null; + File tempFile=null; + FileWriter fwriter=null; - try { + try{ tempFile = File.createTempFile("csvWriterTest", ".csv"); tempFile.deleteOnExit(); fwriter = new FileWriter(tempFile); writer = new CSVWriter(fwriter); - } catch (IOException e) { + }catch(IOException e){ fail(); } // write the test data: writer.writeNext(data); - try { + try{ writer.close(); - } catch (IOException e) { + }catch(IOException e){ fail(); } - try { + try{ // assert that the writer was also closed. fwriter.flush(); fail(); - } catch (IOException e) { + }catch(IOException e){ // we should go through here.. } // read the data and compare. - FileReader in = null; - try { + FileReader in=null; + try{ in = new FileReader(tempFile); - } catch (FileNotFoundException e) { + }catch(FileNotFoundException e){ fail(); } StringBuilder fileContents = new StringBuilder(CSVWriter.INITIAL_STRING_SIZE); - try { + try{ int ch; - while ((ch = in.read()) != -1) { - fileContents.append((char) ch); + while((ch = in.read()) != -1){ + fileContents.append((char)ch); } in.close(); - } catch (IOException e) { + }catch(IOException e){ fail(); } @@ -392,26 +318,29 @@ public void testNestedQuotes() { @Test public void testAlternateLineFeeds() { - String[] line = {"Foo", "Bar", "baz"}; + String[] line = {"Foo","Bar","baz"}; StringWriter sw = new StringWriter(); CSVWriter csvw = new CSVWriter(sw, CSVWriter.DEFAULT_SEPARATOR, CSVWriter.DEFAULT_QUOTE_CHARACTER, "\r"); csvw.writeNext(line); String result = sw.toString(); - + assertTrue(result.endsWith("\r")); - + } @Test public void testResultSetWithHeaders() throws SQLException, IOException { - String[] header = {"Foo", "Bar", "baz"}; + String[] header = {"Foo","Bar","baz"}; String[] value = {"v1", "v2", "v3"}; + MockResultSetHelper mockHelperService = new MockResultSetHelper(header, value); + StringWriter sw = new StringWriter(); CSVWriter csvw = new CSVWriter(sw); - csvw.setResultService(new ResultSetHelperService()); + csvw.setResultService(mockHelperService); - ResultSet rs = MockResultSetBuilder.buildResultSet(header, value, 1); + MockResultSet rs = new MockResultSet(); + rs.setNumberOfResults(1); csvw.writeAll(rs, true); // don't need a result set since I am mocking the result. assertFalse(csvw.checkError()); @@ -423,14 +352,17 @@ public void testResultSetWithHeaders() throws SQLException, IOException { @Test public void testMultiLineResultSetWithHeaders() throws SQLException, IOException { - String[] header = {"Foo", "Bar", "baz"}; + String[] header = {"Foo","Bar","baz"}; String[] value = {"v1", "v2", "v3"}; + MockResultSetHelper mockHelperService = new MockResultSetHelper(header, value); + StringWriter sw = new StringWriter(); CSVWriter csvw = new CSVWriter(sw); - csvw.setResultService(new ResultSetHelperService()); + csvw.setResultService(mockHelperService); - ResultSet rs = MockResultSetBuilder.buildResultSet(header, value, 3); + MockResultSet rs = new MockResultSet(); + rs.setNumberOfResults(3); csvw.writeAll(rs, true); // don't need a result set since I am mocking the result. assertFalse(csvw.checkError()); @@ -442,14 +374,17 @@ public void testMultiLineResultSetWithHeaders() throws SQLException, IOException @Test public void testResultSetWithoutHeaders() throws SQLException, IOException { - String[] header = {"Foo", "Bar", "baz"}; + String[] header = {"Foo","Bar","baz"}; String[] value = {"v1", "v2", "v3"}; + MockResultSetHelper mockHelperService = new MockResultSetHelper(header, value); + StringWriter sw = new StringWriter(); CSVWriter csvw = new CSVWriter(sw); - csvw.setResultService(new ResultSetHelperService()); + csvw.setResultService(mockHelperService); - ResultSet rs = MockResultSetBuilder.buildResultSet(header, value, 1); + MockResultSet rs = new MockResultSet(); + rs.setNumberOfResults(1); csvw.writeAll(rs, false); // don't need a result set since I am mocking the result. assertFalse(csvw.checkError()); @@ -461,41 +396,23 @@ public void testResultSetWithoutHeaders() throws SQLException, IOException { @Test public void testMultiLineResultSetWithoutHeaders() throws SQLException, IOException { - String[] header = {"Foo", "Bar", "baz"}; + String[] header = {"Foo","Bar","baz"}; String[] value = {"v1", "v2", "v3"}; + MockResultSetHelper mockHelperService = new MockResultSetHelper(header, value); + StringWriter sw = new StringWriter(); CSVWriter csvw = new CSVWriter(sw); - csvw.setResultService(new ResultSetHelperService()); + csvw.setResultService(mockHelperService); - ResultSet rs = MockResultSetBuilder.buildResultSet(header, value, 3); + MockResultSet rs = new MockResultSet(); + rs.setNumberOfResults(3); csvw.writeAll(rs, false); // don't need a result set since I am mocking the result. - assertFalse(csvw.checkError()); String result = sw.toString(); assertNotNull(result); assertEquals("\"v1\",\"v2\",\"v3\"\n\"v1\",\"v2\",\"v3\"\n\"v1\",\"v2\",\"v3\"\n", result); } - - @Test - public void testResultSetTrim() throws SQLException, IOException { - String[] header = {"Foo", "Bar", "baz"}; - String[] value = {"v1 ", "v2 ", "v3"}; - - StringWriter sw = new StringWriter(); - CSVWriter csvw = new CSVWriter(sw); - csvw.setResultService(new ResultSetHelperService()); - - ResultSet rs = MockResultSetBuilder.buildResultSet(header, value, 1); - - csvw.writeAll(rs, true, true); // don't need a result set since I am mocking the result. - assertFalse(csvw.checkError()); - String result = sw.toString(); - - assertNotNull(result); - assertEquals("\"Foo\",\"Bar\",\"baz\"\n\"v1\",\"v2\",\"v3\"\n", result); - } - } diff --git a/test/au/com/bytecode/opencsv/MockResultSet.java b/test/au/com/bytecode/opencsv/MockResultSet.java new file mode 100644 index 0000000..a0648cf --- /dev/null +++ b/test/au/com/bytecode/opencsv/MockResultSet.java @@ -0,0 +1,851 @@ +package au.com.bytecode.opencsv; +/** + Copyright 2005 Bytecode Pty Ltd. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.*; +import java.util.Calendar; +import java.util.Map; + +/** + * Created by IntelliJ IDEA. + * User: scott + * Date: Dec 12, 2009 + * Time: 10:15:03 AM + * To change this template use File | Settings | File Templates. + */ +public class MockResultSet implements ResultSet { + + private int numberOfResults = 0; + private ResultSetMetaData metaData; + private String[] columnValues; + private boolean lastValueReadNull; + + private void setLastValueReadNull(String value){ + lastValueReadNull = (value == null); + } + + + public void setColumnValues(String[] values) { + columnValues = values; + } + + public void setNumberOfResults(int results){ + numberOfResults = results; + } + + public void setMetaData(ResultSetMetaData data) { + metaData = data; + } + + public boolean next() throws SQLException { + return numberOfResults-- > 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public void close() throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean wasNull() throws SQLException { + return lastValueReadNull; //To change body of implemented methods use File | Settings | File Templates. + } + + public String getString(int i) throws SQLException { + return columnValues[i-1]; + } + + public boolean getBoolean(int i) throws SQLException { + return Boolean.valueOf(columnValues[i-1]); //To change body of implemented methods use File | Settings | File Templates. + } + + public byte getByte(int i) throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public short getShort(int i) throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public int getInt(int i) throws SQLException { + setLastValueReadNull(columnValues[i-1]); + return columnValues[i-1] == null ? 0 : Integer.valueOf(columnValues[i-1]); + } + + public long getLong(int i) throws SQLException { + setLastValueReadNull(columnValues[i-1]); + return columnValues[i-1] == null ? 0 : Long.valueOf(columnValues[i-1]); + } + + public float getFloat(int i) throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public double getDouble(int i) throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public BigDecimal getBigDecimal(int i, int i1) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public byte[] getBytes(int i) throws SQLException { + return new byte[0]; //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getDate(int i) throws SQLException { + return columnValues[i-1] == null ? null : new Date(Long.valueOf(columnValues[i-1])); + } + + public Time getTime(int i) throws SQLException { + return columnValues[i-1] == null ? null : new Time(Long.valueOf(columnValues[i-1])); + } + + public Timestamp getTimestamp(int i) throws SQLException { + return columnValues[i-1] == null ? null : new Timestamp(Long.valueOf(columnValues[i-1])); + } + + public InputStream getAsciiStream(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public InputStream getUnicodeStream(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public InputStream getBinaryStream(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public String getString(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean getBoolean(String s) throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public byte getByte(String s) throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public short getShort(String s) throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public int getInt(String s) throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public long getLong(String s) throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public float getFloat(String s) throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public double getDouble(String s) throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public BigDecimal getBigDecimal(String s, int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public byte[] getBytes(String s) throws SQLException { + return new byte[0]; //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getDate(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Time getTime(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Timestamp getTimestamp(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public InputStream getAsciiStream(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public InputStream getUnicodeStream(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public InputStream getBinaryStream(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public SQLWarning getWarnings() throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void clearWarnings() throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getCursorName() throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public ResultSetMetaData getMetaData() throws SQLException { + return metaData; + } + + public Object getObject(int i) throws SQLException { + setLastValueReadNull(columnValues[i-1]); + return columnValues[i-1]; //To change body of implemented methods use File | Settings | File Templates. + } + + public Object getObject(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public int findColumn(String s) throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public Reader getCharacterStream(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Reader getCharacterStream(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public BigDecimal getBigDecimal(int i) throws SQLException { + setLastValueReadNull(columnValues[i-1]); + return columnValues[i-1] == null ? null : new BigDecimal(columnValues[i-1]); + } + + public BigDecimal getBigDecimal(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isBeforeFirst() throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isAfterLast() throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isFirst() throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isLast() throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void beforeFirst() throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void afterLast() throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean first() throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean last() throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public int getRow() throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean absolute(int i) throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean relative(int i) throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean previous() throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setFetchDirection(int i) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public int getFetchDirection() throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setFetchSize(int i) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public int getFetchSize() throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public int getType() throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public int getConcurrency() throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean rowUpdated() throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean rowInserted() throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean rowDeleted() throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateNull(int i) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBoolean(int i, boolean b) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateByte(int i, byte b) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateShort(int i, short s) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateInt(int i, int i1) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateLong(int i, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateFloat(int i, float v) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateDouble(int i, double v) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBigDecimal(int i, BigDecimal bigDecimal) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateString(int i, String s) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBytes(int i, byte[] bytes) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateDate(int i, Date date) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateTime(int i, Time time) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateTimestamp(int i, Timestamp timestamp) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateAsciiStream(int i, InputStream inputStream, int i1) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBinaryStream(int i, InputStream inputStream, int i1) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateCharacterStream(int i, Reader reader, int i1) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateObject(int i, Object o, int i1) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateObject(int i, Object o) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateNull(String s) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBoolean(String s, boolean b) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateByte(String s, byte b) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateShort(String s, short i) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateInt(String s, int i) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateLong(String s, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateFloat(String s, float v) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateDouble(String s, double v) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBigDecimal(String s, BigDecimal bigDecimal) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateString(String s, String s1) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBytes(String s, byte[] bytes) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateDate(String s, Date date) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateTime(String s, Time time) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateTimestamp(String s, Timestamp timestamp) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateAsciiStream(String s, InputStream inputStream, int i) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBinaryStream(String s, InputStream inputStream, int i) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateCharacterStream(String s, Reader reader, int i) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateObject(String s, Object o, int i) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateObject(String s, Object o) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void insertRow() throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateRow() throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void deleteRow() throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void refreshRow() throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void cancelRowUpdates() throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void moveToInsertRow() throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void moveToCurrentRow() throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Statement getStatement() throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Object getObject(int i, Map> stringClassMap) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Ref getRef(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Blob getBlob(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Clob getClob(int i) throws SQLException { + return columnValues[i-1] == null ? null : new MockClob(columnValues[i-1]); + } + + public Array getArray(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Object getObject(String s, Map> stringClassMap) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Ref getRef(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Blob getBlob(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Clob getClob(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Array getArray(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getDate(int i, Calendar calendar) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getDate(String s, Calendar calendar) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Time getTime(int i, Calendar calendar) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Time getTime(String s, Calendar calendar) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Timestamp getTimestamp(int i, Calendar calendar) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Timestamp getTimestamp(String s, Calendar calendar) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public URL getURL(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public URL getURL(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateRef(int i, Ref ref) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateRef(String s, Ref ref) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBlob(int i, Blob blob) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBlob(String s, Blob blob) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateClob(int i, Clob clob) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateClob(String s, Clob clob) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateArray(int i, Array array) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateArray(String s, Array array) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public int getHoldability() throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isClosed() throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateNString(int i, String s) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateNString(String s, String s1) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getNString(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public String getNString(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Reader getNCharacterStream(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Reader getNCharacterStream(String s) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateNCharacterStream(int i, Reader reader, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateNCharacterStream(String s, Reader reader, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateAsciiStream(int i, InputStream inputStream, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBinaryStream(int i, InputStream inputStream, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateCharacterStream(int i, Reader reader, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateAsciiStream(String s, InputStream inputStream, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBinaryStream(String s, InputStream inputStream, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateCharacterStream(String s, Reader reader, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBlob(int i, InputStream inputStream, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBlob(String s, InputStream inputStream, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateClob(int i, Reader reader, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateClob(String s, Reader reader, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateNClob(int i, Reader reader, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateNClob(String s, Reader reader, long l) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateNCharacterStream(int i, Reader reader) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateNCharacterStream(String s, Reader reader) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateAsciiStream(int i, InputStream inputStream) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBinaryStream(int i, InputStream inputStream) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateCharacterStream(int i, Reader reader) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateAsciiStream(String s, InputStream inputStream) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBinaryStream(String s, InputStream inputStream) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateCharacterStream(String s, Reader reader) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBlob(int i, InputStream inputStream) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateBlob(String s, InputStream inputStream) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateClob(int i, Reader reader) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateClob(String s, Reader reader) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateNClob(int i, Reader reader) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateNClob(String s, Reader reader) throws SQLException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public T unwrap(Class tClass) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isWrapperFor(Class aClass) throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + + @Override + public NClob getNClob(int arg0) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + + @Override + public NClob getNClob(String arg0) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + + @Override + public RowId getRowId(int arg0) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + + @Override + public RowId getRowId(String arg0) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + + @Override + public SQLXML getSQLXML(int arg0) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + + @Override + public SQLXML getSQLXML(String arg0) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + + @Override + public void updateNClob(int arg0, NClob arg1) throws SQLException { + // TODO Auto-generated method stub + + } + + + @Override + public void updateNClob(String arg0, NClob arg1) throws SQLException { + // TODO Auto-generated method stub + + } + + + @Override + public void updateRowId(int arg0, RowId arg1) throws SQLException { + // TODO Auto-generated method stub + + } + + + @Override + public void updateRowId(String arg0, RowId arg1) throws SQLException { + // TODO Auto-generated method stub + + } + + + @Override + public void updateSQLXML(int arg0, SQLXML arg1) throws SQLException { + // TODO Auto-generated method stub + + } + + + @Override + public void updateSQLXML(String arg0, SQLXML arg1) throws SQLException { + // TODO Auto-generated method stub + + } +} diff --git a/test/au/com/bytecode/opencsv/MockResultSetBuilder.java b/test/au/com/bytecode/opencsv/MockResultSetBuilder.java deleted file mode 100644 index f07c3e6..0000000 --- a/test/au/com/bytecode/opencsv/MockResultSetBuilder.java +++ /dev/null @@ -1,190 +0,0 @@ -package au.com.bytecode.opencsv; - -import javax.sql.rowset.serial.SerialClob; -import java.math.BigDecimal; -import java.sql.*; -import java.util.ArrayList; -import java.util.List; - -import static java.sql.Types.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -/** - * Created by IntelliJ IDEA. - * User: sconway - * Date: 6/14/11 - * Time: 10:40 PM - * To change this template use File | Settings | File Templates. - */ -public class MockResultSetBuilder { - - public static ResultSet buildResultSet(ResultSetMetaData metaData, String[] columnValues, int[] columnTypes) throws SQLException { - ResultSet resultSet = mock(ResultSet.class); - List wnrl = new ArrayList(); - when(resultSet.getMetaData()).thenReturn(metaData); - - for (int i = 0; i < columnValues.length; i++) { - setExpectToGetColumnValue(resultSet, i + 1, columnValues[i], columnTypes[i], wnrl); - } - - if (!wnrl.isEmpty()) { - // Why I have to do it this way I have no idea. but I cannot pass in just an array of Boolean I - // have to break it up into a first value and the rest of the values. - - Boolean firstValue = wnrl.get(0); - wnrl.remove(0); - - Boolean[] values = new Boolean[wnrl.size()]; - int i = 0; - for (Boolean b : wnrl) { - values[i++] = b; - } - - if (!wnrl.isEmpty()) { - when(resultSet.wasNull()).thenReturn(firstValue, values); - } else { - when(resultSet.wasNull()).thenReturn(firstValue); - } - } - - return resultSet; - } - - private static void setExpectToGetColumnValue(ResultSet rs, int index, String value, int type, List wnrl) throws SQLException { - - switch (type) { - case BIT: - case JAVA_OBJECT: - when(rs.getObject(index)).thenReturn(value); - break; - case BOOLEAN: - when(rs.getBoolean(index)).thenReturn(Boolean.valueOf(value)); - break; - case BIGINT: - when(rs.getLong(index)).thenReturn(value != null ? Long.valueOf(value).longValue() : 0); - wnrl.add(value == null); - break; - case Types.DECIMAL: - case Types.DOUBLE: - case Types.FLOAT: - case Types.REAL: - case Types.NUMERIC: - when(rs.getBigDecimal(index)).thenReturn(value != null ? new BigDecimal(value) : null); - break; - case Types.INTEGER: - case Types.TINYINT: - case Types.SMALLINT: - when(rs.getInt(index)).thenReturn(value != null ? new Integer(value).intValue() : 0); - wnrl.add(value == null); - break; - case ResultSetHelperService.NVARCHAR: // todo : use rs.getNString - case ResultSetHelperService.NCHAR: // todo : use rs.getNString - case ResultSetHelperService.LONGNVARCHAR: // todo : use rs.getNString - case Types.LONGVARCHAR: - case Types.VARCHAR: - case Types.CHAR: - when(rs.getString(index)).thenReturn(value); - break; - case Types.DATE: - Date date = createDateFromMilliSeconds(value); - when(rs.getDate(index)).thenReturn(date); - break; - case Types.TIME: - Time time = createTimeFromMilliSeconds(value); - when(rs.getTime(index)).thenReturn(time); - break; - case Types.TIMESTAMP: - Timestamp ts = createTimeStampFromMilliSeconds(value); - when(rs.getTimestamp(index)).thenReturn(ts); - break; - case ResultSetHelperService.NCLOB: // todo : use rs.getNClob - case Types.CLOB: - Clob c = createClobFromString(value); - when(rs.getClob(index)).thenReturn(c); - break; - - } - - } - - private static Clob createClobFromString(String value) throws SQLException { - return value != null ? new SerialClob(value.toCharArray()) : null; - } - - private static Date createDateFromMilliSeconds(String value) { - Date date; - - if (value == null) { - date = null; - } else { - Long milliseconds = Long.valueOf(value); - date = new Date(milliseconds); - } - return date; - } - - private static Time createTimeFromMilliSeconds(String value) { - Time time; - - if (value == null) { - time = null; - } else { - Long milliseconds = Long.valueOf(value); - time = new Time(milliseconds); - } - return time; - } - - private static Timestamp createTimeStampFromMilliSeconds(String value) { - Timestamp timestamp; - - if (value == null) { - timestamp = null; - } else { - Long milliseconds = Long.valueOf(value); - timestamp = new Timestamp(milliseconds); - } - return timestamp; - } - - public static ResultSet buildResultSet(String[] header, String[] values, int numRows) throws SQLException { - ResultSet rs = mock(ResultSet.class); - ResultSetMetaData rsmd = MockResultSetMetaDataBuilder.buildMetaData(header); - - when(rs.getMetaData()).thenReturn(rsmd); - - for (int i = 0; i < values.length; i++) { - buildStringExpects(rs, i + 1, values[i], numRows); - } - buildNextExpect(rs, numRows); - return rs; //To change body of created methods use File | Settings | File Templates. - } - - private static void buildStringExpects(ResultSet rs, int index, String value, int numRows) throws SQLException { - - if (numRows > 1) { - String[] columnValues = new String[numRows]; - for (int i = 0; i < numRows - 1; i++) { - columnValues[i] = value; - } - when(rs.getString(index)).thenReturn(value, columnValues); - } else { - when(rs.getString(index)).thenReturn(value); - } - - } - - private static void buildNextExpect(ResultSet rs, int numRows) throws SQLException { - if (numRows == 1) { - when(rs.next()).thenReturn(true, false); - } else { - Boolean[] nextArray = new Boolean[numRows]; - for (int i = 0; i < numRows; i++) { - nextArray[i] = i < (numRows - 1); - } - when(rs.next()).thenReturn(true, nextArray); - } - - } -} diff --git a/test/au/com/bytecode/opencsv/MockResultSetHelper.java b/test/au/com/bytecode/opencsv/MockResultSetHelper.java new file mode 100644 index 0000000..0a0dfcc --- /dev/null +++ b/test/au/com/bytecode/opencsv/MockResultSetHelper.java @@ -0,0 +1,45 @@ +package au.com.bytecode.opencsv; +/** + Copyright 2005 Bytecode Pty Ltd. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ +import java.io.IOException; +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * Created by IntelliJ IDEA. + * User: scott + * Date: Dec 12, 2009 + * Time: 9:54:50 AM + * To change this template use File | Settings | File Templates. + */ +public class MockResultSetHelper implements ResultSetHelper { + + private String[] columnNames; + private String[] columnValues; + + public MockResultSetHelper(String[] names, String[] values) { + columnNames = names; + columnValues = values; + } + + public String[] getColumnNames(ResultSet rs) throws SQLException { + return columnNames; + } + + public String[] getColumnValues(ResultSet rs) throws SQLException, IOException { + return columnValues; + } +} diff --git a/test/au/com/bytecode/opencsv/MockResultSetMetaData.java b/test/au/com/bytecode/opencsv/MockResultSetMetaData.java new file mode 100644 index 0000000..9ab8a31 --- /dev/null +++ b/test/au/com/bytecode/opencsv/MockResultSetMetaData.java @@ -0,0 +1,130 @@ +package au.com.bytecode.opencsv; +/** + Copyright 2005 Bytecode Pty Ltd. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ +import java.sql.ResultSetMetaData; +import java.sql.SQLException; + +/** + * Created by IntelliJ IDEA. + * User: scott + * Date: Dec 13, 2009 + * Time: 10:27:13 PM + * To change this template use File | Settings | File Templates. + */ +public class MockResultSetMetaData implements ResultSetMetaData { + String[] columnNames; + int[] columnTypes; + + public void setColumnNames(String[] names) { + columnNames = names; + } + + public void setColumnTypes(int[] types) { + columnTypes = types; + } + + public int getColumnCount() throws SQLException { + return columnNames.length; + } + + public boolean isAutoIncrement(int i) throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isCaseSensitive(int i) throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isSearchable(int i) throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isCurrency(int i) throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public int isNullable(int i) throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isSigned(int i) throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public int getColumnDisplaySize(int i) throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public String getColumnLabel(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public String getColumnName(int i) throws SQLException { + return columnNames[i-1]; //To change body of implemented methods use File | Settings | File Templates. + } + + public String getSchemaName(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public int getPrecision(int i) throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public int getScale(int i) throws SQLException { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public String getTableName(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public String getCatalogName(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public int getColumnType(int i) throws SQLException { + return columnTypes[i-1]; + } + + public String getColumnTypeName(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isReadOnly(int i) throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isWritable(int i) throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isDefinitelyWritable(int i) throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public String getColumnClassName(int i) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public T unwrap(Class tClass) throws SQLException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isWrapperFor(Class aClass) throws SQLException { + return false; //To change body of implemented methods use File | Settings | File Templates. + } +} diff --git a/test/au/com/bytecode/opencsv/MockResultSetMetaDataBuilder.java b/test/au/com/bytecode/opencsv/MockResultSetMetaDataBuilder.java deleted file mode 100644 index 8472ed8..0000000 --- a/test/au/com/bytecode/opencsv/MockResultSetMetaDataBuilder.java +++ /dev/null @@ -1,36 +0,0 @@ -package au.com.bytecode.opencsv; - -import org.mockito.Mockito; - -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.sql.Types; - -public class MockResultSetMetaDataBuilder { - - public static ResultSetMetaData buildMetaData(String[] columnNames) throws SQLException { - - ResultSetMetaData metaData = Mockito.mock(ResultSetMetaData.class); - - Mockito.when(metaData.getColumnCount()).thenReturn(columnNames.length); - for (int i = 0; i < columnNames.length; i++) { - Mockito.when(metaData.getColumnName(i + 1)).thenReturn(columnNames[i]); - Mockito.when(metaData.getColumnType(i + 1)).thenReturn(Types.VARCHAR); - } - - return metaData; - } - - public static ResultSetMetaData buildMetaData(String[] columnNames, int[] columnTypes) throws SQLException { - - ResultSetMetaData metaData = Mockito.mock(ResultSetMetaData.class); - - Mockito.when(metaData.getColumnCount()).thenReturn(columnNames.length); - for (int i = 0; i < columnNames.length; i++) { - Mockito.when(metaData.getColumnName(i + 1)).thenReturn(columnNames[i]); - Mockito.when(metaData.getColumnType(i + 1)).thenReturn(columnTypes[i]); - } - - return metaData; - } -} \ No newline at end of file diff --git a/test/au/com/bytecode/opencsv/ResultSetHelperServiceTest.java b/test/au/com/bytecode/opencsv/ResultSetHelperServiceTest.java index 3a5c1ba..d9729c9 100644 --- a/test/au/com/bytecode/opencsv/ResultSetHelperServiceTest.java +++ b/test/au/com/bytecode/opencsv/ResultSetHelperServiceTest.java @@ -15,9 +15,7 @@ limitations under the License. */ -import org.junit.Assert; import org.junit.Test; -import org.mockito.Mockito; import java.io.IOException; import java.sql.*; @@ -38,33 +36,34 @@ public class ResultSetHelperServiceTest { @Test public void canPrintColumnNames() throws SQLException { - - ResultSet resultSet = Mockito.mock(ResultSet.class); + MockResultSet resultSet = new MockResultSet(); + MockResultSetMetaData metaData = new MockResultSetMetaData(); String[] expectedNames = {"name1", "name2", "name3"}; - - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames); - - Mockito.when(resultSet.getMetaData()).thenReturn(metaData); - - // end expects + metaData.setColumnNames(expectedNames); + resultSet.setMetaData(metaData); ResultSetHelperService service = new ResultSetHelperService(); String[] columnNames = service.getColumnNames(resultSet); - Assert.assertArrayEquals(expectedNames, columnNames); + assertArrayEquals(expectedNames, columnNames); } @Test public void getObjectFromResultSet() throws SQLException, IOException { + MockResultSet resultSet = new MockResultSet(); + MockResultSetMetaData metaData = new MockResultSetMetaData(); + String[] expectedNames = {"object", "Null Object"}; String[] realValues = {"foo", null}; String[] expectedValues = {"foo", ""}; - int[] expectedTypes = {Types.JAVA_OBJECT, Types.JAVA_OBJECT}; + int[] expectedTypes = {Types.JAVA_OBJECT,Types.JAVA_OBJECT}; - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); + metaData.setColumnNames(expectedNames); + metaData.setColumnTypes(expectedTypes); + resultSet.setMetaData(metaData); + resultSet.setColumnValues(realValues); ResultSetHelperService service = new ResultSetHelperService(); @@ -75,14 +74,18 @@ public void getObjectFromResultSet() throws SQLException, IOException { @Test public void getBitFromResultSet() throws SQLException, IOException { + MockResultSet resultSet = new MockResultSet(); + MockResultSetMetaData metaData = new MockResultSetMetaData(); String[] expectedNames = {"bit", "Null bit"}; String[] realValues = {"1", null}; String[] expectedValues = {"1", ""}; - int[] expectedTypes = {Types.BIT, Types.BIT}; + int[] expectedTypes = {Types.BIT,Types.BIT}; - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); + metaData.setColumnNames(expectedNames); + metaData.setColumnTypes(expectedTypes); + resultSet.setMetaData(metaData); + resultSet.setColumnValues(realValues); ResultSetHelperService service = new ResultSetHelperService(); @@ -93,13 +96,18 @@ public void getBitFromResultSet() throws SQLException, IOException { @Test public void getBooleanFromResultSet() throws SQLException, IOException { + MockResultSet resultSet = new MockResultSet(); + MockResultSetMetaData metaData = new MockResultSetMetaData(); + String[] expectedNames = {"true", "false", "TRUE", "FALSE", "Null"}; String[] realValues = {"true", "false", "TRUE", "FALSE", null}; String[] expectedValues = {"true", "false", "true", "false", "false"}; - int[] expectedTypes = {Types.BOOLEAN, Types.BOOLEAN, Types.BOOLEAN, Types.BOOLEAN, Types.BOOLEAN}; + int[] expectedTypes = {Types.BOOLEAN,Types.BOOLEAN,Types.BOOLEAN,Types.BOOLEAN,Types.BOOLEAN}; - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); + metaData.setColumnNames(expectedNames); + metaData.setColumnTypes(expectedTypes); + resultSet.setMetaData(metaData); + resultSet.setColumnValues(realValues); ResultSetHelperService service = new ResultSetHelperService(); @@ -110,13 +118,18 @@ public void getBooleanFromResultSet() throws SQLException, IOException { @Test public void getBigIntFromResultSet() throws SQLException, IOException { + MockResultSet resultSet = new MockResultSet(); + MockResultSetMetaData metaData = new MockResultSetMetaData(); + String[] expectedNames = {"BigInt", "Null BigInt"}; String[] realValues = {"100", null}; String[] expectedValues = {"100", ""}; - int[] expectedTypes = {Types.BIGINT, Types.BIGINT}; + int[] expectedTypes = {Types.BIGINT,Types.BIGINT}; - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); + metaData.setColumnNames(expectedNames); + metaData.setColumnTypes(expectedTypes); + resultSet.setMetaData(metaData); + resultSet.setColumnValues(realValues); ResultSetHelperService service = new ResultSetHelperService(); @@ -127,14 +140,18 @@ public void getBigIntFromResultSet() throws SQLException, IOException { @Test public void getBigDecimalFromResultSet() throws SQLException, IOException { + MockResultSet resultSet = new MockResultSet(); + MockResultSetMetaData metaData = new MockResultSetMetaData(); String[] expectedNames = {"Decimal", "double", "float", "real", "numeric", "Null"}; String[] realValues = {"1.1", "2.2", "3.3", "4.4", "5.5", null}; String[] expectedValues = {"1.1", "2.2", "3.3", "4.4", "5.5", ""}; - int[] expectedTypes = {Types.DECIMAL, Types.DOUBLE, Types.FLOAT, Types.REAL, Types.NUMERIC, Types.DECIMAL}; + int[] expectedTypes = {Types.DECIMAL,Types.DOUBLE,Types.FLOAT,Types.REAL,Types.NUMERIC,Types.DECIMAL}; - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); + metaData.setColumnNames(expectedNames); + metaData.setColumnTypes(expectedTypes); + resultSet.setMetaData(metaData); + resultSet.setColumnValues(realValues); ResultSetHelperService service = new ResultSetHelperService(); @@ -145,13 +162,18 @@ public void getBigDecimalFromResultSet() throws SQLException, IOException { @Test public void getIntegerFromResultSet() throws SQLException, IOException { + MockResultSet resultSet = new MockResultSet(); + MockResultSetMetaData metaData = new MockResultSetMetaData(); + String[] expectedNames = {"Integer", "tinyint", "smallint", "Null"}; String[] realValues = {"1", "2", "3", null}; String[] expectedValues = {"1", "2", "3", ""}; - int[] expectedTypes = {Types.INTEGER, Types.TINYINT, Types.SMALLINT, Types.INTEGER}; + int[] expectedTypes = {Types.INTEGER,Types.TINYINT,Types.SMALLINT,Types.INTEGER}; - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); + metaData.setColumnNames(expectedNames); + metaData.setColumnTypes(expectedTypes); + resultSet.setMetaData(metaData); + resultSet.setColumnValues(realValues); ResultSetHelperService service = new ResultSetHelperService(); @@ -162,14 +184,18 @@ public void getIntegerFromResultSet() throws SQLException, IOException { @Test public void getCharFromResultSet() throws SQLException, IOException { + MockResultSet resultSet = new MockResultSet(); + MockResultSetMetaData metaData = new MockResultSetMetaData(); String[] expectedNames = {"longvarchar", "varchar", "char", "Null"}; String[] realValues = {"a", "b", "c", null}; String[] expectedValues = {"a", "b", "c", ""}; - int[] expectedTypes = {Types.LONGVARCHAR, Types.VARCHAR, Types.CHAR, Types.CHAR}; + int[] expectedTypes = {Types.LONGVARCHAR,Types.VARCHAR,Types.CHAR,Types.CHAR}; - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); + metaData.setColumnNames(expectedNames); + metaData.setColumnTypes(expectedTypes); + resultSet.setMetaData(metaData); + resultSet.setColumnValues(realValues); ResultSetHelperService service = new ResultSetHelperService(); @@ -178,34 +204,20 @@ public void getCharFromResultSet() throws SQLException, IOException { } - @Test - public void getCharHandlesNulls() throws SQLException, IOException { - - String[] expectedNames = {"longvarchar", "varchar", "char", "Null"}; - String[] realValues = {"a", "b", "c", null}; - String[] expectedValues = {"a", "b", "c", ""}; - int[] expectedTypes = {Types.LONGVARCHAR, Types.VARCHAR, Types.CHAR, Types.CHAR}; - - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); - - ResultSetHelperService service = new ResultSetHelperService(); - - String[] columnValues = service.getColumnValues(resultSet, true); - assertArrayEquals(expectedValues, columnValues); - - } - @Test public void getUnsupportedFromResultSet() throws SQLException, IOException { + MockResultSet resultSet = new MockResultSet(); + MockResultSetMetaData metaData = new MockResultSetMetaData(); String[] expectedNames = {"Array", "Null"}; - String[] realValues = {"1", null}; + String[] realValues = {"1", null}; String[] expectedValues = {"", ""}; - int[] expectedTypes = {Types.ARRAY, Types.ARRAY}; + int[] expectedTypes = {Types.ARRAY,Types.ARRAY}; - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); + metaData.setColumnNames(expectedNames); + metaData.setColumnTypes(expectedTypes); + resultSet.setMetaData(metaData); + resultSet.setColumnValues(realValues); ResultSetHelperService service = new ResultSetHelperService(); @@ -216,18 +228,22 @@ public void getUnsupportedFromResultSet() throws SQLException, IOException { @Test public void getDateFromResultSet() throws SQLException, IOException { + MockResultSet resultSet = new MockResultSet(); + MockResultSetMetaData metaData = new MockResultSetMetaData(); Date date = new Date(109, 11, 15); // 12/15/2009 long dateInMilliSeconds = date.getTime(); - SimpleDateFormat dateFormat = new SimpleDateFormat(ResultSetHelperService.DEFAULT_DATE_FORMAT); + SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy"); String[] expectedNames = {"Date", "Null"}; - String[] realValues = {Long.toString(dateInMilliSeconds), null}; + String[] realValues = {Long.toString(dateInMilliSeconds), null}; String[] expectedValues = {dateFormat.format(date), ""}; - int[] expectedTypes = {Types.DATE, Types.DATE}; + int[] expectedTypes = {Types.DATE,Types.DATE}; - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); + metaData.setColumnNames(expectedNames); + metaData.setColumnTypes(expectedTypes); + resultSet.setMetaData(metaData); + resultSet.setColumnValues(realValues); ResultSetHelperService service = new ResultSetHelperService(); @@ -236,42 +252,23 @@ public void getDateFromResultSet() throws SQLException, IOException { } - @Test - public void getDateFromResultSetUsingCustomFormat() throws SQLException, IOException { - - String customDateFormat = "mm/dd/yy"; - Date date = new Date(109, 11, 15); // 12/15/2009 - long dateInMilliSeconds = date.getTime(); - SimpleDateFormat dateFormat = new SimpleDateFormat(customDateFormat); - - String[] expectedNames = {"Date", "Null"}; - String[] realValues = {Long.toString(dateInMilliSeconds), null}; - String[] expectedValues = {dateFormat.format(date), ""}; - int[] expectedTypes = {Types.DATE, Types.DATE}; - - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); - - ResultSetHelperService service = new ResultSetHelperService(); - - String[] columnValues = service.getColumnValues(resultSet, false, customDateFormat, null); - assertArrayEquals(expectedValues, columnValues); - - } - @Test public void getTimeFromResultSet() throws SQLException, IOException { + MockResultSet resultSet = new MockResultSet(); + MockResultSetMetaData metaData = new MockResultSetMetaData(); Time time = new Time(12, 0, 0); // noon long dateInMilliSeconds = time.getTime(); String[] expectedNames = {"Time", "Null"}; - String[] realValues = {Long.toString(dateInMilliSeconds), null}; + String[] realValues = {Long.toString(dateInMilliSeconds), null}; String[] expectedValues = {time.toString(), ""}; - int[] expectedTypes = {Types.TIME, Types.TIME}; + int[] expectedTypes = {Types.TIME,Types.TIME}; - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); + metaData.setColumnNames(expectedNames); + metaData.setColumnTypes(expectedTypes); + resultSet.setMetaData(metaData); + resultSet.setColumnValues(realValues); ResultSetHelperService service = new ResultSetHelperService(); @@ -282,58 +279,46 @@ public void getTimeFromResultSet() throws SQLException, IOException { @Test public void getTimestampFromResultSet() throws SQLException, IOException { - Timestamp date = new Timestamp(109, 11, 15, 12, 0, 0, 0); // 12/15/2009 noon - long dateInMilliSeconds = date.getTime(); - SimpleDateFormat timeFormat = new SimpleDateFormat(ResultSetHelperService.DEFAULT_TIMESTAMP_FORMAT); - - String[] expectedNames = {"Timestamp", "Null"}; - String[] realValues = {Long.toString(dateInMilliSeconds), null}; - String[] expectedValues = {timeFormat.format(date), ""}; - int[] expectedTypes = {Types.TIMESTAMP, Types.TIMESTAMP}; + MockResultSet resultSet = new MockResultSet(); + MockResultSetMetaData metaData = new MockResultSetMetaData(); - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); - - ResultSetHelperService service = new ResultSetHelperService(); - - String[] columnValues = service.getColumnValues(resultSet); - assertArrayEquals(expectedValues, columnValues); - - } - - @Test - public void getTimestampFromResultSetWithCustomFormat() throws SQLException, IOException { Timestamp date = new Timestamp(109, 11, 15, 12, 0, 0, 0); // 12/15/2009 noon long dateInMilliSeconds = date.getTime(); - String customFormat = "mm/dd/yy HH:mm:ss"; - SimpleDateFormat timeFormat = new SimpleDateFormat(customFormat); + SimpleDateFormat timeFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); String[] expectedNames = {"Timestamp", "Null"}; - String[] realValues = {Long.toString(dateInMilliSeconds), null}; + String[] realValues = {Long.toString(dateInMilliSeconds), null}; String[] expectedValues = {timeFormat.format(date), ""}; - int[] expectedTypes = {Types.TIMESTAMP, Types.TIMESTAMP}; + int[] expectedTypes = {Types.TIMESTAMP,Types.TIMESTAMP}; - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); + metaData.setColumnNames(expectedNames); + metaData.setColumnTypes(expectedTypes); + resultSet.setMetaData(metaData); + resultSet.setColumnValues(realValues); ResultSetHelperService service = new ResultSetHelperService(); - String[] columnValues = service.getColumnValues(resultSet, false, null, customFormat); + String[] columnValues = service.getColumnValues(resultSet); assertArrayEquals(expectedValues, columnValues); } @Test public void getClobFromResultSet() throws SQLException, IOException { + MockResultSet resultSet = new MockResultSet(); + MockResultSetMetaData metaData = new MockResultSetMetaData(); + String clobString = buildClobString(20); String[] expectedNames = {"Clob", "Null"}; - String[] realValues = {clobString, null}; + String[] realValues = {clobString, null}; String[] expectedValues = {clobString, ""}; - int[] expectedTypes = {Types.CLOB, Types.CLOB}; + int[] expectedTypes = {Types.CLOB,Types.CLOB}; - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); + metaData.setColumnNames(expectedNames); + metaData.setColumnTypes(expectedTypes); + resultSet.setMetaData(metaData); + resultSet.setColumnValues(realValues); ResultSetHelperService service = new ResultSetHelperService(); @@ -344,15 +329,20 @@ public void getClobFromResultSet() throws SQLException, IOException { @Test public void getEmptyClobFromResultSet() throws SQLException, IOException { + MockResultSet resultSet = new MockResultSet(); + MockResultSetMetaData metaData = new MockResultSetMetaData(); + String clobString = buildClobString(0); String[] expectedNames = {"Clob", "Null"}; - String[] realValues = {clobString, null}; + String[] realValues = {clobString, null}; String[] expectedValues = {clobString, ""}; - int[] expectedTypes = {Types.CLOB, Types.CLOB}; + int[] expectedTypes = {Types.CLOB,Types.CLOB}; - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); + metaData.setColumnNames(expectedNames); + metaData.setColumnTypes(expectedTypes); + resultSet.setMetaData(metaData); + resultSet.setColumnValues(realValues); ResultSetHelperService service = new ResultSetHelperService(); @@ -363,15 +353,20 @@ public void getEmptyClobFromResultSet() throws SQLException, IOException { @Test public void getLargeClobFromResultSet() throws SQLException, IOException { + MockResultSet resultSet = new MockResultSet(); + MockResultSetMetaData metaData = new MockResultSetMetaData(); + String clobString = buildClobString(ResultSetHelperService.CLOBBUFFERSIZE + 1); String[] expectedNames = {"Clob", "Null"}; - String[] realValues = {clobString, null}; + String[] realValues = {clobString, null}; String[] expectedValues = {clobString, ""}; - int[] expectedTypes = {Types.CLOB, Types.CLOB}; + int[] expectedTypes = {Types.CLOB,Types.CLOB}; - ResultSetMetaData metaData = MockResultSetMetaDataBuilder.buildMetaData(expectedNames, expectedTypes); - ResultSet resultSet = MockResultSetBuilder.buildResultSet(metaData, realValues, expectedTypes); + metaData.setColumnNames(expectedNames); + metaData.setColumnTypes(expectedTypes); + resultSet.setMetaData(metaData); + resultSet.setColumnValues(realValues); ResultSetHelperService service = new ResultSetHelperService(); diff --git a/test/au/com/bytecode/opencsv/bean/BeanToCsvTest.java b/test/au/com/bytecode/opencsv/bean/BeanToCsvTest.java deleted file mode 100644 index 404cc8d..0000000 --- a/test/au/com/bytecode/opencsv/bean/BeanToCsvTest.java +++ /dev/null @@ -1,151 +0,0 @@ -package au.com.bytecode.opencsv.bean; - -import au.com.bytecode.opencsv.CSVReader; -import au.com.bytecode.opencsv.CSVWriter; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import java.beans.IntrospectionException; -import java.beans.PropertyDescriptor; -import java.io.IOException; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertFalse; - -public class BeanToCsvTest { - - private static final String TEST_STRING = "\"name\",\"orderNumber\",\"num\"\n" - + "\"kyle\",\"abc123456\",\"123\"\n" - + "\"jimmy\",\"def098765\",\"456\"\n"; - - private static final String NULL_TEST_STRING = "\"name\",\"orderNumber\",\"num\"\n" - + "\"null\",\"null\",\"1\"\n" - + "\"null\",\"null\",\"2\"\n"; - - private List testData; - private List nullData; - private BeanToCsv bean; - - @Before - public void setUp() { - bean = new BeanToCsv(); - } - - @Before - public void setTestData() { - testData = new ArrayList(); - MockBean mb = new MockBean(); - mb.setName("kyle"); - mb.setOrderNumber("abc123456"); - mb.setNum(123); - testData.add(mb); - mb = new MockBean(); - mb.setName("jimmy"); - mb.setOrderNumber("def098765"); - mb.setNum(456); - testData.add(mb); - } - - @Before - public void setNullData() { - nullData = new ArrayList(); - MockBean mb = new MockBean(); - mb.setName(null); - mb.setOrderNumber(null); - mb.setNum(1); - nullData.add(mb); - mb = new MockBean(); - mb.setName(null); - mb.setOrderNumber(null); - mb.setNum(2); - nullData.add(mb); - } - - private MappingStrategy createErrorMappingStrategy() { - return new MappingStrategy() { - - public PropertyDescriptor findDescriptor(int col) - throws IntrospectionException { - throw new IntrospectionException("This is the test exception"); - } - - public Object createBean() throws InstantiationException, - IllegalAccessException { - return null; - } - - public void captureHeader(CSVReader reader) throws IOException { - } - }; - } - - @Test(expected = RuntimeException.class) - public void throwRuntimeExceptionWhenExceptionIsThrown() { - StringWriter sw = new StringWriter(); - CSVWriter writer = new CSVWriter(sw); - bean.write(createErrorMappingStrategy(), writer, testData); - } - - @Test - public void beanReturnsFalseOnEmptyList() { - ColumnPositionMappingStrategy strat = new ColumnPositionMappingStrategy(); - strat.setType(MockBean.class); - String[] columns = new String[]{"name", "orderNumber", "num"}; - strat.setColumnMapping(columns); - - StringWriter sw = new StringWriter(); - - assertFalse(bean.write(strat, sw, new ArrayList())); - } - - @Test - public void beanReturnsFalseOnNull() { - ColumnPositionMappingStrategy strat = new ColumnPositionMappingStrategy(); - strat.setType(MockBean.class); - String[] columns = new String[]{"name", "orderNumber", "num"}; - strat.setColumnMapping(columns); - - StringWriter sw = new StringWriter(); - - assertFalse(bean.write(strat, sw, null)); - } - - @Test - public void testWriteQuotes() throws IOException { - ColumnPositionMappingStrategy strat = new ColumnPositionMappingStrategy(); - strat.setType(MockBean.class); - String[] columns = new String[]{"name", "orderNumber", "num"}; - strat.setColumnMapping(columns); - - StringWriter sw = new StringWriter(); - - boolean value = bean.write(strat, sw, testData); - - Assert.assertTrue(value); - - String content = sw.getBuffer().toString(); - Assert.assertNotNull(content); - Assert.assertEquals(TEST_STRING, content); - } - - @Test - public void testWriteNulls() throws IOException { - ColumnPositionMappingStrategy strat = new ColumnPositionMappingStrategy(); - strat.setType(MockBean.class); - String[] columns = new String[]{"name", "orderNumber", "num"}; - strat.setColumnMapping(columns); - - StringWriter sw = new StringWriter(); - - boolean value = bean.write(strat, sw, nullData); - - Assert.assertTrue(value); - - String content = sw.getBuffer().toString(); - Assert.assertNotNull(content); - Assert.assertEquals(NULL_TEST_STRING, content); - } -} diff --git a/test/au/com/bytecode/opencsv/bean/ColumnPositionMappingStrategyTest.java b/test/au/com/bytecode/opencsv/bean/ColumnPositionMappingStrategyTest.java index 83fb061..3112e4a 100644 --- a/test/au/com/bytecode/opencsv/bean/ColumnPositionMappingStrategyTest.java +++ b/test/au/com/bytecode/opencsv/bean/ColumnPositionMappingStrategyTest.java @@ -41,7 +41,8 @@ public void testParse() { "kyle,123456,emp123,1\n" + "jimmy,abcnum,cust09878,2"; - strat.setColumnMapping("name", "orderNumber", "id", "num"); + String[] columns = new String[]{"name", "orderNumber", "id", "num"}; + strat.setColumnMapping(columns); CsvToBean csv = new CsvToBean(); List list = csv.parse(strat, new StringReader(s)); @@ -93,7 +94,8 @@ public void testGetColumnMapping() { @Test public void testGetColumnNames() { - strat.setColumnMapping("name", null, "id"); + String[] columns = new String[]{"name", null, "id"}; + strat.setColumnMapping(columns); assertEquals("name", strat.getColumnName(0)); assertEquals(null, strat.getColumnName(1)); @@ -104,7 +106,8 @@ public void testGetColumnNames() { @Test public void testGetColumnNamesArray() { - strat.setColumnMapping("name", null, "id"); + String[] columns = new String[]{"name", null, "id"}; + strat.setColumnMapping(columns); String[] mapping = strat.getColumnMapping(); assertEquals(3, mapping.length); @@ -114,30 +117,12 @@ public void testGetColumnNamesArray() { } @Test - public void getColumnNamesWhenNullArray() { - strat.setColumnMapping((String[]) null); - - assertEquals(null, strat.getColumnName(0)); - assertEquals(null, strat.getColumnName(1)); - assertArrayEquals(new String[0], strat.getColumnMapping()); - } - - @Test - public void getColumnNamesWhenNullColumnName() { - String[] columns = {null}; - strat.setColumnMapping(columns); + public void getColumnNamesHandlesNull() { + strat.setColumnMapping(null); assertEquals(null, strat.getColumnName(0)); assertEquals(null, strat.getColumnName(1)); - assertArrayEquals(columns, strat.getColumnMapping()); - } - - @Test - public void getColumnNamesWhenEmptyMapping() { - strat.setColumnMapping(); - - assertEquals(null, strat.getColumnName(0)); - assertArrayEquals(new String[0], strat.getColumnMapping()); + assertNull(strat.getColumnMapping()); } } diff --git a/test/au/com/bytecode/opencsv/bean/HeaderColumnNameMappingStrategyTest.java b/test/au/com/bytecode/opencsv/bean/HeaderColumnNameMappingStrategyTest.java index ce4b3fa..389fd6a 100644 --- a/test/au/com/bytecode/opencsv/bean/HeaderColumnNameMappingStrategyTest.java +++ b/test/au/com/bytecode/opencsv/bean/HeaderColumnNameMappingStrategyTest.java @@ -32,32 +32,17 @@ public class HeaderColumnNameMappingStrategyTest { "kyle,abc123456,123\n" + "jimmy,def098765,456"; - private static final String TEST_QUOTED_STRING = "\"name\",\"orderNumber\",\"num\"\n" + - "\"kyle\",\"abc123456\",\"123\"\n" + - "\"jimmy\",\"def098765\",\"456\""; - - private List createTestParseResult(String parseString) { + private List createTestParseResult() { HeaderColumnNameMappingStrategy strat = new HeaderColumnNameMappingStrategy(); strat.setType(MockBean.class); CsvToBean csv = new CsvToBean(); - return csv.parse(strat, new StringReader(parseString)); + return csv.parse(strat, new StringReader(TEST_STRING)); } @Test public void testParse() { - List list = createTestParseResult(TEST_STRING); - assertNotNull(list); - assertTrue(list.size() == 2); - MockBean bean = list.get(0); - assertEquals("kyle", bean.getName()); - assertEquals("abc123456", bean.getOrderNumber()); - assertEquals(123, bean.getNum()); - } - - @Test - public void testQuotedString() { - List list = createTestParseResult(TEST_QUOTED_STRING); + List list = createTestParseResult(); assertNotNull(list); assertTrue(list.size() == 2); MockBean bean = list.get(0); @@ -68,7 +53,7 @@ public void testQuotedString() { @Test public void testParseWithSpacesInHeader() { - List list = createTestParseResult(TEST_STRING); + List list = createTestParseResult(); assertNotNull(list); assertTrue(list.size() == 2); MockBean bean = list.get(0); diff --git a/test/integrationTest/issue3189428/CsvSample.java b/test/integrationTest/issue3189428/CsvSample.java index d1f6789..86ca741 100644 --- a/test/integrationTest/issue3189428/CsvSample.java +++ b/test/integrationTest/issue3189428/CsvSample.java @@ -98,12 +98,12 @@ protected void testRawCsvRead(String originalCommentText) */ protected void testMappingStrategyRead(String originalCommentText) throws FileNotFoundException { - ColumnPositionMappingStrategy mappingStrategy = new ColumnPositionMappingStrategy(); + ColumnPositionMappingStrategy mappingStrategy = new ColumnPositionMappingStrategy(); mappingStrategy.setType(MyBean.class); String[] columns = new String[]{"name", "value", "amount1", "currency", "comments"}; // the fields to bind to in your JavaBean mappingStrategy.setColumnMapping(columns); - CsvToBean csv = new CsvToBean(); + CsvToBean csv = new CsvToBean(); CSVReader reader = new CSVReader(new FileReader(filePath), CSVParser.DEFAULT_SEPARATOR, CSVParser.DEFAULT_QUOTE_CHARACTER, CSVParser.DEFAULT_ESCAPE_CHARACTER, 0, false, false); List list = csv.parse(mappingStrategy, reader); diff --git a/test/integrationTest/issue3402853/HeaderColumnNameMappingStrategyUserTest.java b/test/integrationTest/issue3402853/HeaderColumnNameMappingStrategyUserTest.java deleted file mode 100644 index 3ca02c9..0000000 --- a/test/integrationTest/issue3402853/HeaderColumnNameMappingStrategyUserTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package integrationTest.issue3402853; - -/** - Copyright 2007 Kyle Miller. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - - -import au.com.bytecode.opencsv.CSVReader; -import au.com.bytecode.opencsv.bean.CsvToBean; -import au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy; -import org.junit.Test; - -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -public class HeaderColumnNameMappingStrategyUserTest { - - private static final String USER_FILE = "test/integrationTest/issue3402853/user.csv"; - - private List createTestParseResult() throws FileNotFoundException { - CSVReader reader = new CSVReader(new FileReader(USER_FILE)); - HeaderColumnNameMappingStrategy strat = new HeaderColumnNameMappingStrategy(); - strat.setType(MockUserBean.class); - CsvToBean csv = new CsvToBean(); - return csv.parse(strat, reader); - } - - @Test - public void testParse() throws FileNotFoundException { - List list = createTestParseResult(); - assertNotNull(list); - assertEquals(2, list.size()); - MockUserBean bean = list.get(0); - assertEquals("rbst218@yahoo.com", bean.getEmail()); - assertEquals("\\\"CHia Sia Ta", bean.getFirst_Name()); - assertEquals("", bean.getLast_Name()); - assertEquals("bc1er1163", bean.getProfile_Id()); - } - -} diff --git a/test/integrationTest/issue3402853/MockUserBean.java b/test/integrationTest/issue3402853/MockUserBean.java deleted file mode 100644 index c2cb7fd..0000000 --- a/test/integrationTest/issue3402853/MockUserBean.java +++ /dev/null @@ -1,118 +0,0 @@ -package integrationTest.issue3402853; - -/** - * Created by IntelliJ IDEA. - * User: sconway - * Date: 9/5/11 - * Time: 10:06 PM - * To change this template use File | Settings | File Templates. - */ -public class MockUserBean { - public static final String DEFAULT_BLANK_FIELD = ""; - private String profile_id = ""; - private String email = ""; - private String secondary_email = ""; - private String first_name = DEFAULT_BLANK_FIELD; - private String last_name = DEFAULT_BLANK_FIELD; - - public String getProfile_Id() { - return profile_id; - } - - public void setProfile_Id(String userId) { - this.profile_id = userId; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getFirst_Name() { - return first_name; - } - - public void setFirst_Name(String firstName) { - this.first_name = firstName; - } - - public String getLast_Name() { - return last_name; - } - - public void setLast_Name(String lastName) { - this.last_name = lastName; - } - - public String toString() { - String userId = isEmpty(getProfile_Id()) ? "" : getProfile_Id().trim(); - String firstname = isEmpty(getFirst_Name()) ? "" : getFirst_Name().trim(); - String lastname = isEmpty(getLast_Name()) ? "" : getLast_Name().trim(); - String email = isEmpty(getEmail()) ? "" : getEmail().trim(); - StringBuffer value = new StringBuffer(); - value.append(",user id:" + userId); - value.append(",email:" + email); - value.append(",first name:" + firstname); - value.append(",last name:" + lastname); - - return value.toString(); - } - - public boolean equals(Object obj) { - if ((null == obj) || !(obj instanceof MockUserBean)) { - return false; - } - - if (this == obj) { - return true; - } - - return ((MockUserBean) obj).toString().equalsIgnoreCase(this.toString()); - } - - public int hashCode() { - return toString().hashCode(); - } - - public boolean isFirstNameEmpty() { - return isNameEmpty(getFirst_Name()); - } - - public boolean isLastNameEmpty() { - return isNameEmpty(getLast_Name()); - } - - private boolean isNameEmpty(String name) { - if (name == null || name.length() == 0 || DEFAULT_BLANK_FIELD.equals(name)) { - return true; - } - - return false; - } - - public void setSecondary_Email(String secondaryEmail) { - this.secondary_email = secondaryEmail; - } - - public String getSecondary_Email() { - return secondary_email; - } - - /** - * This method simply check if a String is null or blank - * - * @param value - * @return - */ - public boolean isEmpty(final String value) { - if ((null == value) || (value.trim().length() == 0)) { - return true; - } - - return false; - } - -} diff --git a/test/integrationTest/issue3402853/user.csv b/test/integrationTest/issue3402853/user.csv deleted file mode 100644 index 306ea54..0000000 --- a/test/integrationTest/issue3402853/user.csv +++ /dev/null @@ -1,3 +0,0 @@ -"id","email","profile_id","first_name","last_name" -"475592","rbst218@yahoo.com","bc1er1163","\\\"CHia Sia Ta","" -"12345","kazem.naderi@tt.com","bc234a","kazem","naderi" \ No newline at end of file