Class 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.
      • Methods inherited from class org.xml.sax.helpers.DefaultHandler

        endPrefixMapping, error, notationDecl, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 is File.
      • 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 interface org.xml.sax.EntityResolver
        Overrides:
        resolveEntity in class org.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 interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class org.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 interface org.xml.sax.ContentHandler
        Overrides:
        endElement in class org.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 interface org.xml.sax.ContentHandler
        Overrides:
        characters in class org.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 interface org.xml.sax.ContentHandler
        Overrides:
        ignorableWhitespace in class org.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 interface org.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 interface org.xml.sax.ContentHandler
        Overrides:
        processingInstruction in class org.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 interface org.xml.sax.ContentHandler
        Overrides:
        startDocument in class org.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 interface org.xml.sax.ContentHandler
        Overrides:
        endDocument in class org.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 interface org.xml.sax.ErrorHandler
        Overrides:
        fatalError in class org.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 interface org.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 interface org.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 interface org.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 interface org.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 interface org.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 interface org.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 interface org.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 interface org.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 interface org.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 interface org.xml.sax.ext.DeclHandler