jimmc.roots
Class RootsBase

java.lang.Object
  |
  +--jimmc.roots.RootsBase
All Implemented Interfaces:
ResourceSource

public class RootsBase
extends java.lang.Object
implements ResourceSource

RootsBase is the database object for a simple in-memory genealogy database.


Field Summary
 PrintOptions currentPrintOptions
           
 PrintOptions defaultPrintOptions
           
 PrintOptions defaultShowOptions
           
protected  java.util.ResourceBundle resources
           
 
Constructor Summary
RootsBase()
          Create an empty roots database
 
Method Summary
 void clearSelection()
          Clear the current selection.
 RootsRecord findRecord(java.lang.String key)
          Given a key value, return the record for that key
 RootsRecord[] findRecordList(java.lang.String keylist)
          Given a comma-separated list of key values, return an array of records for those keys.
 RootsRecord[] findSelection(java.lang.String[] what, int start, int count)
          Get the records referred to by the specified selection expression.
 RootsRecord[] findSelection(java.lang.String[] what, int start, int count, RootsRecord[] selection)
          Get a selection by expression relative to another selection.
 RootsRecord[] findSelection(java.lang.String what, RootsRecord[] selection)
          Get a selection by simple expression relative to another selection.
protected  RootsRecord[] findSelectionField(java.lang.String[] what, int start, int count, RootsRecord[] selection, java.lang.String fieldName)
          Process the name matching operations.
protected  RootsRecord[] findSelectionPlus(java.lang.String[] what, int start, int count, RootsRecord[] selection)
          Process the "plus" keyword in a selection.
protected  RootsRecord[] findSelectionRecurse(java.lang.String[] what, int start, int count, RootsRecord[] selection)
          Process the "recurse" keyword in a selection.
 int getRecordCount()
          Get the number of records in the database.
 java.lang.String getResourceFormatted(java.lang.String name, java.lang.Object arg)
          Get a string from a resource file and format it with the given arg.
 java.lang.String getResourceFormatted(java.lang.String name, java.lang.Object[] args)
          Get a string from a resource file and use it as the format in a call to MessageFormat.format.
 java.lang.String getResourceString(java.lang.String name)
          Get a string from our resource file.
 java.lang.String[] getSelectedKeys()
          Get the list of currently selected keys.
 java.lang.String getSelectedKeysString()
          Get the list of currently selected keys as a single string.
 void initResources()
          Set up our resources.
static void main(java.lang.String[] args)
          Sample main program
 void println(java.lang.String s)
          Print a line to our current output
 void printRecords(PrintOptions po)
          Print the current selection in the specified format.
 void printRecords(PrintOptions po, RootsRecord[] ra)
          Print the specified selection using the given print options.
 void printRecords(PrintOptions po, java.lang.String[] what, int start, int count)
          Print out the data for the given selection expression
 void readNcvFile(java.lang.String filename)
          Read jimmc's name:value database file into the database.
 void select(java.lang.String[] what, int start, int count)
          Change the selection to the referenced selection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultPrintOptions

public PrintOptions defaultPrintOptions

defaultShowOptions

public PrintOptions defaultShowOptions

currentPrintOptions

public PrintOptions currentPrintOptions

resources

protected java.util.ResourceBundle resources
Constructor Detail

RootsBase

public RootsBase()
Create an empty roots database
Method Detail

getRecordCount

public int getRecordCount()
Get the number of records in the database.

readNcvFile

public void readNcvFile(java.lang.String filename)
Read jimmc's name:value database file into the database. Ncv means name-colon-value, such as "SOURCE: John Doe"

findRecord

public RootsRecord findRecord(java.lang.String key)
Given a key value, return the record for that key

findRecordList

public RootsRecord[] findRecordList(java.lang.String keylist)
Given a comma-separated list of key values, return an array of records for those keys. If any items in the list are not found, the corresponding entry in the array is null.

printRecords

