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.DeclHandlerThe 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 voidattributeDecl(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.voidcharacters(char[] ch, int start, int length)Receive notification of character data inside an element.voidcomment(char[] ch, int start, int length)Receive notification of an XML comment anywhere in the document.org.xml.sax.InputSourcedoResolve(java.lang.String publicId, java.lang.String systemId)Resolves external entity and creates a new writer if it's an included file.voidelementDecl(java.lang.String name, java.lang.String model)Not used: An element type declaration.voidendCDATA()Report the end of a CDATA section.voidendDocument()Receive notification of the end of the document.voidendDTD()Report the end of DTD declarations.voidendElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)Receive notification of the end of an element.voidendEntity(java.lang.String name)Report the end of an entity.voidexternalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)Report a parsed external entity declaration.voidfatalError(org.xml.sax.SAXParseException e)Report a fatal XML parsing error.FilterContextgetContext()java.util.List<java.io.File>getProcessedFiles()Returns external files this handler has processed, because they were included into main file.voidignorableWhitespace(char[] ch, int start, int length)Receive notification of ignorable whitespace in element content.voidinternalEntityDecl(java.lang.String name, java.lang.String value)Report an internal entity declaration.booleanisParagraphTag(Tag tag)Returns whether the tag starts a new paragraph.voidprocessingInstruction(java.lang.String target, java.lang.String data)Receive notification of an XML processing instruction anywhere in the document.org.xml.sax.InputSourceresolveEntity(java.lang.String publicId, java.lang.String systemId)Resolves an external entity.voidstartCDATA()Report the start of a CDATA section.voidstartDocument()Receive notification of the beginning of the document.voidstartDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)Report the start of DTD declarations, if any.voidstartElement(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.voidstartEntity(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.IOExceptionCreates 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.URISyntaxExceptionResolves external entity and creates a new writer if it's an included file.- Throws:
org.xml.sax.SAXExceptionTranslationExceptionjava.io.IOExceptionjava.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.SAXExceptionResolves an external entity.- Specified by:
resolveEntityin interfaceorg.xml.sax.EntityResolver- Overrides:
resolveEntityin 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.SAXExceptionReceive notification of the start of an element.- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin 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.SAXExceptionReceive notification of the end of an element.- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
characters
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXExceptionReceive notification of character data inside an element.- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
charactersin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXExceptionReceive notification of ignorable whitespace in element content.- Specified by:
ignorableWhitespacein interfaceorg.xml.sax.ContentHandler- Overrides:
ignorableWhitespacein classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
comment
public void comment(char[] ch, int start, int length) throws org.xml.sax.SAXExceptionReceive notification of an XML comment anywhere in the document.- Specified by:
commentin 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.SAXExceptionReceive notification of an XML processing instruction anywhere in the document.- Specified by:
processingInstructionin interfaceorg.xml.sax.ContentHandler- Overrides:
processingInstructionin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
startDocument
public void startDocument() throws org.xml.sax.SAXExceptionReceive notification of the beginning of the document.- Specified by:
startDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
startDocumentin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
endDocument
public void endDocument() throws org.xml.sax.SAXExceptionReceive notification of the end of the document.- Specified by:
endDocumentin interfaceorg.xml.sax.ContentHandler- Overrides:
endDocumentin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException
-
fatalError
public void fatalError(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXExceptionReport a fatal XML parsing error. Is used to provide feedback.- Specified by:
fatalErrorin interfaceorg.xml.sax.ErrorHandler- Overrides:
fatalErrorin 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.SAXExceptionReport the start of DTD declarations, if any.- Specified by:
startDTDin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
endDTD
public void endDTD() throws org.xml.sax.SAXExceptionReport the end of DTD declarations. Queues the DTD declaration with all the entities declared.- Specified by:
endDTDin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
startCDATA
public void startCDATA() throws org.xml.sax.SAXExceptionReport the start of a CDATA section.- Specified by:
startCDATAin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
endCDATA
public void endCDATA() throws org.xml.sax.SAXExceptionReport the end of a CDATA section.- Specified by:
endCDATAin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
startEntity
public void startEntity(java.lang.String name) throws org.xml.sax.SAXExceptionNot used: Report the beginning of some internal and external XML entities.- Specified by:
startEntityin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
endEntity
public void endEntity(java.lang.String name) throws org.xml.sax.SAXExceptionReport the end of an entity.- Specified by:
endEntityin 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.SAXExceptionReport an internal entity declaration.- Specified by:
internalEntityDeclin 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.SAXExceptionReport a parsed external entity declaration.- Specified by:
externalEntityDeclin 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:
elementDeclin 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:
attributeDeclin interfaceorg.xml.sax.ext.DeclHandler
-
-