Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gov.lanl.Utility
Class CSVDB  view CSVDB download CSVDB.java

java.lang.Object
  extended bygov.lanl.Utility.CSVDB

public class CSVDB
extends java.lang.Object

Class to create persistent CSV database using Persistent Hashtables. Used to track changes in an external database to provide a list of only the changed rows.

Version:
$Id: CSVDB.java,v 1.7 2002/12/09 05:01:43 dwforslund Exp $

Field Summary
private static org.apache.log4j.Logger cat
           
private  JDBMRecordManager recman
           
private  JDBMHashtable rows
           
private  java.lang.String sqlReader
           
 
Constructor Summary
CSVDB(java.util.Properties props)
          Constructor with name of the database
 
Method Summary
 void addRow(java.lang.String id, java.lang.String row)
          Add a row of data with the key id
 boolean compare(java.lang.String id, java.lang.String row)
          Compare the row for the given id
 java.lang.String findRow(java.lang.String id)
          get the row corresponding to the key
 java.lang.String[] getElements()
          Dump the database
 java.lang.String getHead()
          get the head
 void insertHead(java.lang.String head)
          Insert the head labels
static void main(java.lang.String[] argv)
          code for reading and updating CSV Database
 java.lang.String[] match(java.lang.String[] ids, java.lang.String[] rows)
          return all non matching rows
 java.lang.String[] update(java.lang.String[] ids, java.util.ArrayList rows)
          update and return all non matching rows
 java.lang.String[] update(java.lang.String[] ids, java.lang.String[] rows)
          update and return all non matching rows
 boolean update(java.lang.String id, java.lang.String row)
          Update the row if it has changed or doesn't exist.
 java.util.ArrayList updateAndCompare(java.lang.String database, int key)
          Find the elements in target database that are different that the CSV database
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cat

private static org.apache.log4j.Logger cat

recman

private JDBMRecordManager recman

rows

private JDBMHashtable rows

sqlReader

private java.lang.String sqlReader
Constructor Detail

CSVDB

public CSVDB(java.util.Properties props)
Constructor with name of the database

Method Detail

getElements

public java.lang.String[] getElements()
Dump the database


updateAndCompare

public java.util.ArrayList updateAndCompare(java.lang.String database,
                                            int key)
Find the elements in target database that are different that the CSV database


addRow

public void addRow(java.lang.String id,
                   java.lang.String row)
            throws java.io.IOException
Add a row of data with the key id


findRow

public java.lang.String findRow(java.lang.String id)
                         throws java.io.IOException
get the row corresponding to the key


insertHead

public void insertHead(java.lang.String head)
                throws java.io.IOException
Insert the head labels


getHead

public java.lang.String getHead()
                         throws java.io.IOException
get the head


compare

public boolean compare(java.lang.String id,
                       java.lang.String row)
                throws java.io.IOException
Compare the row for the given id


update

public boolean update(java.lang.String id,
                      java.lang.String row)
               throws java.io.IOException
Update the row if it has changed or doesn't exist.


match

public java.lang.String[] match(java.lang.String[] ids,
                                java.lang.String[] rows)
                         throws java.io.IOException
return all non matching rows


update

public java.lang.String[] update(java.lang.String[] ids,
                                 java.lang.String[] rows)
                          throws java.io.IOException
update and return all non matching rows


update

public java.lang.String[] update(java.lang.String[] ids,
                                 java.util.ArrayList rows)
                          throws java.io.IOException
update and return all non matching rows


main

public static void main(java.lang.String[] argv)
code for reading and updating CSV Database