public void printRecords(PrintOptions po)
Print the current selection in the specified format.

printRecords

public void printRecords(PrintOptions po,
                         RootsRecord[] ra)
Print the specified selection using the given print options.

printRecords

public void printRecords(PrintOptions po,
                         java.lang.String[] what,
                         int start,
                         int count)
Print out the data for the given selection expression

clearSelection

public void clearSelection()
Clear the current selection.

select

public void select(java.lang.String[] what,
                   int start,
                   int count)
Change the selection to the referenced selection.
Parameters:
what - array of strings containing selection expression
start - index of first item in selection expression
count - number of items in selection expression

findSelection

public RootsRecord[] findSelection(java.lang.String[] what,
                                   int start,
                                   int count)
Get the records referred to by the specified selection expression.
Parameters:
what - array of selection strings in expression
start - index of first item to consider
count - number of items to consider
Returns:
array of matching records if found, null if not found

findSelection

public RootsRecord[] findSelection(java.lang.String[] what,
                                   int start,
                                   int count,
                                   RootsRecord[] selection)
Get a selection by expression relative to another selection.
Parameters:
what - array of selection strings in expression
start - index of first item to consider
count - number of items to consider
selection - the selection this expression is relative to
Returns:
array of matching records if found, null if not found

findSelectionRecurse

protected RootsRecord[] findSelectionRecurse(java.lang.String[] what,
                                             int start,
                                             int count,
                                             RootsRecord[] selection)
Process the "recurse" keyword in a selection. The recurse selection says we should make the initial reference on the given selection, then keep on making that reference on the returned selection until we don't have any more new items. For example, "recurse father" will get all of the male ancestors.

findSelectionPlus

protected RootsRecord[] findSelectionPlus(java.lang.String[] what,
                                          int start,
                                          int count,
                                          RootsRecord[] selection)
Process the "plus" keyword in a selection. The plus keyword says to take the following selection and add it to its source. For example, the selection "plus wife of father of 123" will select the father and the wife.

findSelectionField

protected RootsRecord[] findSelectionField(java.lang.String[] what,
                                           int start,
                                           int count,
                                           RootsRecord[] selection,
                                           java.lang.String fieldName)
Process the name matching operations.

findSelection

public RootsRecord[] findSelection(java.lang.String what,
                                   RootsRecord[] selection)
Get a selection by simple expression relative to another selection.
Parameters:
what - one selection string.
Returns:
array of matching records if found, null if not found.

getSelectedKeys

public java.lang.String[] getSelectedKeys()
Get the list of currently selected keys.

getSelectedKeysString

public java.lang.String getSelectedKeysString()
Get the list of currently selected keys as a single string.

println

public void println(java.lang.String s)
Print a line to our current output

initResources

public void initResources()
Set up our resources.

getResourceString

public java.lang.String getResourceString(java.lang.String name)
Get a string from our resource file.
Specified by:
getResourceString in interface ResourceSource
Following copied from interface: jimmc.util.ResourceSource
Parameters:
name - The resource name.
Returns:
The value of the resource, or the name if no value is found.

getResourceFormatted

public java.lang.String getResourceFormatted(java.lang.String name,
                                             java.lang.Object[] args)
Get a string from a resource file and use it as the format in a call to MessageFormat.format. args.
Specified by:
getResourceFormatted in interface ResourceSource
Parameters:
name - The name of the resource.
args - The args to pass to MessageFormat.format.
Returns:
The formatted string.

getResourceFormatted

public java.lang.String getResourceFormatted(java.lang.String name,
                                             java.lang.Object arg)
Get a string from a resource file and format it with the given arg.
Specified by:
getResourceFormatted in interface ResourceSource
Following copied from interface: jimmc.util.ResourceSource
Parameters:
name - The resource name.
arg - The argument to MessageFormat.format.
Returns:
The formatted resource string.

main

public static void main(java.lang.String[] args)
Sample main program