org.xBaseJ
Class DBF

java.lang.Object
  extended byorg.xBaseJ.DBF

public class DBF
extends Object


Field Summary
 java.nio.ByteBuffer buffer
           
 java.nio.channels.FileChannel channel
           
static byte DBASEIII
           
static byte DBASEIII_WITH_MEMO
           
static byte DBASEIV
           
static byte DBASEIV_WITH_MEMO
           
static byte DELETED
           
static String encodedType
           
 RandomAccessFile file
           
 java.nio.channels.FileLock filelock
           
 long fileLockWait
           
static byte FOXPRO_WITH_MEMO
           
 MDXFile MDXfile
           
static byte NOTDELETED
           
static char READ_ONLY
           
 boolean readonly
           
 java.nio.channels.FileLock recordlock
           
 boolean useSharedLocks
           
static String xBaseJVersion
           
 
Constructor Summary
DBF(String DBFname)
          creates an DBF object and opens existing database file in read/write mode.
DBF(String DBFname, boolean destroy)
          creates a new DBF file or replaces an existing database file, w/o format assumes dbaseiii file format.
DBF(String DBFname, boolean destroy, String inEncodeType)
          creates a new DBF file or replaces an existing database file, w/o format assumes dbaseiii file format.
DBF(String DBFname, char readOnly)
          creates an DBF object and opens existing database file in readonly mode.
DBF(String DBFname, char readOnly, String inEncodeType)
          creates an DBF object and opens existing database file in readonly mode.
DBF(String DBFname, int format, boolean destroy)
          creates a new DBF file or replaces an existing database file.
DBF(String DBFname, int format, boolean destroy, String inEncodeType)
          creates a new DBF file or replaces an existing database file.
