JPlate 0.1

"How To"

How To

This section describes how to use portions of JPlate.

Include Jars

To utilize the JPlate include all jar files found in the release lib directory as part of the classpath.  For example, assume JPlate 0.1 has been downloaded and installed to /shared/jplate-0.1 on a Linux platform:

JPLATE_HOME=/shared/jplate-0.1
JPLATE_LIB_HOME=
${JPLATE_HOME}/lib

JPLATE_CLASSPATH=${JPLATE_JAR_FILE}
JPLATE_CLASSPATH=${JPLATE_CLASSPATH}:${JPLATE_LIB_HOME}/avalon-framework.jar
JPLATE_CLASSPATH=${JPLATE_CLASSPATH}:${JPLATE_LIB_HOME}/commons-logging.jar
JPLATE_CLASSPATH=${JPLATE_CLASSPATH}:${JPLATE_LIB_HOME}/jplate-0.1.jar
JPLATE_CLASSPATH=
${JPLATE_CLASSPATH}${JPLATE_LIB_HOME}/log4.jar
JPLATE_CLASSPATH=${JPLATE_CLASSPATH}${JPLATE_LIB_HOME}/logkit.jar
JPLATE_CLASSPATH=${JPLATE_CLASSPATH}${JPLATE_LIB_HOME}/servlet-api.jar

CLASSPATH=
${JPLATE_CLASSPATH}:${CLASSPATH}

Building (if desired)

If you wish to build JPlate from source, either checkout the source (from the Subversion) or download the source.  You will also need Ant 1.7.1.

Checkout the source

Latest Source

svn co https://jplate.svn.sourceforge.net/svnroot/jplate/trunk
cd trunk

This release

svn co https://jplate.svn.sourceforge.net/svnroot/jplate/branches/jplate-0.1
cd
jplate-0.1

Download the source

Simply download the source and unpack it (either bunzip/tar xvf, gunzip/tar xvf or unzip).  Once unpacked, change directories to the unpacked directory.

Build the source

Once you have a copy of the code (and have Ant 1.7.1 installed properly), execute the following command:

ant

Results

After building, you should find an assembly/release directory containing various things such as a jar file (for example the JPlate 0.1 release produces jplate-0.1.jar) and other files normally associated with a JPlate release.

Examples

This section illustrates how to quickly make use of JPlate.  However, remember that this is simply a "quick start" and does not explain how to use the complete library.  Please look to individual classes for more specific information on class utilization.

Foundation

Foundation provides "core" Java functionality that is utilized elsewhere in JPlate:  KVP and Tabular (listed below).  This section is a "work in progress" - examples will be added at a later date.

KVP

KVP provides key/value pair functionality - much like java.util.Properties including a parser.  There is a utility class that makes use of default implentations to create list/maps from files, input streams, readers and strings.  By examining the source code for this class, one can extrapolate how to extend or use the rest of the project. import java.io.File;

import java.util.List;

import org.jplate.kvp.KvpIfc;


import org.jplate.kvp.util.KvpUtil;

...

    final File kvpFile = new File ( "SomeFile.kvp" );

    final List <KvpIfc> KvpUtil.getAsList (
kvpFile );

...

import java.net.Socket;

import java.util.Map;

import org.jplate.kvp.KvpIfc;


import org.jplate.kvp.util.KvpUtil;


...

    final Socket kvpSocket = // Create socket in some fashion...

    final Map <String, String> KvpUtil.getAsMap (
kvpSocket.getInputStream () );

...

Tabular

Tabular 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.

Parsers

There are three included parsers:

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.
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 );

...

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 () );

...