Class Replacer
java.lang.Object
org.xml.sax.helpers.DefaultHandler
Replacer
- All Implemented Interfaces:
- org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
public class Replacer
- extends org.xml.sax.helpers.DefaultHandler
This SAX parser copies an XML corpus file into an output file
replacing in mode 3 or 4 all orth elements with the replacements specified in a ConversionDictionary,
otherwise stripping the elements or replacing them with strings of Xx chars
- Version:
- 0.1, November 2007
- Author:
- Johannes Dellert
Constructor Summary |
Replacer(java.io.File outputFile,
int aMode,
java.lang.String theOrthPath,
java.lang.String thePosPath,
Drop log)
A Replacer needs an output file, a mode, and specification of the content to mask. |
Method Summary |
void |
characters(char[] ch,
int start,
int length)
|
void |
endDocument()
|
void |
endElement(java.lang.String namespaceURI,
java.lang.String sName,
java.lang.String qName)
|
void |
log(java.lang.String output)
used to display a message (debugging or progress info) in System.out or in the log window of the GUI |
void |
setConvDict(ConversionDictionary theDict)
specify a ConversionDictionary to be used for masking |
void |
startDocument()
|
void |
startElement(java.lang.String namespaceURI,
java.lang.String sName,
java.lang.String qName,
org.xml.sax.Attributes attrs)
|
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Replacer
public Replacer(java.io.File outputFile,
int aMode,
java.lang.String theOrthPath,
java.lang.String thePosPath,
Drop log)
- A Replacer needs an output file, a mode, and specification of the content to mask.
- Parameters:
outputFile
- - the file to write toaMode
- - an integer between 0 and 4 for different modes (for internal use)theOrthPath
- - the XPath expression to define masked contentthePosPath
- - the XPath expression to define classification of content for dictionary retrievallog
- - a Drop object to handle logging messages in the GUI - null for console output
setConvDict
public void setConvDict(ConversionDictionary theDict)
- specify a ConversionDictionary to be used for masking
- Parameters:
theDict
- - a ConversionDictionary defining how to mask the different tokens
startDocument
public void startDocument()
- Specified by:
startDocument
in interface org.xml.sax.ContentHandler
- Overrides:
startDocument
in class org.xml.sax.helpers.DefaultHandler
endDocument
public void endDocument()
- Specified by:
endDocument
in interface org.xml.sax.ContentHandler
- Overrides:
endDocument
in class org.xml.sax.helpers.DefaultHandler
startElement
public void startElement(java.lang.String namespaceURI,
java.lang.String sName,
java.lang.String qName,
org.xml.sax.Attributes attrs)
- Specified by:
startElement
in interface org.xml.sax.ContentHandler
- Overrides:
startElement
in class org.xml.sax.helpers.DefaultHandler
endElement
public void endElement(java.lang.String namespaceURI,
java.lang.String sName,
java.lang.String qName)
- Specified by:
endElement
in interface org.xml.sax.ContentHandler
- Overrides:
endElement
in class org.xml.sax.helpers.DefaultHandler
characters
public void characters(char[] ch,
int start,
int length)
- Specified by:
characters
in interface org.xml.sax.ContentHandler
- Overrides:
characters
in class org.xml.sax.helpers.DefaultHandler
log
public void log(java.lang.String output)
- used to display a message (debugging or progress info) in System.out or in the log window of the GUI
- Parameters:
output
- - the logging message to be displayed in System.out or in the log window of the GUI