JPlate Tabular 0.2
Summary
Welcome to the JPlate Tabular
Project! This
subproject of JPlate provides tabular related functionality. Here
"tabular" refers to data organized into tables of records and
fields, where each has a fixed delimiter: for example, records
delimited by "new lines" and fields delimited by commas.
Please
note: this documentation is a "work
in progress"
and will be enhanced when time permits - it is an initial version and
much is missing
(unit test cases, good Java documentation, etc).
Parsers
There are three included parsers:
- Colon Delimited Values (CDV): fields separated by colons
and records by newlines.
- Comma Separated Values (CSV): fields separated by commas
and records by newlines.
- Tab Delimeted Values (TDV): fields separated by tabs and
records by new lines.
As a side note, CSV includes
two parsers - one strictly adheres to RFC 4180, while
the other is a more lax version similar to both the CDV and TDV
parsers.
Quick Start
This section illustrates how to quickly make use of the parsers
described above. However, remember that this is simply a
"quick start" and does not explain how to use the complete Tabular
library.
Classpath
To utilize the Tabular library, include all jar files found in the
release
lib directory as part of the classpath. For example, assume
Tabular
0.2 has been downloaded and installed to
/shared/jplate-tabular-0.2 on a Linux platform:
JPLATE_TABULAR_HOME=/shared/jplate-tabular-0.2
JPLATE_TABULAR_LIB_HOME=${JPLATE_TABULAR_HOME}/lib
JPLATE_TABULAR_CLASSPATH=${JPLATE_TABULAR_LIB_HOME}/commons-logging-1.1.jar
JPLATE_TABULAR_CLASSPATH=${JPLATE_TABULAR_LIB_HOME}/jplate-foundation-0.9.jar:${JPLATE_TABULAR_CLASSPATH}
JPLATE_TABULAR_CLASSPATH=${JPLATE_TABULAR_LIB_HOME}/jplate-tabular-0.2.jar:${JPLATE_TABULAR_CLASSPATH}
JPLATE_TABULAR_CLASSPATH=${JPLATE_TABULAR_LIB_HOME}/log4j-1.2.15.jar:${JPLATE_TABULAR_CLASSPATH}
CLASSPATH=${JPLATE_TABULAR_CLASSPATH}:${CLASSPATH}
There are a set of utility
classes that make use of default implentations to create
tables/lists from files, input streams, readers and strings. By
examining the source code for these classes,
one can extrapolate how to extend or use the rest of the project.
Examples
Consider the following examples:
- Comma separated values contained in a file to be consumed as a
java.util.List:
import java.io.File;
import java.util.List;
import org.jplate.tabular.util.JPlateCsvUtil;
...
final File csvFile = new File ( "SomeFile.csv" );
final List <List <String>>
JPlateCsvUtil.getAsList ( csvFile );
...
- Tabbed delimited values streamed from a socket to be consumed as
an org.jplate.tabular.TableIfc:
import java.net.Socket;
import org.jplate.tabular.TableIfc;
import org.jplate.tabular.util.TdvUtil;
...
final Socket tdvSocket = // Create socket in some
fashion...
final TableIfc table = TdvUtil.getAsTable ( tdvSocket.getInputStream () );
...
Please look to individual classes for
more specific information.
Building (if desired)
If you wish to build Tabular from source, you will need access
to a Subversion client and Ant 1.7.0+
(preferably 1.7.1
to simplify using the included libraries - please see the documentation
on Environment
1.1 for more information).
Check out the source
Create a directory for checkout, change to this directory and execute:
svn co
https://jplate.svn.sourceforge.net/svnroot/jplate/trunk/environment
svn co
https://jplate.svn.sourceforge.net/svnroot/jplate/trunk/tabular
You will note two directories are created: environment
and tabular.
Build the source
Build the source - change directories to the aforementioned tabular
directory and execute the command:
ant
Results
After building, you should find a tabular/assembly/release
directory containing various things such as a jar file
(for example Tabular 0.2 release produces jplate-tabular-0.2.jar)
and other files normally associated with a Tabular release.
Dependencies
Tabular has dependencies upon:
IRC Channel
There is an
IRC channel on
irc.freenode.net under the channel name #JPlate.
The Project Manager
is usually there most days under the name Flossy. He is more than
happy to help or answer questions you may have.
Related Links
Tabular related links follow: