Save This Page
Home » openjdk-7 » net.sourceforge » jbird » [javadoc | source]
net.sourceforge.jbird
public final class: JbirdDB [javadoc | source]
java.lang.Object
   net.sourceforge.jbird.JbirdDB
Field Summary
public static final  int LIST_NAME_LEN_MAX    Max length of field in checklistinfo 
public static final  int LIST_DESCRIPTION_LEN_MAX    Max length of field in checklistinfo 
public static final  int LIST_SOURCE_LEN_MAX    Max length of field in checklistinfo 
public static final  int LIST_CONTRIBUTOR_LEN_MAX    Max length of field in checklistinfo 
public static final  int LIST_VERSION_LEN_MAX    Max length of field in checklistinfo 
public static final  int LOCALE_LEN_MAX    Max length of field in commonlistinfo 
public static final  int REGION_NAME_MAX_LEN    Max length of field in regions table. 
public static final  int OBSERVER_NAME_MAX_LEN    Max length of field in observers table. 
public static final  int LOCALITY_MAX_LEN    Max length of field in trips table. 
public static final  int KEYWORDS_MAX_LEN    Max length of field in trips table. 
public  Connection jbirdconn     
public  Statement taxastatement     
public  ResultSet taxaresult     
public  Statement familystatment     
public  ResultSet familyquery     
protected  PreparedStatement pticktypestmt    PreparedStatement for determining tick types. 
protected  PreparedStatement ptickspeciesstmt    PreparedStatement for determining ticking species. 
protected  PreparedStatement pistickedstmt    PreparedStatement for checking ticks. 
protected  PreparedStatement p_get_tick    Prepared statement for quering individual ticks. See getTick. @since distant-future 
protected  PreparedStatement p_update_tickcount    Prepared statement for updating counts of individual ticks. See updateTickCount. @since distant-future 
public static final  int NO_CHECKLIST    Constants that indicate which types of bird names are to be returned by a query 
public static final  int SCIENTIFIC     
public static final  int COMMON     
public static final  int BOTH     
public static final  int INTERNAL_ERROR     
public static final  int TICK_ALREADY     
public static final  int TICK_TRIP     
public static final  int TICK_REGION     
public static final  int TICK_LIFE     
Constructor:
 public JbirdDB(String path,
    String uname,
    String password,
    ResourceBundle pr,
    String driver) throws SQLException 
    Throws SQLException if fails to open connection to the data base
