net.sf.cpsolver.ifs.util
Class CSVFile

java.lang.Object
  extended by net.sf.cpsolver.ifs.util.CSVFile
All Implemented Interfaces:
Serializable

public class CSVFile
extends Object
implements Serializable

Support for CSV (comma separated) text files.

Version:
IFS 1.1 (Iterative Forward Search)
Copyright (C) 2006 Tomáš Müller
muller@unitime.org
Lazenska 391, 76314 Zlin, Czech Republic

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
See Also:
Serialized Form

Nested Class Summary
static class CSVFile.CSVField
          Representation of a field of a CSV file
static interface CSVFile.CSVFilter
          An interface for filtering lines of a CSV file
 class CSVFile.CSVLine
          Representation of a line of a CSV file
 
Constructor Summary
CSVFile()
           
CSVFile(File file)
           
CSVFile(File file, String separator)
           
CSVFile(File file, String separator, String quotationMark)
           
 
Method Summary
 CSVFile.CSVLine addLine()
           
 CSVFile.CSVLine addLine(Collection fields)
           
 CSVFile.CSVLine addLine(CSVFile.CSVField[] fields)
           
 void addLine(CSVFile.CSVLine line)
           
 void addLine(String line)
           
static CSVFile.CSVFilter and(CSVFile.CSVFilter first, CSVFile.CSVFilter second)
           
static CSVFile.CSVFilter eq(String name, String value)
           
 Vector filter(CSVFile.CSVFilter filter)
           
 CSVFile.CSVLine getHeader()
           
 CSVFile.CSVLine getLine(int idx)
           
 Vector getLines()
           
 String getQuotationMark()
           
 String getSeparator()
           
 boolean isEmpty()
           
 Enumeration lines()
           
 void load(File file)
           
static CSVFile.CSVFilter not(CSVFile.CSVFilter filter)
           
static CSVFile.CSVFilter or(CSVFile.CSVFilter first, CSVFile.CSVFilter second)
           
 void save(File file)
           
 CSVFile.CSVLine setHeader(Collection fields)
           
 CSVFile.CSVLine setHeader(CSVFile.CSVField[] fields)
           
 void setHeader(CSVFile.CSVLine header)
           
 void setQuotationMark(String quotationMark)
           
 void setSeparator(String separator)
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVFile

public CSVFile()

CSVFile

public CSVFile(File file)
        throws IOException
Throws:
IOException

CSVFile

public CSVFile(File file,
               String separator)
        throws IOException
Throws:
IOException

CSVFile

public CSVFile(File file,
               String separator,
               String quotationMark)
        throws IOException
Throws:
IOException
Method Detail

setSeparator

public void setSeparator(String separator)

getSeparator

public String getSeparator()

setQuotationMark

public void setQuotationMark(String quotationMark)

getQuotationMark

public String getQuotationMark()

load

public void load(File file)
          throws IOException
Throws:
IOException

save

public void save(File file)
          throws IOException
Throws:
IOException

getHeader

public CSVFile.CSVLine getHeader()

setHeader

public void setHeader(CSVFile.CSVLine header)

getLines

public Vector getLines()

size

public int size()

isEmpty

public boolean isEmpty()

getLine

public CSVFile.CSVLine getLine(int idx)

lines

public Enumeration lines()

addLine

public void addLine(CSVFile.CSVLine line)

addLine

public void addLine(String line)

filter

public Vector filter(CSVFile.CSVFilter filter)

addLine

public CSVFile.CSVLine addLine()

addLine

public CSVFile.CSVLine addLine(CSVFile.CSVField[] fields)

addLine

public CSVFile.CSVLine addLine(Collection fields)

setHeader

public CSVFile.CSVLine setHeader(CSVFile.CSVField[] fields)

setHeader

public CSVFile.CSVLine setHeader(Collection fields)

eq

public static CSVFile.CSVFilter eq(String name,
                                   String value)

and

public static CSVFile.CSVFilter and(CSVFile.CSVFilter first,
                                    CSVFile.CSVFilter second)

or

public static CSVFile.CSVFilter or(CSVFile.CSVFilter first,
                                   CSVFile.CSVFilter second)

not

public static CSVFile.CSVFilter not(CSVFile.CSVFilter filter)