Package org.omegat.filters3.xml
Class Handler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.omegat.filters3.xml.Handler
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler
,org.xml.sax.DTDHandler
,org.xml.sax.EntityResolver
,org.xml.sax.ErrorHandler
,org.xml.sax.ext.DeclHandler
,org.xml.sax.ext.LexicalHandler
public class Handler extends org.xml.sax.helpers.DefaultHandler implements org.xml.sax.ext.LexicalHandler, org.xml.sax.ext.DeclHandler
The part of XML filter that actually does the job. This class is called back by SAXParser. Entities described on http://www.ibm.com/developerworks/xml/library/x-entities/ http://xmlwriter.net/xml_guide/entity_declaration.shtml
-
-
Constructor Summary
Constructors Constructor Description Handler(org.omegat.filters3.xml.Translator translator, XMLDialect dialect, java.io.File inFile, java.io.File outFile, FilterContext fc)
Creates a new instance of Handler
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attributeDecl(java.lang.String eName, java.lang.String aName, java.lang.String type, java.lang.String valueDefault, java.lang.String value)
Not used: An attribute type declaration.void
characters(char[] ch, int start, int length)
Receive notification of character data inside an element.void
comment(char[] ch, int start, int length)
Receive notification of an XML comment anywhere in the document.org.xml.sax.InputSource
doResolve(java.lang.String publicId, java.lang.String systemId)
Resolves external entity and creates a new writer if it's an included file.void
elementDecl(java.lang.String name, java.lang.String model)
Not used: An element type declaration.void
endCDATA()
Report the end of a CDATA section.void
endDocument()
Receive notification of the end of the document.void
endDTD()
Report the end of DTD declarations.void
endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
Receive notification of the end of an element.void
endEntity(java.lang.String name)
Report the end of an entity.void
externalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
Report a parsed external entity declaration.void
fatalError(org.xml.sax.SAXParseException e)
Report a fatal XML parsing error.FilterContext
getContext()
java.util.List<java.io.File>
getProcessedFiles()
Returns external files this handler has processed, because they were included into main file.void
ignorableWhitespace(char[] ch, int start, int length)
Receive notification of ignorable whitespace in element content.void
internalEntityDecl(java.lang.String name, java.lang.String value)
Report an internal entity declaration.boolean
isParagraphTag(Tag tag)
Returns whether the tag starts a new paragraph.void
processingInstruction(java.lang.String target, java.lang.String data)
Receive notification of an XML processing instruction anywhere in the document.org.xml.sax.InputSource
resolveEntity(java.lang.String publicId, java.lang.String systemId)
Resolves an external entity.void
startCDATA()
Report the start of a CDATA section.void
startDocument()
Receive notification of the beginning of the document.void
startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
Report the start of DTD declarations, if any.void
startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
Receive notification of the start of an element.void
startEntity(java.lang.String name)
Not used: Report the beginning of some internal and external XML entities.
-
-
-
Constructor Detail
-
Handler
public Handler(org.omegat.filters3.xml.Translator translator, XMLDialect dialect, java.io.File inFile, java.io.File outFile, FilterContext fc) throws java.io.IOException
Creates a new instance of Handler- Throws:
java.io.IOException
-
-
Method Detail
-
getProcessedFiles
public java.util.List<java.io.File> getProcessedFiles()
Returns external files this handler has processed, because they were included into main file. Each entry isFile
.
-
getContext
public FilterContext getContext()
-
doResolve
public org.xml.sax.InputSource doResolve(java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException, TranslationException, java.io.IOException, java.net.URISyntaxException
Resolves external entity and creates a new writer if it's an included file.- Throws:
org.xml.sax.SAXException
TranslationException
java.io.IOException
java.net.URISyntaxException
-
isParagraphTag
public boolean isParagraphTag(Tag tag)
Returns whether the tag starts a new paragraph.
-
resolveEntity
public org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
Resolves an external entity.- Specified by:
resolveEntity
in interfaceorg.xml.sax.EntityResolver
- Overrides:
resolveEntity
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
startElement
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
Receive notification of the start of an element.- Specified by:
startElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startElement
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
endElement
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
Receive notification of the end of an element.- Specified by:
endElement
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endElement
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
characters
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
Receive notification of character data inside an element.- Specified by:
characters
in interfaceorg.xml.sax.ContentHandler
- Overrides:
characters
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException
Receive notification of ignorable whitespace in element content.- Specified by:
ignorableWhitespace
in interfaceorg.xml.sax.ContentHandler
- Overrides:
ignorableWhitespace
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
comment
public void comment(char[] ch, int start, int length) throws org.xml.sax.SAXException
Receive notification of an XML comment anywhere in the document.- Specified by:
comment
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
-
processingInstruction
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
Receive notification of an XML processing instruction anywhere in the document.- Specified by:
processingInstruction
in interfaceorg.xml.sax.ContentHandler
- Overrides:
processingInstruction
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
startDocument
public void startDocument() throws org.xml.sax.SAXException
Receive notification of the beginning of the document.- Specified by:
startDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
startDocument
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
endDocument
public void endDocument() throws org.xml.sax.SAXException
Receive notification of the end of the document.- Specified by:
endDocument
in interfaceorg.xml.sax.ContentHandler
- Overrides:
endDocument
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
fatalError
public void fatalError(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
Report a fatal XML parsing error. Is used to provide feedback.- Specified by:
fatalError
in interfaceorg.xml.sax.ErrorHandler
- Overrides:
fatalError
in classorg.xml.sax.helpers.DefaultHandler
- Throws:
org.xml.sax.SAXException
-
startDTD
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
Report the start of DTD declarations, if any.- Specified by:
startDTD
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
-
endDTD
public void endDTD() throws org.xml.sax.SAXException
Report the end of DTD declarations. Queues the DTD declaration with all the entities declared.- Specified by:
endDTD
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
-
startCDATA
public void startCDATA() throws org.xml.sax.SAXException
Report the start of a CDATA section.- Specified by:
startCDATA
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
-
endCDATA
public void endCDATA() throws org.xml.sax.SAXException
Report the end of a CDATA section.- Specified by:
endCDATA
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
-
startEntity
public void startEntity(java.lang.String name) throws org.xml.sax.SAXException
Not used: Report the beginning of some internal and external XML entities.- Specified by:
startEntity
in interfaceorg.xml.sax.ext.LexicalHandler
- Throws:
org.xml.sax.SAXException
-
endEntity
public void endEntity(java.lang.String name) throws org.xml.sax.SAXException
Report the end of an entity.- Specified by:
endEntity
in interfaceorg.xml.sax.ext.LexicalHandler
- Parameters:
name
- The name of the entity that is ending.- Throws:
org.xml.sax.SAXException
- The application may raise an exception.- See Also:
startEntity(java.lang.String)
-
internalEntityDecl
public void internalEntityDecl(java.lang.String name, java.lang.String value) throws org.xml.sax.SAXException
Report an internal entity declaration.- Specified by:
internalEntityDecl
in interfaceorg.xml.sax.ext.DeclHandler
- Throws:
org.xml.sax.SAXException
-
externalEntityDecl
public void externalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
Report a parsed external entity declaration.- Specified by:
externalEntityDecl
in interfaceorg.xml.sax.ext.DeclHandler
- Throws:
org.xml.sax.SAXException
-
elementDecl
public void elementDecl(java.lang.String name, java.lang.String model)
Not used: An element type declaration.- Specified by:
elementDecl
in interfaceorg.xml.sax.ext.DeclHandler
-
attributeDecl
public void attributeDecl(java.lang.String eName, java.lang.String aName, java.lang.String type, java.lang.String valueDefault, java.lang.String value)
Not used: An attribute type declaration.- Specified by:
attributeDecl
in interfaceorg.xml.sax.ext.DeclHandler
-
-