text
Class CSVGetter<L extends java.util.List>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<E>
java.util.LinkedList<L>
text.CSVGetter<L>
All Implemented Interfaces: java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<L>, java.util.Collection<L>, java.util.Deque<L>, java.util.List<L>, java.util.Queue<L>
public class CSVGetter<L extends java.util.List> extends java.util.LinkedList<L>
The CSV Getter is overloaded, which supports reading from a variety of formats,
it accepts a file object, or a string of content which gets read, and passed through
a method to separate the content based on a comma. The commas are found by looping through each character and
the system also detects quotes - therefore it allows commas to be inside of quoted text. The content doesn't need to
be separated on a new line, it can detect when content has been sparsed out over multiple lines.
Overloaded and Chained Constructors.
1: new CSVGetter>(TextFileIO.getContent(name));
2: new CSVGetter>(new File(name));
3: new CSVGetter>(new LinkedList(), new File(name));
4: new CSVGetter>(new Stack(), TextFileIO.getContent(name));
5: new CSVGetter>(new Vector(), TextFileIO.getContent(name));
6: new CSVGetter>(new ArrayList(), TextFileIO.getContent(name));
See Also: Serialized Form
Fields inherited from class java.util.AbstractList
modCount
Constructor Summary
CSVGetter (java.io.File file)
The constructors are chained, and the default constructor accepts a
File Object of the desired file to be read, and creates the enternal
structure as a LinkedList.
CSVGetter (L list,
java.io.File file)
The chained constructor accepts a instance of a List, and a File Object.
CSVGetter (L list,
java.io.File file,
char separator)
The chained constructor accepts a list instance, a file object, and a separating char.
CSVGetter (L list,
java.io.File file,
char separator,
char quote)
The chained contructor accepts a List instance, a file object, a separator, and a quote char.
CSVGetter (L list,
java.io.File file,
char separator,
char quote,
java.lang.String newline)
The chained constructor is the final chained constructor used with the File object.
CSVGetter (L list,
java.lang.String content)
The chained contructor receives a instance of a List, and the String content.
CSVGetter (L list,
java.lang.String content,
char separator)
The chained constructor recieves a List, a String of Content, and a Char
separating value.
CSVGetter (L list,
java.lang.String content,
char separator,
char quote)
The chained constructor receives a instance list, a string of content, a char separating value,
and a quoting char.
CSVGetter (L list,
java.lang.String content,
char separator,
char quote,
java.lang.String newline)
This is the final chained constructor for the use with a already existing String of content.
CSVGetter (java.lang.String content)
The series of chained constructors don't accept a file Object.
Method Summary
java.lang.Object[][]
getArray ()
The getArray method will convert the CSVGetter into a 2 Dimensional Array of Objects.
private java.lang.String
getContent (java.io.File file,
java.lang.String newline)
This method isn't used in the TextFilePackage, but it adds additional flexibility for further expansion, and for uses external to this application.
java.lang.Object
getElement (int row,
int col)
The getElement method provides a way of retrieving the stored element within a specified
record.
java.util.Set
getSet ()
The getSet method will provide a way of adding the list to a Map.
private void
readSource (L list,
java.lang.String content,
char separator,
char quote,
java.lang.String newline)
The readSource method receives the inner instance of the List, the String content,
the char separating value, and a char quote.
Methods inherited from class java.util.LinkedList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, toArray, toArray
Methods inherited from class java.util.AbstractSequentialList
iterator
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList
Methods inherited from interface java.util.Deque
iterator
serialVersionUID
private static final long serialVersionUID
See Also: Constant Field Values
NEW_LINE
private static final java.lang.String NEW_LINE
See Also: Constant Field Values
SPACE
private static final char SPACE
See Also: Constant Field Values
QUOTE
private static final char QUOTE
See Also: Constant Field Values
COMMA
private static final char COMMA
See Also: Constant Field Values
CSVGetter
public CSVGetter (java.io.File file)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.io.IOException
The constructors are chained, and the default constructor accepts a
File Object of the desired file to be read, and creates the enternal
structure as a LinkedList.
Parameters: file
- - A File Object of the Desired File.
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
CSVGetter
public CSVGetter (L list,
java.io.File file)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.io.IOException
The chained constructor accepts a instance of a List, and a File Object.
Parameters: list
- - Accepts a instantiated instance of the desired inner List;
which could be anything that extends the List super type.file
- - The File Object of the desired File to be read.
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
CSVGetter
public CSVGetter (L list,
java.io.File file,
char separator)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.io.IOException
The chained constructor accepts a list instance, a file object, and a separating char.
Parameters: list
- - The instance of the desired inner List.file
- - The desired File to be separatedseparator
- - The separator character.
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
CSVGetter
public CSVGetter (L list,
java.io.File file,
char separator,
char quote)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.io.IOException
The chained contructor accepts a List instance, a file object, a separator, and a quote char.
Parameters: list
- - The instance of the desired List.file
- - The desired File object.separator
- - The character to be separated at.quote
- - The Quote around the text, which could possibly contain separating characters.
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
CSVGetter
public CSVGetter (L list,
java.io.File file,
char separator,
char quote,
java.lang.String newline)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.io.IOException
The chained constructor is the final chained constructor used with the File object.
It directly from here goes into the process for converting the content of the file.
-- It contains a inner File content retrieval method for getting the content from the object,
allowing for the class to work indepently if it is taken out of the text file package at some point.
Parameters: list
- - A instance of the inner List.file
- - A desired File Objectseparator
- - Separating Characterquote
- - Quota Characternewline
- - New Line Character
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
CSVGetter
public CSVGetter (java.lang.String content)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException
The series of chained constructors don't accept a file Object. Instead it accepts
the String of the content. It instantiates a default inner list of Linked List,
and has the separator value of a Comma.
Parameters: content
- String - The String content, which has already been grabbed from a file.
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
CSVGetter
public CSVGetter (L list,
java.lang.String content)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException
The chained contructor receives a instance of a List, and the String content.
Parameters: list
- - A instance of the desired List format.content
- - A String of the content to be parsed.
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
CSVGetter
public CSVGetter (L list,
java.lang.String content,
char separator)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException
The chained constructor recieves a List, a String of Content, and a Char
separating value. It by default places the quote char as the quoting character.
Parameters: list
- - Instance of a List.content
- - String of content.separator
- - Char separating value.
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
CSVGetter
public CSVGetter (L list,
java.lang.String content,
char separator,
char quote)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException
The chained constructor receives a instance list, a string of content, a char separating value,
and a quoting char.
Parameters: list
- - Instance of a List.content
- - String of content.separator
- - Char separating value.quote
- - Quota Character
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
CSVGetter
public CSVGetter (L list,
java.lang.String content,
char separator,
char quote,
java.lang.String newline)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException
This is the final chained constructor for the use with a already existing String of content.
It now calls the readSource method which does the processing.
Parameters: list
- - A instance of the inner List.content
- -String of content.separator
- - Separating Characterquote
- - Quota Characternewline
- - New Line Character
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
readSource
private void readSource (L list,
java.lang.String content,
char separator,
char quote,
java.lang.String newline)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException
The readSource method receives the inner instance of the List, the String content,
the char separating value, and a char quote. It loops through each line tokenized on the
new line separating value. It creates a new instance of the inner list received for each
new line (which is a record); the inner list is used for the adding of each separated element.
The reader itself is very flexible. It can read a file sparsed out over multiple lines, and the file does
not have to be evenly structured. It will only separate on the separating value at times where it is not within
the quoting character, and if its still inside the quotes once it has reached the end of the line - it will continue to
the next. For each of the lines, it will loop through each character - which provides a more structured way of
deciphering each element.
For each of the elements it will create a string buffer, and the string buffer gets characters appended for each of the
until it has reached a separating value. It will add that element into the inner list instance, and create a new
string buffer for the next element. Once the line has been completed, it will add the instance of the inner list to itself (which is the
class, which extends LinkedList) and creates a new instance of the inner list and starts the cycle again until it
has reached the end of the content.
Parameters: list
- - Instance of the inner list.content
- - The content of String which will get separated.separator
- - The separating valuequote
- - The quoting character - for containing occurences of the separating value.newline
- - The line breaking character, which the content string gets tokenized at.
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
getContent
private java.lang.String getContent (java.io.File file,
java.lang.String newline)
throws java.io.IOException
This method isn't used in the TextFilePackage, but it adds additional flexibility for further expansion, and for uses external to this application.
It allows the CSV getter to act independent from the other classes; thus giving it more freedom.
Parameters: file
- Object which will get read.newline
- - separating the newline character.
Returns: String of content.
Throws:
java.io.IOException
getElement
public java.lang.Object getElement (int row,
int col)
The getElement method provides a way of retrieving the stored element within a specified
record.
Parameters: row
- Integer - the index of the record in the structure.col
- Integer - The stored element
Returns:
getSet
public java.util.Set getSet ()
The getSet method will provide a way of adding the list to a Map. By retrieving the
HasSet, it can easily be placed into a map structure. Therefore supporting Map structures.
Returns: HashSet
getArray
public java.lang.Object[][] getArray ()
The getArray method will convert the CSVGetter into a 2 Dimensional Array of Objects.
Returns: Object[][].