DBF(String DBFname, String inEncodeType)
          creates an DBF object and opens existing database file in read/write mode.
 
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(String filename, String index, boolean unique)
          creates a new Index as a NDX file, assumes NDX file does not exist.
 Index createIndex(String filename, String index, boolean destroy, boolean unique)
          creates a new Index as a NDX file.
 Index createTag(String tagname, 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
 void finalize()
           
 boolean find(String keyString)
          used to find a record with an equal or greater string value.
 boolean find(String keyString, boolean lock)
          used to find a record with an equal or greater string value.
 boolean find(String keyString, int recno)
          used to find a record with an equal and at the particular record.
 boolean find(String keyString, int recno, boolean lock)
          used to find a record with an equal and at the particular record.
 boolean findExact(String keyString)
          used to find a record with an equal string value.
 boolean findExact(String keyString, boolean lock)
          used to find a record with an equal string value.
 void findNext()
          used to get the next record in the index list.
 void findNext(boolean lock)
          used to get the next record in the index list.
 void findPrev()
          used to get the previous record in the index list.
 void findPrev(boolean lock)
          used to get the previous record in the index list.
 int getCurrentRecordNumber()
          returns the current record number
static String getEncodingType()
          gets the character encoding string value.
 Field getField(int i)
          returns a Field object by its relative position.
 Field getField(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
 String getName()
          returns the full path name of the database
 int getRecordCount()
          returns the number of records in a database
 int getVersion()
          returns the dbase version field.
 void getXML(PrintWriter pw)
          generates an xml string representation using xbase.dtd
 File getXML(String inFileName)
          generates an xml string representation using xbase.dtd
 void gotoRecord(int recno)
          used to read a record at a particular place in the database.
 void gotoRecord(int recno, boolean lock)
          used to read a record at a particular place in the database.
 void lock()
          locks the entire database
will try 5 times within the fileLockTimeOut specified in org.xBaseJ.property fileLockTimeOut, default 5000 milliseconds (5 seconds)
 void lockRecord()
          locks the current record, exclusively
will try 5 times within the fileLockTimeOut specified in org.xBaseJ.property fileLockTimeOut, default 5000 milliseconds (5 seconds)
 void lockRecord(int recno)
          locks a particular record, exclusively
will try 5 times within the fileLockTimeOut specified in org.xBaseJ.property fileLockTimeOut, default 5000 milliseconds (5 seconds)
 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.
 void read(boolean lock)
          used to read the next record, after the current record pointer, in the database.
 void readPrev()
          used to read the previous record, before the current record pointer, in the database.
 void readPrev(boolean lock)
          used to read the previous record, before the current record pointer, in the database.
 void renameTo(String newname)
           
static void setEncodingType(String inType)
          sets the character encoding variable.
 void setFileLockWait(long inLongWait)
          sets the filelockwait timeout value in milliseconds
defaults to 5000 milliseconds
if negative value will not be set
 void setVersion(int b)
           
 void startBottom()
          used to position record pointer at the last record or index in the database.
 void startTop()
          used to position record pointer at the first record or index in the database.
 void undelete()
          marks the current records as not deleted.
 void unlock()
          unlocks the entire database
 void unlockRecord()
          unlocks the current locked recorfd
 void update_dbhead()
           
 void update()
          updates the record at the current position.
 void update(boolean lock)
          updates the record at the current position.
 Index useIndex(Index ndx)
          used to indicate the primary Index
 Index useIndex(String filename)
          opens an Index file associated with the database.
 Index useIndex(String filename, String ID)
          opens an Index file associated with the database
 Index useIndexByID(String ID)
          used to indicate the primary Index.
 Index useTag(String tagname)
          associates all Index operations with an existing tag.
 Index useTag(String tagname, String ID)
          associates all Index operations with an existing tag.
static String version()
           
 void write()
          used to write a new record in the database.
 void write(boolean lock)
          used to write a new record in the database.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

public RandomAccessFile file

MDXfile

public MDXFile MDXfile

DBASEIII

public static final byte DBASEIII
See Also:
Constant Field Values

DBASEIV

public static final byte DBASEIV
See Also:
Constant Field Values

DBASEIII_WITH_MEMO

public static final byte DBASEIII_WITH_MEMO
See Also:
Constant Field Values

DBASEIV_WITH_MEMO

public static final byte DBASEIV_WITH_MEMO
See Also:
Constant Field Values

FOXPRO_WITH_MEMO

public static final byte FOXPRO_WITH_MEMO
See Also:
Constant Field Values

NOTDELETED

public static final byte NOTDELETED
See Also:
Constant Field Values

DELETED

public static final byte DELETED
See Also:
Constant Field Values

READ_ONLY

public static final char READ_ONLY
See Also:
Constant Field Values

readonly

public boolean readonly

xBaseJVersion

public static final String xBaseJVersion
See Also:
Constant Field Values

encodedType

public static String encodedType

channel

public java.nio.channels.FileChannel channel

filelock

public java.nio.channels.FileLock filelock

recordlock

public java.nio.channels.FileLock recordlock

fileLockWait

public long fileLockWait

buffer

public java.nio.ByteBuffer buffer

useSharedLocks

public boolean useSharedLocks
Constructor Detail

DBF

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

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

DBF

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

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
IOException - Java error caused by called methods
SecurityException - Java error caused by called methods, most likely trying to create on a remote system

DBF

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

Parameters:
DBFname - an existing database file, can be full or partial pathname
readOnly - see DBF.READ_ONLY
Throws:
xBaseJException - Can not find database
xBaseJException - database not dbaseIII format
IOException - Java error caused by called methods

DBF

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

Parameters:
DBFname - an existing database file, can be full or partial pathname
Throws:
xBaseJException - Can not find database
xBaseJException - database not dbaseIII format
IOException - Java error caused by called methods

DBF

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

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

DBF

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

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
inEncodeType - file encoding value
Throws:
xBaseJException - File does exist and told not to destroy it.
xBaseJException - Told to destroy but operating system can not destroy
IOException - Java error caused by called methods
SecurityException - Java error caused by called methods, most likely trying to create on a remote system

DBF

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

Parameters:
DBFname - an existing database file, can be full or partial pathname
readOnly - see DBF.READ_ONLY
inEncodeType - file encoding value
Throws:
xBaseJException - Can not find database
xBaseJException - database not dbaseIII format
IOException - Java error caused by called methods

DBF

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

Parameters:
DBFname - an existing database file, can be full or partial pathname
inEncodeType - file encoding value
Throws:
xBaseJException - Can not find database
xBaseJException - database not dbaseIII format
IOException - Java error caused by called methods
Method Detail

version

public static final String version()

finalize

public void finalize()
              throws Throwable
Throws:
Throwable

addField

public void addField(Field aField)
              throws xBaseJException,
                     IOException
adds a new Field to a database

Parameters:
aField - a predefined Field object
Throws:
xBaseJException - org.xBaseJ error caused by called methods
IOException - Java error caused by called methods
See Also:
Field

addField

public void addField(Field[] aField)
              throws xBaseJException,
                     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
IOException - Java error caused by called methods
See Also:
Field

renameTo

public void renameTo(String newname)
              throws IOException
Throws:
IOException

setFileLockWait

public void setFileLockWait(long inLongWait)
sets the filelockwait timeout value in milliseconds
defaults to 5000 milliseconds
if negative value will not be set

Parameters:
inLongWait - long milliseconds

lock

public void lock()
          throws IOException,
                 xBaseJException
locks the entire database
will try 5 times within the fileLockTimeOut specified in org.xBaseJ.property fileLockTimeOut, default 5000 milliseconds (5 seconds)

Throws:
IOException - - related to java.nio.channels and filelocks
xBaseJException - - file lock wait timed out,
Since:
2.1

lockRecord

public void lockRecord()
                throws IOException,
                       xBaseJException
locks the current record, exclusively
will try 5 times within the fileLockTimeOut specified in org.xBaseJ.property fileLockTimeOut, default 5000 milliseconds (5 seconds)

Throws:
IOException - - related to java.nio.channels and filelocks
xBaseJException - - file lock wait timed out,
Since:
2.1

lockRecord

public void lockRecord(int recno)
                throws IOException,
                       xBaseJException
locks a particular record, exclusively
will try 5 times within the fileLockTimeOut specified in org.xBaseJ.property fileLockTimeOut, default 5000 milliseconds (5 seconds)

Parameters:
recno - record # to be locked
Throws:
IOException - - related to java.nio.channels and filelocks
xBaseJException - - file lock wait timed out,

unlock

public void unlock()
            throws IOException
unlocks the entire database

Throws:
IOException - - related to java.nio.channels and filelocks
Since:
2.1

unlockRecord

public void unlockRecord()
                  throws IOException
unlocks the current locked recorfd

Throws:
IOException - - related to java.nio.channels and filelocks
Since:
2.1

dropField

public void dropField(Field aField)
               throws xBaseJException,
                      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
IOException - Java error caused by called methods
See Also:
Field

changeField

public void changeField(Field oldField,
                        Field newField)
                 throws xBaseJException,
                        IOException
changes a Field in a database NOT FULLY IMPLEMENTED

Parameters:
oldField - a Field object
newField - a Field object
Throws:
xBaseJException - org.xBaseJ error caused by called methods
IOException - Java error caused by called methods
See Also:
Field

getFieldCount

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


getRecordCount

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

Throws:
xBaseJException
IOException

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:
indexPosition -
Throws:
xBaseJException - index value incorrect

useIndex

public Index useIndex(String filename)
               throws xBaseJException,
                      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 - org.xBaseJ Fields defined in index do not match fields in database
IOException - Java error caused by called methods

useIndex

public Index useIndex(String filename,
                      String ID)
               throws xBaseJException,
                      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 - org.xBaseJ Fields defined in Index do not match Fields in database
IOException - Java error caused by called methods

useIndex

public Index useIndex(Index ndx)
               throws xBaseJException,
                      IOException
used to indicate the primary Index

Parameters:
ndx - an Index object
Throws:
xBaseJException - org.xBaseJ Index not opened or not part of the database
IOException - Java error caused by called methods

useIndexByID

public Index useIndexByID(String ID)
                   throws xBaseJException
used to indicate the primary Index.

Parameters:
ID - String index name
Throws:
xBaseJException - org.xBaseJ Index not opened or not part of the database
See Also:
useIndex(String,String)

useTag

public Index useTag(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(String tagname,
                    String ID)
             throws xBaseJException,
                    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
IOException - Java error caused by called methods

createIndex

public Index createIndex(String filename,
                         String index,
                         boolean unique)
                  throws xBaseJException,
                         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
IOException - Java error caused by called methods

createIndex

public Index createIndex(String filename,
                         String index,
                         boolean destroy,
                         boolean unique)
                  throws xBaseJException,
                         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
IOException - Java error caused by called methods

createTag

public Index createTag(String tagname,
                       String tagIndex,
                       boolean unique)
                throws xBaseJException,
                       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
IOException - Java error caused by called methods

find

public boolean find(String keyString,
                    boolean lock)
             throws xBaseJException,
                    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
lock - boolean lock record indicator
Returns:
boolean indicating if the record found contains the exact key
Throws:
xBaseJException - org.xBaseJ no Indexs opened with database
IOException - Java error caused by called methods

find

public boolean find(String keyString)
             throws xBaseJException,
                    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
Returns:
boolean indicating if the record found contains the exact key
Throws:
xBaseJException - org.xBaseJ no Indexs opened with database
IOException - Java error caused by called methods

find

public boolean find(String keyString,
                    int recno,
                    boolean lock)
             throws xBaseJException,
                    IOException
used to find a record with an equal and at the particular record. when done the record pointer and field contents will be changed.

Parameters:
keyString - a search string
recno - - int record number
lock - - boolean lock record indicator
Returns:
boolean indicating if the record found contains the exact key
Throws:
xBaseJException - org.xBaseJ Index not opened or not part of the database
IOException - Java error caused by called methods

find

public boolean find(String keyString,
                    int recno)
             throws xBaseJException,
                    IOException
used to find a record with an equal and at the particular record. when done the record pointer and field contents will be changed.

Parameters:
keyString - a search string
Returns:
boolean indicating if the record found contains the exact key
Throws:
xBaseJException - org.xBaseJ Index not opened or not part of the database
IOException - Java error caused by called methods

findExact

public boolean findExact(String keyString,
                         boolean lock)
                  throws xBaseJException,
                         IOException
used to find a record with an equal string value. when done the record pointer and field contents will be changed only if the exact key is found.

Parameters:
keyString - a search string
lock - - boolean lock record indiator
Returns:
boolean indicating if the record found contains the exact key
Throws:
xBaseJException - org.xBaseJ no Indexs opened with database
IOException - Java error caused by called methods

findExact

public boolean findExact(String keyString)
                  throws xBaseJException,
                         IOException
used to find a record with an equal string value. when done the record pointer and field contents will be changed only if the exact key is found.

Parameters:
keyString - a search string
Returns:
boolean indicating if the record found contains the exact key
Throws:
xBaseJException - org.xBaseJ no Indexs opened with database
IOException - Java error caused by called methods

findNext

public void findNext(boolean lock)
              throws xBaseJException,
                     IOException
used to get the next record in the index list. when done the record pointer and field contents will be changed.

Parameters:
lock - - boolean lock record indicator
Throws:
xBaseJException - org.xBaseJ Index not opened or not part of the database eof - end of file
IOException - Java error caused by called methods

findNext

public void findNext()
              throws xBaseJException,
                     IOException
used to get the next record in the index list. when done the record pointer and field contents will be changed

Throws:
xBaseJException - org.xBaseJ Index not opened or not part of the database eof - end of file
IOException - Java error caused by called methods

findPrev

public void findPrev(boolean lock)
              throws xBaseJException,
                     IOException
used to get the previous record in the index list. when done the record pointer and field contents will be changed.

Parameters:
lock - boolean lock record indicator
Throws:
xBaseJException - org.xBaseJ Index not opened or not part of the database tof - top of file
IOException - Java error caused by called methods

findPrev

public void findPrev()
              throws xBaseJException,
                     IOException
used to get the previous record in the index list. when done the record pointer and field contents will be changed.

Throws:
xBaseJException - org.xBaseJ Index not opened or not part of the database tof - top of file
IOException - Java error caused by called methods

read

public void read(boolean lock)
          throws xBaseJException,
                 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.

Parameters:
lock - - boolean lock record indicator
Throws:
xBaseJException - usually the end of file condition
IOException - Java error caused by called methods

read

public void read()
          throws xBaseJException,
                 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
IOException - Java error caused by called methods

readPrev

public void readPrev(boolean lock)
              throws xBaseJException,
                     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.

Parameters:
lock - - boolean lock record indicator
Throws:
xBaseJException - usually the top of file condition
IOException - Java error caused by called methods

readPrev

public void readPrev()
              throws xBaseJException,
                     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
IOException - Java error caused by called methods

gotoRecord

public void gotoRecord(int recno,
                       boolean lock)
                throws xBaseJException,
                       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
lock - - boolean lock record indicator
Throws:
xBaseJException - passed an negative number, 0 or value greater than the number of records in database
IOException - Java error caused by called methods

gotoRecord

public void gotoRecord(int recno)
                throws xBaseJException,
                       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
IOException - Java error caused by called methods

startTop

public void startTop()
              throws xBaseJException,
                     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)

Returns:
String starting index
Throws:
xBaseJException - most likely no records in database
IOException - Java error caused by called methods

startBottom

public void startBottom()
                 throws xBaseJException,
                        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)

Returns:
String terminal index
Throws:
xBaseJException - most likely no records in database
IOException - Java error caused by called methods

write

public void write(boolean lock)
           throws xBaseJException,
                  IOException
used to write a new record in the database. when done the record pointer is at the end of the database.

Parameters:
lock - - boolean lock indicator - locks the entire file during the write process and then unlocks the file.
Throws:
xBaseJException - any one of several errors
IOException - Java error caused by called methods

write

public void write()
           throws xBaseJException,
                  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
IOException - Java error caused by called methods

update

public void update(boolean lock)
            throws xBaseJException,
                   IOException
updates the record at the current position.

Parameters:
lock - - boolean lock indicator - locks the entire file during the write process and then unlocks the file. Also record lock will be released, regardless of parameter value
Throws:
xBaseJException - any one of several errors
IOException - Java error caused by called methods

update

public void update()
            throws xBaseJException,
                   IOException
updates the record at the current position.

Throws:
xBaseJException - any one of several errors
IOException - Java error caused by called methods

delete

public void delete()
            throws IOException,
                   xBaseJException
marks the current records as deleted.

Throws:
xBaseJException - usually occurs when no record has been read
IOException - Java error caused by called methods

undelete

public void undelete()
              throws IOException,
                     xBaseJException
marks the current records as not deleted.

Throws:
xBaseJException - usually occurs when no record has been read.
IOException - Java error caused by called methods

close

public void close()
           throws IOException
closes the database.

Throws:
IOException - Java error caused by called methods

getField

public Field getField(int i)
               throws 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
ArrayIndexOutOfBoundsException

getField

public Field getField(String name)
               throws xBaseJException,
                      ArrayIndexOutOfBoundsException
returns a Field object by its name in the database.

Parameters:
name - Field name
Throws:
xBaseJException - Field name is not correct
ArrayIndexOutOfBoundsException

getName

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


deleted

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


update_dbhead

public void update_dbhead()
                   throws IOException
Throws:
IOException

setVersion

public void setVersion(int b)

pack

public void pack()
          throws xBaseJException,
                 IOException,
                 SecurityException,
                 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
IOException - Java error caused by called methods
CloneNotSupportedException - Java error caused by called methods
SecurityException

getVersion

public int getVersion()
returns the dbase version field.

Returns:
int

setEncodingType

public static void setEncodingType(String inType)
sets the character encoding variable.
do this prior to opening any dbfs.

Parameters:
inType - encoding type, default is "8859_1" could use "CP850" others

getEncodingType

public static String getEncodingType()
gets the character encoding string value.

Returns:
String "8859_1", "CP850", ...

getXML

public File getXML(String inFileName)
            throws IOException,
                   xBaseJException
generates an xml string representation using xbase.dtd

Parameters:
inFileName - - String
Returns:
File, file is closed when returned.
Throws:
IOException
xBaseJException

getXML

public void getXML(PrintWriter pw)
            throws IOException,
                   xBaseJException
generates an xml string representation using xbase.dtd

Parameters:
pw - - PrinterWriter
Throws:
IOException
xBaseJException


Copyright © 1997-2007 American Coders Ltd. All Rights Reserved.