xBaseJ
Class DBF

java.lang.Object
  |
  +--xBaseJ.DBF

public class DBF
extends java.lang.Object


Field Summary
static byte DBASEIII
           
static byte DBASEIV
           
static char READ_ONLY
           
 
Constructor Summary
DBF(java.lang.String DBFname)
          creates an DBF object and opens existing database file in read/write mode
DBF(java.lang.String DBFname, boolean destroy)
          creates a new DBF file or replaces an existing database file, w/o format assumes dbaseiii file format
DBF(java.lang.String DBFname, char readOnly)
          creates an DBF object and opens existing database file in readonly mode
DBF(java.lang.String DBFname, int format, boolean destroy)
          creates a new DBF file or replaces an existing database file
 
Method Summary
 void addField(Field aField)
          adds a new Field to a database
 void addField(Field[] aField)
          adds an array of new Fields to a database
 void changeField(Field oldField, Field newField)
          changes a Field in a database NOT FULLY IMPLEMENTED
 void close()
          closes the database
 Index createIndex(java.lang.String filename, java.lang.String index, boolean unique)
          creates a new Index as a NDX file, assumes NDX file does not exist
 Index createIndex(java.lang.String filename, java.lang.String index, boolean destroy, boolean unique)
          creates a new Index as a NDX file
 Index createTag(java.lang.String tagname, java.lang.String tagIndex, boolean unique)
          creates a tag in the MDX file
 void delete()
          marks the current records as deleted
 boolean deleted()
          returns true if record is marked for deletion
 void dropField(Field aField)
          removes a Field from a database NOT FULLY IMPLEMENTED
 boolean find(java.lang.String keyString)
          used to find a record with an equal or greater string value when done the record pointer and field contents will be changed
 void findNext()
          used to get the next record in the index list when done the record pointer and field contents will be changed
 void findPrev()
          used to get the previous record in the index list when done the record pointer and field contents will be changed
 int fldcount()
          Deprecated. use getFieldCount
 int getCurrentRecordNumber()
          returns the current record number
 Field getField(int i)
          returns a Field object by its relative position
 Field getField(java.lang.String name)
          returns a Field object by its name in the database
 int getFieldCount()
          returns the number of fields in a database
 Index getIndex(int indexPosition)
          gets an Index object associated with the database.
 int getIndexCount()
          returns the number of known index files and tags
 java.lang.String getName()
          returns the full path name of the database
 int getRecordCount()
          returns the number of records in a database
 int getVersion()
           
 void gotoRecord(int recno)
          used to read a record at a particular place in the database when done the record pointer and field contents will be changed
 void pack()
          packs a DBF by removing deleted records and memo fields
 void read()
          used to read the next record, after the current record pointer, in the database when done the record pointer and field contents will be changed
 void readPrev()
          used to read the previous record, before the current record pointer, in the database when done the record pointer and field contents will be changed
 int reccount()
          Deprecated. use getRecordCount
 int recno()
          Deprecated. use getCurrentRecordNumber
 void setFieldEvaluation(java.lang.String evalString)
           
 void startBottom()
          used to position record pointer at the last record or index in the database when done the record pointer will be changed.
 void startTop()
          used to position record pointer at the first record or index in the database when done the record pointer will be changed.
 void undelete()
          marks the current records as not deleted
 void update()
          updates the record at the current position
 Index useIndex(Index ndx)
          used to indicate the primary Index
 Index useIndex(java.lang.String filename)
          opens an Index file associated with the database.
 Index useIndex(java.lang.String filename, java.lang.String ID)
          opens an Index file associated with the database
 Index useIndexByID(java.lang.String ID)
          used to indicate the primary Index
 Index useTag(java.lang.String tagname)
          associates all Index operations with an existing tag
 Index useTag(java.lang.String tagname, java.lang.String ID)
          associates all Index operations with an existing tag
 java.lang.String version()
           
 void write()
          used to write a new record in the database when done the record pointer is at the end of the database
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DBASEIII

public static final byte DBASEIII

DBASEIV

public static final byte DBASEIV

READ_ONLY

public static final char READ_ONLY
Constructor Detail

DBF

public DBF(java.lang.String DBFname,
           boolean destroy)
    throws xBaseJException,
           java.io.IOException,
           java.lang.SecurityException
creates a new DBF file or replaces an existing database file, w/o format assumes dbaseiii file format

The unregistered package limitted to 5 open dbf's.

Parameters:
DBFname - a new or existing database file, can be full or partial pathname
format - use class constants DBASEIII or DBASEIV
Throws:
xBaseJException - File does exist and told not to destroy it.
xBaseJException - Told to destroy but operating system can not destroy
java.lang.SecurityException - Java error caused by called methods, most likely trying to create on a remote system

DBF

public DBF(java.lang.String DBFname,
           int format,
           boolean destroy)
    throws xBaseJException,
           java.io.IOException,
           java.lang.SecurityException
creates a new DBF file or replaces an existing database file

The unregistered package limitted to 5 open dbf's.

Parameters:
DBFname - a new or existing database file, can be full or partial pathname
format - use class constants DBASEIII or DBASEIV
destroy - permission to destroy an existing database file
Throws:
xBaseJException - File does exist and told not to destroy it.
xBaseJException - Told to destroy but operating system can not destroy
java.lang.SecurityException - Java error caused by called methods, most likely trying to create on a remote system

DBF

public DBF(java.lang.String DBFname,
           char readOnly)
    throws xBaseJException,
           java.io.IOException
creates an DBF object and opens existing database file in readonly mode

The unregistered package limitted to 5 open dbf's.

Parameters:
DBFname - an existing database file, can be full or partial pathname
Throws:
xBaseJException - Can not find database
xBaseJException - database not dbaseIII format

DBF

public DBF(java.lang.String DBFname)
    throws xBaseJException,
           java.io.IOException
creates an DBF object and opens existing database file in read/write mode

The unregistered package limitted to 5 open dbf's.

Parameters:
DBFname - an existing database file, can be full or partial pathname
Throws:
xBaseJException - Can not find database
xBaseJException - database not dbaseIII format
Method Detail

version

public java.lang.String version()

addField

public void addField(Field aField)
              throws xBaseJException,
                     java.io.IOException
adds a new Field to a database
Parameters:
aField - a predefined Field object
Throws:
xBaseJException - xBaseJ error caused by called methods
See Also:
Field

addField

public void addField(Field[] aField)
              throws xBaseJException,
                     java.io.IOException
adds an array of new Fields to a database
Parameters:
aField - an array of predefined Field object
Throws:
xBaseJException - passed an empty array or other error
See Also:
Field

dropField

public void dropField(Field aField)
               throws xBaseJException,
                      java.io.IOException
removes a Field from a database NOT FULLY IMPLEMENTED
Parameters:
aField - a field in the database
Throws:
xBaseJException - Field is not part of the database
See Also:
Field

changeField

public void changeField(Field oldField,
                        Field newField)
                 throws xBaseJException,
                        java.io.IOException
changes a Field in a database NOT FULLY IMPLEMENTED
Parameters:
aField - a Field object
Throws:
xBaseJException - xBaseJ error caused by called methods
See Also:
Field

fldcount

public int fldcount()
Deprecated. use getFieldCount

returns the number of fields in a database

reccount

public int reccount()
Deprecated. use getRecordCount

returns the number of records in a database

recno

public int recno()
Deprecated. use getCurrentRecordNumber

returns the current record number

getFieldCount

public int getFieldCount()
returns the number of fields in a database

getRecordCount

public int getRecordCount()
returns the number of records in a database

getCurrentRecordNumber

public int getCurrentRecordNumber()
returns the current record number

getIndexCount

public int getIndexCount()
returns the number of known index files and tags

getIndex

public Index getIndex(int indexPosition)
               throws xBaseJException
gets an Index object associated with the database. This index does not become the primary index. Written for the makeDBFBean application. Position is relative to 1.
Parameters:
int - index position
Throws:
xBaseJException - index value incorrect

useIndex

public Index useIndex(java.lang.String filename)
               throws xBaseJException,
                      java.io.IOException
opens an Index file associated with the database. This index becomes the primary index used in subsequent find methods.
Parameters:
filename - an existing ndx file(can be full or partial pathname) or mdx tag
Throws:
xBaseJException - xBaseJ Fields defined in index do not match fields in database

useIndex

public Index useIndex(java.lang.String filename,
                      java.lang.String ID)
               throws xBaseJException,
                      java.io.IOException
opens an Index file associated with the database
Parameters:
filename - an existing Index file, can be full or partial pathname
ID - a unique id to define Index at run-time.
Throws:
xBaseJException - xBaseJ Fields defined in Index do not match Fields in database

useIndex

public Index useIndex(Index ndx)
               throws xBaseJException,
                      java.io.IOException
used to indicate the primary Index
Parameters:
Index - a Index object
Throws:
xBaseJException - xBaseJ Index not opened or not part of the database

useIndexByID

public Index useIndexByID(java.lang.String ID)
                   throws xBaseJException
used to indicate the primary Index
Parameters:
Index - a string id
Throws:
xBaseJException - xBaseJ Index not opened or not part of the database
See Also:
useIndex(String,String)

useTag

public Index useTag(java.lang.String tagname)
             throws xBaseJException
associates all Index operations with an existing tag
Parameters:
tagname - an existing tag name in the production MDX file
Throws:
xBaseJException - no MDX file tagname not found

useTag

public Index useTag(java.lang.String tagname,
                    java.lang.String ID)
             throws xBaseJException,
                    java.io.IOException
associates all Index operations with an existing tag
Parameters:
tagname - an existing tag name in the production MDX file
ID - a unique id to define Index at run-time.
Throws:
xBaseJException - no MDX file tagname not found

createIndex

public Index createIndex(java.lang.String filename,
                         java.lang.String index,
                         boolean unique)
                  throws xBaseJException,
                         java.io.IOException
creates a new Index as a NDX file, assumes NDX file does not exist
Parameters:
filename - a new Index file name
index - string identifying Fields used in Index
unique - boolean to indicate if the key is always unique
Throws:
xBaseJException - NDX file already exists

createIndex

public Index createIndex(java.lang.String filename,
                         java.lang.String index,
                         boolean destroy,
                         boolean unique)
                  throws xBaseJException,
                         java.io.IOException
creates a new Index as a NDX file
Parameters:
filename - a new Index file name
index - string identifying Fields used in Index
destroy - permission to destory NDX if file exists
unique - boolean to indicate if the key is always unique
Throws:
xBaseJException - NDX file already exists

createTag

public Index createTag(java.lang.String tagname,
                       java.lang.String tagIndex,
                       boolean unique)
                throws xBaseJException,
                       java.io.IOException
creates a tag in the MDX file
Parameters:
tagname - a non-existing tag name in the production MDX file
tagIndex - string identifying Fields used in Index
unique - boolean to indicate if the key is always unique
Throws:
xBaseJException - no MDX file tagname already exists

find

public boolean find(java.lang.String keyString)
             throws xBaseJException,
                    java.io.IOException
used to find a record with an equal or greater string value when done the record pointer and field contents will be changed
Parameters:
keyString - a search string
Throws:
xBaseJException - xBaseJ no Indexs opened with database

findNext

public void findNext()
              throws xBaseJException,
                     java.io.IOException
used to get the next record in the index list when done the record pointer and field contents will be changed
Throws:
xBaseJException - xBaseJ Index not opened or not part of the database eof - end of file

findPrev

public void findPrev()
              throws xBaseJException,
                     java.io.IOException
used to get the previous record in the index list when done the record pointer and field contents will be changed
Throws:
xBaseJException - xBaseJ Index not opened or not part of the database tof - top of file

read

public void read()
          throws xBaseJException,
                 java.io.IOException
used to read the next record, after the current record pointer, in the database when done the record pointer and field contents will be changed
Throws:
xBaseJException - usually the end of file condition

readPrev

public void readPrev()
              throws xBaseJException,
                     java.io.IOException
used to read the previous record, before the current record pointer, in the database when done the record pointer and field contents will be changed
Throws:
xBaseJException - usually the top of file condition

gotoRecord

public void gotoRecord(int recno)
                throws xBaseJException,
                       java.io.IOException
used to read a record at a particular place in the database when done the record pointer and field contents will be changed
Parameters:
recno - the relative position of the record to read
Throws:
xBaseJException - passed an negative number, 0 or value greater than the number of records in database

startTop

public void startTop()
              throws xBaseJException,
                     java.io.IOException
used to position record pointer at the first record or index in the database when done the record pointer will be changed. NO RECORD IS READ. Your program should follow this with either a read (for non-index reads) or findNext (for index processing)
Throws:
xBaseJException - most likely no records in database

startBottom

public void startBottom()
                 throws xBaseJException,
                        java.io.IOException
used to position record pointer at the last record or index in the database when done the record pointer will be changed. NO RECORD IS READ. Your program should follow this with either a read (for non-index reads) or findPrev (for index processing)
Throws:
xBaseJException - most likely no records in database

write

public void write()
           throws xBaseJException,
                  java.io.IOException
used to write a new record in the database when done the record pointer is at the end of the database
Throws:
xBaseJException - any one of several errors

update

public void update()
            throws xBaseJException,
                   java.io.IOException
updates the record at the current position
Throws:
xBaseJException - any one of several errors

delete

public void delete()
            throws java.io.IOException,
                   xBaseJException
marks the current records as deleted
Throws:
xBaseJException - usually occurs when no record has been read

undelete

public void undelete()
              throws java.io.IOException,
                     xBaseJException
marks the current records as not deleted
Throws:
xBaseJException - usually occurs when no record has been read.

close

public void close()
           throws java.io.IOException
closes the database

getField

public Field getField(int i)
               throws java.lang.ArrayIndexOutOfBoundsException,
                      xBaseJException
returns a Field object by its relative position
Parameters:
i - Field number
Throws:
xBaseJException - usually occurs when Field number is less than 1 or greater than the number of fields

getField

public Field getField(java.lang.String name)
               throws xBaseJException,
                      java.lang.ArrayIndexOutOfBoundsException
returns a Field object by its name in the database
Parameters:
name - Field name
Throws:
xBaseJException - Field name is not correct

getName

public java.lang.String getName()
returns the full path name of the database

deleted

public boolean deleted()
returns true if record is marked for deletion

pack

public void pack()
          throws xBaseJException,
                 java.io.IOException,
                 java.lang.SecurityException,
                 java.lang.CloneNotSupportedException
packs a DBF by removing deleted records and memo fields
Throws:
xBaseJException - File does exist and told not to destroy it.
xBaseJException - Told to destroy but operating system can not destroy
java.lang.CloneNotSupportedException - Java error caused by called methods

setFieldEvaluation

public void setFieldEvaluation(java.lang.String evalString)
                        throws xBaseJException

getVersion

public int getVersion()