genealogy.parser
Class Parser

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--genealogy.parser.Parser

public class Parser
extends java.lang.Thread


Field Summary
private static boolean checkOK
           
private static int childOrder
           
private static LogWriter configLog
           
private static java.util.Vector dataContent
           
private static int dateBegin
           
private static int dateEnd
           
private static int dateType
           
private static DBManager dbm
           
private static int eventOrder
           
private static int familyOrder
           
private static int genId
           
private static boolean initDone
           
private static java.lang.String inputDir
           
private static java.lang.String ltp
           
private static int maxLevel
           
private static java.lang.String outputDir
           
private static LogWriter parserLog
           
private static boolean parsing
           
private static int pollTime
           
private static SourceReader reader
           
private static int researchId
           
private static java.lang.String sc
           
private static java.lang.String[] sourceExt
           
private static java.io.File srcFile
           
private static int state
           
private static java.lang.StringBuffer strBuf
           
private static int textOrder
           
private static java.lang.String updateDir
           
private static SourceWriter writer
           
 
Fields inherited from class java.lang.Thread
contextClassLoader, daemon, eetop, group, inheritedAccessControlContext, MAX_PRIORITY, MIN_PRIORITY, name, NORM_PRIORITY, priority, single_step, stillborn, stopThreadPermission, target, threadInitNumber, threadQ, values
 
Constructor Summary
Parser(ConfigReader cr, LogWriter log)
           
 
Method Summary
private static int convertDate(java.lang.String date)
          This method is used to convert a date string into a format stored into the database.
private static java.lang.String convertString(java.lang.String s)
          This method is used to convert " and ' characters into escape characters \" and \' so that they can be fed into the database without a problem.
private static int getState(java.lang.String tag)
          This method is used to find out how to proceed when parsing a level 0 Gedcom structures.
private static void initParser(ConfigReader cr)
           
private static boolean parseChildOrder(java.lang.String refId)
          This method is called to parse any and all children contained by a family structure in the source data.
private static boolean parseDate(int lev)
          This method provides the necessary functionality to parse both simple and structured dates.
private static boolean parseFamilyOrder(java.lang.String refId)
          This method is called to parse any and all families contained by an individual structure in the source data.
private static Incident parseIncident(java.lang.String refId, int lev)
          This method provides the functionality to parse events from source data.
private static java.lang.String parseName(java.lang.String refId, int lev)
          This method provides the necessary functionality to parse bot simple and structured names.
private static java.lang.String parsePlace(int lev)
          This method provides the necessary functionality to parse bot simple and structured places.
private static boolean parseRefText(java.lang.String refId, int lev)
          This method can be called to parse a reference object from the source data.
private static boolean parseText(java.lang.String refId, int lev)
          This method provides the functionality to parse all text fields.
static void runParser()
          Varsinainen metodi, joka hoitaa Gedcom tiedoston jäsentämisen ja kirjoittaa SQL käskyt levylle.
static void startParser()
          This method will start the parser, create log files, open source files and out file as well as create a reader and writer for input and output and initialize all static variables used by the parser.
static void stopParser()
          This method is called when the parser has finished parsing the source data.
 
Methods inherited from class java.lang.Thread
, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, exit, getContextClassLoader, getName, getPriority, getThreadGroup, init, interrupt, interrupt0, interrupted, isAlive, isDaemon, isInterrupted, isInterrupted, join, join, join, nextThreadNum, registerNatives, resume, resume0, run, setContextClassLoader, setDaemon, setName, setPriority, setPriority0, sleep, sleep, start, stop, stop, stop0, suspend, suspend0, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

initDone

private static boolean initDone

parsing

private static boolean parsing

pollTime

private static int pollTime

srcFile

private static java.io.File srcFile

sc

private static final java.lang.String sc

inputDir

private static java.lang.String inputDir

outputDir

private static java.lang.String outputDir

updateDir

private static java.lang.String updateDir

sourceExt

private static java.lang.String[] sourceExt

configLog

private static LogWriter configLog

parserLog

private static LogWriter parserLog

dataContent

private static java.util.Vector dataContent

reader

private static SourceReader reader

writer

private static SourceWriter writer

dbm

private static DBManager dbm

state

private static int state

ltp

private static java.lang.String ltp

maxLevel

private static int maxLevel

researchId

private static int researchId

genId

private static int genId

textOrder

private static int textOrder

eventOrder

private static int eventOrder

childOrder

private static int childOrder

familyOrder

private static int familyOrder

dateBegin

private static int dateBegin

dateEnd

private static int dateEnd

dateType

private static int dateType

strBuf

private static java.lang.StringBuffer strBuf

checkOK

private static boolean checkOK
Constructor Detail

Parser

public Parser(ConfigReader cr,
              LogWriter log)
Method Detail

initParser

private static void initParser(ConfigReader cr)

startParser

public static void startParser()
This method will start the parser, create log files, open source files and out file as well as create a reader and writer for input and output and initialize all static variables used by the parser. It will also set the state for the parser, depending on whether there is new material to parse or not.

runParser

public static void runParser()
Varsinainen metodi, joka hoitaa Gedcom tiedoston jäsentämisen ja kirjoittaa SQL käskyt levylle. Metodi hoitaa myös yhteydet tietokantaan ja tutkimuksen tilan päivityksen jäsentämisen yhteydessä.
Returns:
void

stopParser

public static void stopParser()
This method is called when the parser has finished parsing the source data. It will write the SQL commands and close all open streams to source, output and logging.
Returns:
void

getState

private static int getState(java.lang.String tag)
This method is used to find out how to proceed when parsing a level 0 Gedcom structures. (Eg. what type of structure is in question.
Parameters:
tag - String containing the data tag
Returns:
int int equal to tag type

parseText

private static boolean parseText(java.lang.String refId,
                                 int lev)
                          throws java.lang.Exception
This method provides the functionality to parse all text fields. This includes notes, sources, texts and possibly other structures as well.
Parameters:
refId - reference to a parent structure
lev - level at which this call occurred
Returns:
boolean true, if succesfull

convertString

private static java.lang.String convertString(java.lang.String s)
                                       throws java.lang.Exception
This method is used to convert " and ' characters into escape characters \" and \' so that they can be fed into the database without a problem.
Parameters:
String - s the String to check for conversion
Returns:
String either the converted or unmodified String

parseIncident

private static Incident parseIncident(java.lang.String refId,
                                      int lev)
                               throws java.lang.Exception
This method provides the functionality to parse events from source data. In order to parse references, dates, places, notes, sources and texts, it will call different methods.
Parameters:
refId - reference to a parent structure
lev - level at which this call occurred
Returns:
Incident parsed Incident structure

parsePlace

private static java.lang.String parsePlace(int lev)
                                    throws java.lang.Exception
This method provides the necessary functionality to parse bot simple and structured places. Information gained will be placed into three static variables and saved to event.
Parameters:
lev - level at which this call occurred
Returns:
boolean true, if succesfull

parseName

private static java.lang.String parseName(java.lang.String refId,
                                          int lev)
                                   throws java.lang.Exception
This method provides the necessary functionality to parse bot simple and structured names. Information gained will be placed into three static variables and saved to individual.
Parameters:
refId - reference to a parent structure
lev - level at which this call occurred
Returns:
boolean true, if succesfull

parseDate

private static boolean parseDate(int lev)
                          throws java.lang.Exception
This method provides the necessary functionality to parse both simple and structured dates. Information gained will be placed into three static variables and saved to event.
Parameters:
int - lev level at which this call occurred
Returns:
boolean true, if succesfull

convertDate

private static int convertDate(java.lang.String date)
                        throws java.lang.Exception
This method is used to convert a date string into a format stored into the database.
Parameters:
String - date date string (dd month yyyy)
Returns:
int converted date (yyyymmdd)

parseRefText

private static boolean parseRefText(java.lang.String refId,
                                    int lev)
                             throws java.lang.Exception
This method can be called to parse a reference object from the source data. The reference may be of any type. The actual reference is later parsed and placed into Text table.
Parameters:
String - refId reference to a parent structure
int - lev level at which this reference occurred
Returns:
boolean true, if parsing was succesfull

parseFamilyOrder

private static boolean parseFamilyOrder(java.lang.String refId)
                                 throws java.lang.Exception
This method is called to parse any and all families contained by an individual structure in the source data. It will preserve the order of the families.
Parameters:
String - refId reference to a parent structure
Returns:
boolean true, if parsing was succesfull

parseChildOrder

private static boolean parseChildOrder(java.lang.String refId)
                                throws java.lang.Exception
This method is called to parse any and all children contained by a family structure in the source data. It will preserve the order of the children.
Parameters:
String - refId reference to a parent structure
Returns:
boolean true, if parsing was succesfull