public class TextDatabase extends Object implements CGDatabase
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
Attached |
(package private) String |
currentfilename
Once the database file is opened, this class leaves the file open; it's
up to its user to close it with closeDB().
|
(package private) String[] |
DBValidNames |
(package private) FileInputStream |
fis |
(package private) BufferedReader |
in |
(package private) boolean |
openAndReady |
(package private) int |
primaryKey |
Constructor and Description |
---|
TextDatabase(String fname) |
Modifier and Type | Method and Description |
---|---|
void |
closeDB()
Close the database file.
|
String |
doLookup(String keytype,
String keyvalue,
String targettype)
Searches the database file for the appropriate value; the "guts" of a
database lookup.
|
int |
getFieldPosition(String Field) |
String[] |
getFields() |
String |
getName()
Accesses the name by which the database will be known to graphs.
|
int |
getPrimaryKey() |
String |
getPrimaryKeyString() |
String[] |
getValidNames() |
boolean |
isOpened() |
boolean |
isReady() |
void |
makeReady()
set up the database file for reading data
|
boolean |
open(String fname)
Initializes the file "in" for reading.
|
void |
resetDB()
Rewinds the database file so that the first line of read data can be
read.
|
void |
setPrimaryKey(int keyIndex) |
void |
setPrimaryKey(String keyType) |
EditFrame |
setupGraph(int key)
Creates a new editing window with a graph already created for accessing
this database.
|
private void |
showRecordLine(String[] holder,
String s) |
String currentfilename
String[] DBValidNames
int primaryKey
FileInputStream fis
BufferedReader in
boolean openAndReady
boolean Attached
public TextDatabase(String fname) throws CGFileException
CGFileException
public String getName()
CGDatabase
getName
in interface CGDatabase
GraphUpdater
public boolean open(String fname) throws CGFileException
fname
- path-qualified name of file to be opened.CGFileException
public void resetDB()
resetDB
in interface CGDatabase
public void closeDB()
closeDB
in interface CGDatabase
public boolean isOpened()
public boolean isReady()
public String[] getValidNames()
public void setPrimaryKey(int keyIndex)
public void setPrimaryKey(String keyType)
public int getPrimaryKey()
public String getPrimaryKeyString()
public void makeReady()
public String[] getFields() throws CGFileException
CGFileException
public int getFieldPosition(String Field)
Field
- the text representation of a database field namepublic String doLookup(String keytype, String keyvalue, String targettype)
doLookup
in interface CGDatabase
keytype
- The field name used as a key; e.g., "Employee"keyvalue
- The key's value; e.g., "John Smith"targettype
- The field name (column) whose value is being sought;
e.g., "Phone Number"private void showRecordLine(String[] holder, String s)
public EditFrame setupGraph(int key) throws CGException
key
- index into the DBValidNames array; -1
if there is
no key.CGException