org.tbee.csv
Class CSVStringParser

java.lang.Object
  extended by org.tbee.csv.CSVStringParser

public class CSVStringParser
extends Object

This class can split up a string based on CSV logic. It is used by FileParser to split up the individual lines.

Usage is simple:

// create the parser
CSVStringParser lCSVStringParser = new CSVStringParser();

// parse a string
lFields = lCSVStringParser.parse("test,test,test");

The field separator is per default a comma (,) but can be set prior to parsing. The parser recognizes empty fields (",,,") and returns an empty string. The separator can be escaped using the escaper (default escaper is '\', so '\,') and the escaper can be escaped also ('\\')

Version:
$Revision: 1.8 $
Author:
$Author: cvs $

Field Summary
static String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Constructor Summary
CSVStringParser()
           
 
Method Summary
 char getEscaper()
           
 char getQuote()
           
 char getSeparator()
           
 String[] parse(String pCSVString)
          Parse the string and return the fields
 void setEscaper(char pEscaper)
           
 void setQuote(char pQuote)
           
 void setSeparator(char pSeparator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCECODE_VERSION

public static final String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values
Constructor Detail

CSVStringParser

public CSVStringParser()
Method Detail

setSeparator

public void setSeparator(char pSeparator)

getSeparator

public char getSeparator()

setEscaper

public void setEscaper(char pEscaper)

getEscaper

public char getEscaper()

setQuote

public void setQuote(char pQuote)

getQuote

public char getQuote()

parse

public String[] parse(String pCSVString)
Parse the string and return the fields



Copyright © 2011 KnowledgePlaza. All Rights Reserved.