Method from net.sourceforge.jbird.JbirdDB Summary:
addNewNote,   addNewObserver,   addNewRegion,   addNewTrip,   attachNoteToTrip,   changeIndexedString,   clipToMax,   close,   closePreparedStatement,   closePreparedStatements,   closeSqlQuery,   commit,   commonNamesNums,   commonNamesNums,   commonNamesNumsAlphO,   commonNamesNumsTaxO,   countNoteRefs,   countNoteRefs,   dateQuery,   deleteNote,   deleteNote,   dumpTable,   dumpTables,   dumpToFile,   extractInt,   extractIntClose,   extractSpeciesSet,   extractSpeciesSet,   extractValueNLabel,   getAllSpecies,   getAllSpecies,   getAlphabeticalIntvarStringvar,   getChecklistInfo,   getChecklistInfo,   getChecklists,   getChecklists,   getCommonListInfo,   getCommonListInfo,   getCreditsInfo,   getFamilyGenus,   getIndexedString,   getIntvarStringvar,   getIntvarStringvar,   getLogListener,   getNoteInfo,   getNoteText,   getObserverNames,   getObserverNotes,   getObserverNumber,   getObservers,   getObservers,   getStringIndex,   getTick,   getTripDate,   getTripInfo,   getTripNoteNums,   getTripsInRegion,   getUniqueSQL,   getUnsharedObsNoteNums,   intFieldIntoArrayList,   isTicked,   joinIntArray,   joinIntArrayList,   linkSpeciesNote,   moveAllTripsToRegion,   moveTripTicksToTrip,   moveTripsToRegion,   oneParmMsg,   queryForIntString,   regionName,   regionNumber,   removeObserver,   removeRegion,   removeTripsNTicks,   removeTripsNTicks,   removeTripsNTicks,   renameObserver,   renameRegion,   rollback,   setAutoCommit,   setLogListener,   singleIntQuery,   sqlQuery,   sqlQuery,   sqlQuery,   sqlUpdate,   sqlUpdate,   sqlUpdate,   sqlUpdateAsOne,   tickSpecies,   tickSpecies,   tickType,   toCondition,   toCondition,   unanticipatedError,   unlinkNDeleteSpeciesNote,   unlinkSpeciesNote,   untickSpecies,   untickSpecies,   updateNoteText,   updateTickCount,   updateTripInfo,   updateTripNote
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from net.sourceforge.jbird.JbirdDB Detail:
 public final int addNewNote(String text) 
    Add a new note and return the value of NoteNo or -1 upon failure
 public int addNewObserver(String proposedname) 
 public int addNewRegion(String proposedname) 
    Return region number if successful; Return -1 if region already exists; Return -2 on internal error;
 public int addNewTrip(int region,
    Date date,
    String locality,
    String keywords,
    String notes) 
 public int attachNoteToTrip(int noteno,
    int tripno) 
    For a trip, set the value of NoteNo to that given Intended only for emergeny purposes such as when a the system fails to delete a note after that note has already been disassociated from the trip.
 public int changeIndexedString(String dbname,
    String idxvar,
    int idx,
    String stringvar,
    String newvalue) throws SQLException 
 public static final String clipToMax(String value,
    int maxlen) 
 public  void close() 
 public final  void closePreparedStatement(PreparedStatement ps) 
    Close an individual prepared statement without concern for exceptions thrown in the process. null values ok
 public final  void closePreparedStatements() 
    Close all open prepared statements JbirdDB author responsible for making sure that all prepared statements are processed here
 public final  void closeSqlQuery(ResultSet rs) 
    A method to close both a result set and the statement from which it was built.

    Intended for use in methods that make use of the ResultSets that are returned by the sqlQuery method of this class.

    The proper thing to do is probably to make a subclass of ResultSet that has a modified close method. Maybe someday.

 public final  void commit() throws SQLException 
 public final IntStringArrays commonNamesNums(int listno,
    boolean alphabetic) 
    Return a list of common names and species numbers.
 public final IntStringArrays commonNamesNums(String listno,
    boolean alphabetic) 
    Return a list of common names and species numbers. Note that listno is the list number represented as a string.
 public final IntStringArrays commonNamesNumsAlphO(String listno) 
    Get list of species numbers and common names in alphabetic order
 public final IntStringArrays commonNamesNumsTaxO(String listno) 
    Get list of species numbers and common names in tradtional taxonomic order
 public final int countNoteRefs(int notenum) 
    Count number of instances of a note in both tables trips and ticks.

    Returns number of instances or -1 on failure.

 public final int countNoteRefs(int notenum,
    String table) 
    Count references to a note in the given table (table may be trips, ticks or notes).

    Returns number of instances or -1 on failure.

 public final ResultSet dateQuery(String query,
    Date[] dates) throws SQLException 
    A method executing queries that contain date literals, which is an enormous headache. Why format a Date object into a variety of formats for different SQL engines so that the engines can convert them back to binary?

    The query should be a PreparedStatement query in which all question marks represent dates. The number of dates in the array must match the number of question marks in the query. (No checking is done.

 public final int deleteNote(int[] notenums) 
    Delete an array of notes from the notes table if they are not referenced in the ticks table.
 public final int deleteNote(int notenum) 
    Delete a note from the notes table if it is not referenced by any observation in the ticks or trips tables
 public final int dumpTable(String tabname) throws IOException, SQLException 
    Dump table to file of comma separated values. Values containg commas will be quoted. Returns number of records written
 public final  void dumpTables() throws IOException, SQLException 
    Dump all tables.

    WORK HERE - this should report numbers of lines written to the log. dumpTable now returns those numbers.

 public final int dumpToFile(String tabname,
    String filename,
    String delim,
    String quote) throws IOException, SQLException 
    Dump table to file using the specified delimiter. Values containg the delimiter will be quoted using the quote argument if the argument is not null. File io is buffered. Returns number of records written
 public final int extractInt(ResultSet rs) throws SQLException 
    Extract a single integer from column 1 row 1 of the result set. The ResultSet is not closed.

    Useful for COUNT, MAX queries where the statement can be closed after the query.

 public final int extractIntClose(ResultSet rs) throws SQLException 
    Extract a single integer from column 1 row 1 of the result set, and close both the result set and its parent statement.

    Useful for COUNT, MAX queries where the statement can be closed after the query.

 public final int extractSpeciesSet(ResultSet rs,
    SpeciesSet set) throws SQLException 
    Extract species from a ResultSet and add them to the species set that is provided. The locations of items in the ResultSet is pretty picky.

    Called by getChecklists and getTicked Species, which have been written to provide fields in identical order.

 public final int extractSpeciesSet(ResultSet rs,
    SpeciesSet set,
    boolean closequery) throws SQLException 
 protected final ValueNLabel extractValueNLabel(ResultSet rs) throws SQLException 
    This method is used to collect information on column and row headers from a preliminary query that extracts that information from a table. The idea is to run a query for column headers, use this method, run a query for row headers, use this method, run the cross tabulation query, and use buildTableData to harvest the results.
 public final ResultSet getAllSpecies(int commonlist) throws SQLException 
 public final int getAllSpecies(int commonlist,
    SpeciesSet set) throws SQLException 
 public IntStringArrays getAlphabeticalIntvarStringvar(String dbname,
    String idxvar,
    String stringvar,
    String extra) 
    Returns null if there was an error.
    Returns an IntStringArrays object that contains nulls if the query returned no observations.
 public String[] getChecklistInfo(int listno) throws SQLException 
    Return array of information about a checklist when the list number is given as an integer. See string version for details on the String array.
 public String[] getChecklistInfo(String strlistno) throws SQLException 
    Return array of array of information about a commmon name list, when the list number is given as a string.

    The string array returned contains in the following order Listname, Description, Source, Contributor, Version.

 public final IntStringArrays getChecklists() throws SQLException 
    Return an IntStringArray object that contains the checklists in alphabetical order and their primary keys.
 public final int getChecklists(int[] lists,
    int commonlist,
    SpeciesSet set) throws SQLException 
    Add species in the checklist to the set of species.
 public String[] getCommonListInfo(int listno) 
    Return array of information about a common name list when the list number is given as an integer. See string version for details on the String array.
 public String[] getCommonListInfo(String strlistno) 
    Return array of array of information about a commmon name list, when the list number is given as a string.

    The string array returned contains in the following order Encoding, Listname, Description, Source, Contributor, Version

 public Object[] getCreditsInfo(int commonlist,
    int checklist) 
 public final int[] getFamilyGenus(int species) throws SQLException 
    Return the family and genus numbers of a species.
 public String getIndexedString(String dbname,
    String idxvar,
    int idx,
    String stringvar) throws SQLException 
 public IntStringArrays getIntvarStringvar(String dbname,
    String idxvar,
    String stringvar) throws SQLException 
 public IntStringArrays getIntvarStringvar(String dbname,
    String idxvar,
    String stringvar,
    String extra) throws SQLException 
    Returns null if nothing matches query.
 public final LogListener getLogListener() 
 public ResultSet getNoteInfo(int trip,
    int[] observers,
    int species) 
    Return a result set that includes the note index for each observer that observed a species on a trip.
 public final String getNoteText(int noteno) 
    Return the text of the indicated note, or null on failure
 public String[] getObserverNames(int[] obsnos) 
    Return the names of the observers in the same order
 public final ArrayList getObserverNotes(int obsno) throws SQLException 
 public int getObserverNumber(String observer) throws SQLException 
    Return number that corresponds to observer. Returns -1 if observer not found.
 public final int[] getObservers(int tripno) 
 public final int[] getObservers(String tripno) 
 public int getStringIndex(String dbname,
    String idxvar,
    String stringvar,
    String stringval) 
 public final Tick getTick(Tick info) throws SQLException 
    Fill in the count and note fields of the tick provided. Returns null if the the tick is not completely specified (trip, observer, or species < 0) or if the species has not been ticked by the observer on the given trip. Throws all SQLExceptions. The bird count and note fields will have the value Tick.MISSING if they are null in the returned record.

    No effort is made to check for duplicate observations. The first returned by the database query is returned by the method.

 public Date getTripDate(int tripno) 
 public TripInfo getTripInfo(int tripno) 
 public final ArrayList getTripNoteNums(String triplist) throws SQLException 
 public IntStringArrays getTripsInRegion(int region) 
 public final String getUniqueSQL(String key) 
    Retrieve an entry from the store of sql that is unique to the driver in use.

    Such sql is assumed to be used infrequently. Only a weak reference is maintained to it by JbirdDB.

 public final ArrayList getUnsharedObsNoteNums(int obsno) throws SQLException 
 public static int intFieldIntoArrayList(ResultSet rs,
    int fieldno,
    ArrayList la) throws SQLException 
    Extract integer field from a result set and store values in a ArrayList that is provided in the function call.

    Return the number of values added to the ArrayList.

    This method does not close either the ResultSet.

 public boolean isTicked(int species,
    int trip,
    int observer) 
    Determine whether a species has been ticked by an observer on a trip.

    In the event of an exception, prints to log and returns false without further incident.

 public final String joinIntArray(String delim,
    int[] ia) 
    Format integer array as a string with elements delimited as indicated.
 public final String joinIntArrayList(String delim,
    ArrayList al) 
 public int linkSpeciesNote(int tripno,
    int specno,
    int[] observers,
    int noteno) 
    Associate a note with observers on a trip.
 public int moveAllTripsToRegion(int srcregion,
    int destregion) 
 public int moveTripTicksToTrip(int srctrip,
    int desttrip) 
    ALSO REMOVES srctrip.
 public int moveTripsToRegion(String region,
    String triplist) 
 public  void oneParmMsg(int level,
    String resname,
    String message) 
 public final IntStringArrays queryForIntString(String sqlquery,
    int intcol,
    int stringcol) 
    Perform the sql query indicated and return integer and string arrays of the columns indicated by intcol and stringcol.

    Returns null on error or empty ResultSet.

 public String regionName(int regionnumber) throws SQLException 
 public int regionNumber(String regionname) throws SQLException 
    Return number that corresponds to region name. Returns -1 if region not found.
 public int removeObserver(int observer) 
 public int removeRegion(int region) 
 public int removeTripsNTicks(String triplist) 
    Remove trips listed, including ticks and notes.

    Triplist should be a ", " delimited list of trips to delete.

    If auto commit is on, changes effected by this methods will be performed as a single transaction, (i.e., auto commit will be turned off, the transactions will be committed, and autocommit will be turned back on.

 public int removeTripsNTicks(int[] triplist) 
 public int removeTripsNTicks(int tripno) 
 public int renameObserver(int lobsnum,
    String lnewname) 
 public int renameRegion(int lregnum,
    String lnewname) 
 public final  void rollback() throws SQLException 
 public final  void setAutoCommit(boolean to) throws SQLException 
 public final  void setLogListener(LogListener logger) 
 public final int singleIntQuery(String query,
    Object[] objects,
    int[] types) throws SQLException 
    Return the integer result of query that returns an a result set that contains a single observation with a single integer field. This method can be used for more complex result sets, but will return the integer value in the first column of the first row of the result set.

    Closes ResultSet AND parent Statement!

 public final ResultSet sqlQuery(String query) throws SQLException 
 public final ResultSet sqlQuery(String[] querya) throws SQLException 
 public final ResultSet sqlQuery(String query,
    Object[] objects,
    int[] types) throws SQLException 
    A query for avoiding all formatting of literals for the query. Pass a query suitable for a preparedStatement, an array of objects along with an array of java.sql.Types that describes the nature of the objects for substitution. Array lengths must match the number question marks in the query.
 public int sqlUpdate(String query) throws SQLException 
 public int sqlUpdate(String[] querya) throws SQLException 
 public final int sqlUpdate(String query,
    Object[] objects,
    int[] types) throws SQLException 
    An update query for avoiding all formatting of literals for the query. Pass a query suitable for a preparedStatement, an array of objects along with an array of java.sql.Types that describes the nature of the objects for substitution. Array lengths must match the number question marks in the query.
 public int sqlUpdateAsOne(String[] querya) throws SQLException 
    Like sqlUpdate, but uses transaction processing. Sets auto commit to false before processing the argument. Commits, rolls back and sets to auto commit to true after processing.
 public final int tickSpecies(int trip,
    int observer,
    int species) 
 public final int tickSpecies(int trip,
    int observer,
    int species,
    int count) 
 public int tickType(int region,
    int trip,
    Date tripdate,
    int observer,
    int species) 
    Returns one of INTERNAL_ERROR, TICK_ALREADY, TICK_TRIP, TICK_REGION, TICK_LIFE.
 public final String toCondition(int[] ia) 
    Return a string that contains an SQL condition operator and what follows it for a condition. If the length of ia is 1, return "= value_of_ia[0]". If the length of ia is greater than 1 return an IN condition such as "IN ( value_of_ia[0], ... )"
 public final String toCondition(String[] sa) 
    Return a string that contains an SQL condition operator and what follows it for a condition. If the length of ia is 1, return "= value_of_ia[0]". If the length of ia is greater than 1 return an IN condition such as "IN ( value_of_ia[0], ... )" Note that this method quotes non-destructively quotes the elements of sa for inclusion in the condition.
 public  void unanticipatedError(String msg) 
 public final int unlinkNDeleteSpeciesNote(int tripno,
    int specno,
    int[] observers) 
    Unlink and delete species notes for the observers, species, and trip indicated.

    Returns the number of notes actually deleted.

 public final int[] unlinkSpeciesNote(int tripno,
    int specno,
    int[] observers) 
    Disassociate a note from the indicated observers in the indicated trip.

    Returns an integer array that contains identification numbers of notes that were unlinked.

    The note will not be deleted from the notes table. Use deleteNote to do that after all associations have been broken.

 public final int untickSpecies(int trip,
    int observer,
    int species)