org.cdlib.xtf.textIndexer
Class MARCIndexSource.RecordHandler

Object
  extended by Thread
      extended by MARCIndexSource.RecordHandler
All Implemented Interfaces:
Runnable, ContentHandler
Enclosing class:
MARCIndexSource

private class MARCIndexSource.RecordHandler
extends Thread
implements ContentHandler

Handles running blocks of records through the stylesheet


Nested Class Summary
 
Nested classes/interfaces inherited from class Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  StringBuffer buffer
          Accumulates the current MARCXML record
 Throwable error
          If an exception occured, it is recorded here
 boolean isDone
          Set to true when this thread has finished its business.
 String parsedMarcXML
          A single parsed MARCXML record
private  Vector prefixNames
          Names of XML namespace prefixes
private  Vector prefixUris
          URIs of XML namespace prefixes
private  HashMap prefixUriToName
          Mapping from URI to name
private  int recordNum
           
 
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
private MARCIndexSource.RecordHandler()
           
 
Method Summary
private  void beginChunk()
           
 void characters(char[] ch, int start, int length)
           
 String convertFromUTF8(char[] chars, int start, int length)
          Look for probable UTF-8 encoding.
private  void convertRecords()
           
private  void endChunk()
           
 void endDocument()
           
 void endElement(String uri, String localName, String qName)
           
 void endPrefixMapping(String prefix)
           
 void ignorableWhitespace(char[] ch, int start, int length)
           
 void processingInstruction(String target, String data)
           
 void run()
           
 void setDocumentLocator(Locator locator)
           
private  boolean skipBadRecord()
           
 void skippedEntity(String name)
           
 void startDocument()
           
 void startElement(String uri, String localName, String qName, Attributes atts)
           
 void startPrefixMapping(String prefix, String uri)
           
 
Methods inherited from class Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parsedMarcXML

public String parsedMarcXML
A single parsed MARCXML record


isDone

public boolean isDone
Set to true when this thread has finished its business.


error

public Throwable error
If an exception occured, it is recorded here


prefixNames

private Vector prefixNames
Names of XML namespace prefixes


prefixUris

private Vector prefixUris
URIs of XML namespace prefixes


prefixUriToName

private HashMap prefixUriToName
Mapping from URI to name


buffer

private StringBuffer buffer
Accumulates the current MARCXML record


recordNum

private int recordNum
Constructor Detail

MARCIndexSource.RecordHandler

private MARCIndexSource.RecordHandler()
Method Detail

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

convertRecords

private void convertRecords()
                     throws Exception
Throws:
Exception

skipBadRecord

private boolean skipBadRecord()
                       throws IOException
Throws:
IOException

beginChunk

private void beginChunk()
                 throws SAXException
Throws:
SAXException

endChunk

private void endChunk()
               throws SAXException
Throws:
SAXException

startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
Throws:
SAXException

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Throws:
SAXException

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Specified by:
characters in interface ContentHandler
Throws:
SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Specified by:
endPrefixMapping in interface ContentHandler
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException
Specified by:
ignorableWhitespace in interface ContentHandler
Throws:
SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Specified by:
processingInstruction in interface ContentHandler
Throws:
SAXException

setDocumentLocator

public void setDocumentLocator(Locator locator)
Specified by:
setDocumentLocator in interface ContentHandler

skippedEntity

public void skippedEntity(String name)
                   throws SAXException
Specified by:
skippedEntity in interface ContentHandler
Throws:
SAXException

convertFromUTF8

public String convertFromUTF8(char[] chars,
                              int start,
                              int length)
Look for probable UTF-8 encoding. If found, convert it to Unicode; if not, return null.

Parameters:
chars - Array of characters to convert
start - Where to start in the array
length - How many characters to examine
Returns:
New Unicode string, or null if no UTF-8 characters found.