|
Oracle Fusion Middleware extensions for Applications Core API Reference 11g Release 1 (11.1.1.5) E22562-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.apps.fnd.applcore.attachments.utility.CsvTokenizer
public class CsvTokenizer
This class parses strings for CSV (Comma Seperated Variable) data. I define this format to be (and this should be consistant with all databases and spreadsheets): 1. fields seperated by commas. 2. a field will be null if two commas are adjacent. 3. fields have leading and terminating space chars trimmed. 4. If a field contains a comma it must be quoted. The quote char is ' (single quote). 5. A field is determined to be quoted if is starts with the quote char. 6. If a quoted field contains a quote, it must be escaped. The escape character (perversely) is a single quote. Note that surrounding quotes and escaped quotes are not taken out of the fields. It is assumed that the calling program will do this. eg: a,b,c ==> fields a b and c eg: 'a',,c ==> fields 'a' null and c eg: , ==> fields null and null eg: 'a,b',c ==> fields 'a,b' and c eg: 'a''b',c ==> fields 'a''b' and c This class works in much the same way as java.util.StringTokenizer. Standard Usage: String imp = "a,b,c"; CSVTokenizer tokenizer = new CSVTokenizer(inp); while (tokenizer.hasMoreTokens()) { System.out.println("==>" + tokenizer.nextToken() + "<=="); }
Field Summary | |
---|---|
static java.lang.String |
COMMA
|
Constructor Summary | |
---|---|
CsvTokenizer(java.lang.String value)
Constructs a CSV tokenizer for the specified string. |
Method Summary | |
---|---|
boolean |
hasMoreElements()
Returns the same value as the hasMoreTokens method. |
boolean |
hasMoreTokens()
Tests if there are more tokens available from this tokenizer's string. |
java.lang.Object |
nextElement()
Returns the next token from this string tokenizer. |
java.lang.Object |
nextToken()
Returns the same value as the nextElement method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String COMMA
Constructor Detail |
---|
public CsvTokenizer(java.lang.String value)
value
- The string tokenize.Method Detail |
---|
public boolean hasMoreTokens()
public boolean hasMoreElements()
hasMoreElements
in interface java.util.Enumeration
public java.lang.Object nextToken() throws java.util.NoSuchElementException
java.util.NoSuchElementException
public java.lang.Object nextElement() throws java.util.NoSuchElementException
nextElement
in interface java.util.Enumeration
java.lang.Exception
- if there is a problem parsing the string (ie it is not a valid CSV file).
java.util.NoSuchElementException
|
Oracle Fusion Middleware extensions for Applications Core API Reference 11g Release 1 (11.1.1.5) E22562-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |