org.jfin.common
Class CSVFileFormatTokenizer
- java.lang.Object
-
- org.jfin.common.CSVFileFormatTokenizer
-
public class CSVFileFormatTokenizer extends java.lang.ObjectClass to parse a single line of a .csv file and break it down into a series of tokens.
-
-
Constructor Summary
Constructors Constructor and Description CSVFileFormatTokenizer(java.lang.String input)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.lang.String[]getTokens()Utility method to allow quick conversion into an array of Strings.static java.lang.String[]getTokens(java.lang.String line)Utility static method to allow the quick conversion of a CSV formatted line into an array of Strings.booleanhasNext()Used to find if any more tokens are left to be parsed from the input String.voidinitialise(java.lang.String input)Initialises the CSVFormat object ready for parsing the new input string.java.lang.Stringnext()Used to retrive the next token (or null if there are no more) as a String.bytenextByte()bytenextByte(java.text.NumberFormat numberFormat)java.util.DatenextDate()java.util.DatenextDate(java.text.DateFormat dateFormat)doublenextDouble()doublenextDouble(java.text.NumberFormat numberFormat)floatnextFloat()floatnextFloat(java.text.NumberFormat numberFormat)intnextInt()intnextInt(java.text.NumberFormat numberFormat)longnextLong()longnextLong(java.text.NumberFormat numberFormat)java.lang.NumbernextNumber()java.lang.NumbernextNumber(java.text.NumberFormat numberFormat)shortnextShort()shortnextShort(java.text.NumberFormat numberFormat)
-
-
-
Constructor Detail
-
CSVFileFormatTokenizer
public CSVFileFormatTokenizer(java.lang.String input)
Constructor- Parameters:
input- A String representing a line of CSV Formatted text
-
-
Method Detail
-
initialise
public void initialise(java.lang.String input)
Initialises the CSVFormat object ready for parsing the new input string.- Parameters:
input- A String representing a line of CSV Formatted text
-
hasNext
public boolean hasNext()
Used to find if any more tokens are left to be parsed from the input String.- Returns:
- true if there are more tokens, otherwise false
-
next
public java.lang.String next()
Used to retrive the next token (or null if there are no more) as a String. If the original token was surrounded by quotes, for example if it contained commas, then the quotes are stripped.- Returns:
- the next token as a String
-
getTokens
public static java.lang.String[] getTokens(java.lang.String line)
Utility static method to allow the quick conversion of a CSV formatted line into an array of Strings.- Parameters:
line- The CSV Formatted line to be parsed- Returns:
- an array of String containing the tokens
-
getTokens
public java.lang.String[] getTokens()
Utility method to allow quick conversion into an array of Strings.- Returns:
- an array of String containing the tokens
-
nextNumber
public java.lang.Number nextNumber() throws java.text.ParseException- Returns:
- the next token as a Number
- Throws:
java.text.ParseException
-
nextNumber
public java.lang.Number nextNumber(java.text.NumberFormat numberFormat) throws java.text.ParseException- Parameters:
numberFormat- The format to use to process the token- Returns:
- the next token as a Number
- Throws:
java.text.ParseException
-
nextDouble
public double nextDouble() throws java.text.ParseException- Returns:
- the next token as a double
- Throws:
java.text.ParseException
-
nextDouble
public double nextDouble(java.text.NumberFormat numberFormat) throws java.text.ParseException- Parameters:
numberFormat- The format to use to process the token- Returns:
- the next token as a double
- Throws:
java.text.ParseException
-
nextInt
public int nextInt() throws java.text.ParseException- Returns:
- the next token as an int
- Throws:
java.text.ParseException
-
nextInt
public int nextInt(java.text.NumberFormat numberFormat) throws java.text.ParseException- Parameters:
numberFormat- The format to use to process the token- Returns:
- the next token as an int
- Throws:
java.text.ParseException
-
nextLong
public long nextLong() throws java.text.ParseException- Returns:
- the next token as a long
- Throws:
java.text.ParseException
-
nextLong
public long nextLong(java.text.NumberFormat numberFormat) throws java.text.ParseException- Parameters:
numberFormat- The format to use to process the token- Returns:
- the next token as a long
- Throws:
java.text.ParseException
-
nextByte
public byte nextByte() throws java.text.ParseException- Returns:
- the next token as a byte
- Throws:
java.text.ParseException
-
nextByte
public byte nextByte(java.text.NumberFormat numberFormat) throws java.text.ParseException- Parameters:
numberFormat- The format to use to process the token- Returns:
- the next token as a byte
- Throws:
java.text.ParseException
-
nextShort
public short nextShort() throws java.text.ParseException- Returns:
- the next token as a short
- Throws:
java.text.ParseException
-
nextShort
public short nextShort(java.text.NumberFormat numberFormat) throws java.text.ParseException- Parameters:
numberFormat- The format to use to process the token- Returns:
- the next token as a short
- Throws:
java.text.ParseException
-
nextFloat
public float nextFloat() throws java.text.ParseException- Returns:
- the next token as a float
- Throws:
java.text.ParseException
-
nextFloat
public float nextFloat(java.text.NumberFormat numberFormat) throws java.text.ParseException- Parameters:
numberFormat- The format to use to process the token- Returns:
- the next token as a float
- Throws:
java.text.ParseException
-
nextDate
public java.util.Date nextDate() throws java.text.ParseException- Returns:
- the next token as a Date
- Throws:
java.text.ParseException
-
nextDate
public java.util.Date nextDate(java.text.DateFormat dateFormat) throws java.text.ParseException- Parameters:
dateFormat- The format to use to process the token- Returns:
- the next token as a Date
- Throws:
java.text.ParseException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG