gov.lanl.Utility
Class CSVDB

java.lang.Object
  |
  +--gov.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 $
Author:
$Author: dwforslund $

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
 

Constructor Detail

CSVDB

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

Parameters:
props -
Method Detail

getElements

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

Returns:

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

Parameters:
database -
Returns:

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

Parameters:
id - is the key
row - is the row
Throws:
java.io.IOException

findRow

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

Parameters:
id -
Returns:
Throws:
java.io.IOException

insertHead

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

Parameters:
head -
Throws:
java.io.IOException

getHead

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

Returns:
Throws:
java.io.IOException

compare

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

Parameters:
id -
row -
Returns:
Throws:
java.io.IOException

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.

Parameters:
id -
row -
Returns:
true if the row was updated
Throws:
java.io.IOException

match

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

Parameters:
ids -
rows -
Returns:
Throws:
java.io.IOException

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

Parameters:
ids -
rows -
Returns:
Throws:
java.io.IOException

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

Parameters:
ids -
rows -
Returns:
Throws:
java.io.IOException

main

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

Parameters:
argv -


Copyright © 2000 Apache Software Foundation. All Rights Reserved.