org.xml.sax.ext.Locator2 Java Examples

The following examples show how to use org.xml.sax.ext.Locator2. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StAXStream2SAX.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument() throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return staxStreamReader.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return staxStreamReader.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return staxStreamReader.getLocation().getPublicId();
        }
        public String getSystemId() {
            return staxStreamReader.getLocation().getSystemId();
        }
        public String getXMLVersion() {
            return staxStreamReader.getVersion();
        }
        public String getEncoding() {
            return staxStreamReader.getEncoding();
        }
     });
    _sax.startDocument();
}
 
Example #2
Source File: StAXStream2SAX.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument() throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return staxStreamReader.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return staxStreamReader.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return staxStreamReader.getLocation().getPublicId();
        }
        public String getSystemId() {
            return staxStreamReader.getLocation().getSystemId();
        }
        public String getXMLVersion() {
            return staxStreamReader.getVersion();
        }
        public String getEncoding() {
            return staxStreamReader.getEncoding();
        }
     });
    _sax.startDocument();
}
 
Example #3
Source File: StAXStream2SAX.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument() throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return staxStreamReader.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return staxStreamReader.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return staxStreamReader.getLocation().getPublicId();
        }
        public String getSystemId() {
            return staxStreamReader.getLocation().getSystemId();
        }
        public String getXMLVersion() {
            return staxStreamReader.getVersion();
        }
        public String getEncoding() {
            return staxStreamReader.getEncoding();
        }
     });
    _sax.startDocument();
}
 
Example #4
Source File: StAXEvent2SAX.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument(final XMLEvent event) throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return event.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return event.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return event.getLocation().getPublicId();
        }
        public String getSystemId() {
            return event.getLocation().getSystemId();
        }
        public String getXMLVersion(){
            return version;
        }
        public String getEncoding(){
            return encoding;
        }

    });
    _sax.startDocument();
}
 
Example #5
Source File: StAXStream2SAX.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument() throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return staxStreamReader.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return staxStreamReader.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return staxStreamReader.getLocation().getPublicId();
        }
        public String getSystemId() {
            return staxStreamReader.getLocation().getSystemId();
        }
        public String getXMLVersion() {
            return staxStreamReader.getVersion();
        }
        public String getEncoding() {
            return staxStreamReader.getEncoding();
        }
     });
    _sax.startDocument();
}
 
Example #6
Source File: StAXStream2SAX.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument() throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return staxStreamReader.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return staxStreamReader.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return staxStreamReader.getLocation().getPublicId();
        }
        public String getSystemId() {
            return staxStreamReader.getLocation().getSystemId();
        }
        public String getXMLVersion() {
            return staxStreamReader.getVersion();
        }
        public String getEncoding() {
            return staxStreamReader.getEncoding();
        }
     });
    _sax.startDocument();
}
 
Example #7
Source File: StAXStream2SAX.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument() throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return staxStreamReader.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return staxStreamReader.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return staxStreamReader.getLocation().getPublicId();
        }
        public String getSystemId() {
            return staxStreamReader.getLocation().getSystemId();
        }
        public String getXMLVersion() {
            return staxStreamReader.getVersion();
        }
        public String getEncoding() {
            return staxStreamReader.getEncoding();
        }
     });
    _sax.startDocument();
}
 
Example #8
Source File: StAXStream2SAX.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private void handleStartDocument() throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return staxStreamReader.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return staxStreamReader.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return staxStreamReader.getLocation().getPublicId();
        }
        public String getSystemId() {
            return staxStreamReader.getLocation().getSystemId();
        }
        public String getXMLVersion() {
            return staxStreamReader.getVersion();
        }
        public String getEncoding() {
            return staxStreamReader.getEncoding();
        }
     });
    _sax.startDocument();
}
 
Example #9
Source File: StAXEvent2SAX.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private void handleStartDocument(final XMLEvent event) throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return event.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return event.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return event.getLocation().getPublicId();
        }
        public String getSystemId() {
            return event.getLocation().getSystemId();
        }
        public String getXMLVersion(){
            return version;
        }
        public String getEncoding(){
            return encoding;
        }

    });
    _sax.startDocument();
}
 
Example #10
Source File: StAXEvent2SAX.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument(final XMLEvent event) throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return event.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return event.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return event.getLocation().getPublicId();
        }
        public String getSystemId() {
            return event.getLocation().getSystemId();
        }
        public String getXMLVersion(){
            return version;
        }
        public String getEncoding(){
            return encoding;
        }

    });
    _sax.startDocument();
}
 
Example #11
Source File: StAXEvent2SAX.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument(final XMLEvent event) throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return event.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return event.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return event.getLocation().getPublicId();
        }
        public String getSystemId() {
            return event.getLocation().getSystemId();
        }
        public String getXMLVersion(){
            return version;
        }
        public String getEncoding(){
            return encoding;
        }

    });
    _sax.startDocument();
}
 
Example #12
Source File: StAXEvent2SAX.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument(final XMLEvent event) throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return event.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return event.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return event.getLocation().getPublicId();
        }
        public String getSystemId() {
            return event.getLocation().getSystemId();
        }
        public String getXMLVersion(){
            return version;
        }
        public String getEncoding(){
            return encoding;
        }

    });
    _sax.startDocument();
}
 
Example #13
Source File: StAXEvent2SAX.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument(final XMLEvent event) throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return event.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return event.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return event.getLocation().getPublicId();
        }
        public String getSystemId() {
            return event.getLocation().getSystemId();
        }
        public String getXMLVersion(){
            return version;
        }
        public String getEncoding(){
            return encoding;
        }

    });
    _sax.startDocument();
}
 
Example #14
Source File: StAXEvent2SAX.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private void handleStartDocument(final XMLEvent event) throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return event.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return event.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return event.getLocation().getPublicId();
        }
        public String getSystemId() {
            return event.getLocation().getSystemId();
        }
        public String getXMLVersion(){
            return version;
        }
        public String getEncoding(){
            return encoding;
        }

    });
    _sax.startDocument();
}
 
Example #15
Source File: StAXStream2SAX.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument() throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return staxStreamReader.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return staxStreamReader.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return staxStreamReader.getLocation().getPublicId();
        }
        public String getSystemId() {
            return staxStreamReader.getLocation().getSystemId();
        }
        public String getXMLVersion() {
            return staxStreamReader.getVersion();
        }
        public String getEncoding() {
            return staxStreamReader.getEncoding();
        }
     });
    _sax.startDocument();
}
 
Example #16
Source File: StAXEvent2SAX.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument(final XMLEvent event) throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return event.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return event.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return event.getLocation().getPublicId();
        }
        public String getSystemId() {
            return event.getLocation().getSystemId();
        }
        public String getXMLVersion(){
            return version;
        }
        public String getEncoding(){
            return encoding;
        }

    });
    _sax.startDocument();
}
 
Example #17
Source File: PositionalXmlHandlerTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartElement() throws SAXException {
  handler.startDocument();
  Locator2 locator = Mockito.mock(Locator2.class);
  handler.setDocumentLocator(locator);
  Mockito.when(locator.getLineNumber()).thenReturn(1);
  Mockito.when(locator.getColumnNumber()).thenReturn(7);
  handler.startElement("", "", "element", new AttributesImpl());
  
  assertEquals(1, handler.getElementStack().size());
  
  Element element = handler.getElementStack().pop();
  DocumentLocation location = (DocumentLocation) element.getUserData("location");
  assertEquals(1, location.getLineNumber());
  assertEquals(7, location.getColumnNumber());
}
 
Example #18
Source File: PositionalXmlHandlerTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testEndElement() throws SAXException {
  handler.startDocument();
  Locator2 locator = Mockito.mock(Locator2.class);
  handler.setDocumentLocator(locator);
  Mockito.when(locator.getLineNumber()).thenReturn(1);
  Mockito.when(locator.getColumnNumber()).thenReturn(7);
  handler.startElement("", "", "element", new AttributesImpl());
  
  assertEquals(1, handler.getElementStack().size());
  
  Mockito.when(locator.getEncoding()).thenReturn("UTF-8");
  handler.endElement("", "", "element");
  
  assertEquals(0, handler.getElementStack().size());
  
  Document document = handler.getDocument();
  Node node = document.getDocumentElement();
  DocumentLocation location = (DocumentLocation) node.getUserData("location");
  assertEquals(1, location.getLineNumber());
  assertEquals(7, location.getColumnNumber());
}
 
Example #19
Source File: PositionalXmlHandlerTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testAddText() throws SAXException {
  char[] test = "test".toCharArray();
  
  handler.startDocument();
  Locator2 locator = Mockito.mock(Locator2.class);
  handler.setDocumentLocator(locator);
  Mockito.when(locator.getLineNumber()).thenReturn(1);
  Mockito.when(locator.getColumnNumber()).thenReturn(7);
  handler.startElement("", "", "element", new AttributesImpl());
  
  handler.characters(test, 0, test.length);
  handler.addText();
  
  Stack<Element> elements = handler.getElementStack();
  Node parent = elements.pop();
  NodeList childNodes = parent.getChildNodes();
  assertEquals(1, childNodes.getLength());
  assertEquals("test", childNodes.item(0).getTextContent());
}
 
Example #20
Source File: StAXStream2SAX.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument() throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return staxStreamReader.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return staxStreamReader.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return staxStreamReader.getLocation().getPublicId();
        }
        public String getSystemId() {
            return staxStreamReader.getLocation().getSystemId();
        }
        public String getXMLVersion() {
            return staxStreamReader.getVersion();
        }
        public String getEncoding() {
            return staxStreamReader.getEncoding();
        }
     });
    _sax.startDocument();
}
 
Example #21
Source File: StAXEvent2SAX.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument(final XMLEvent event) throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return event.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return event.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return event.getLocation().getPublicId();
        }
        public String getSystemId() {
            return event.getLocation().getSystemId();
        }
        public String getXMLVersion(){
            return version;
        }
        public String getEncoding(){
            return encoding;
        }

    });
    _sax.startDocument();
}
 
Example #22
Source File: StAXEvent2SAX.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private void handleStartDocument(final XMLEvent event) throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return event.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return event.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return event.getLocation().getPublicId();
        }
        public String getSystemId() {
            return event.getLocation().getSystemId();
        }
        public String getXMLVersion(){
            return version;
        }
        public String getEncoding(){
            return encoding;
        }

    });
    _sax.startDocument();
}
 
Example #23
Source File: StAXStream2SAX.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private void handleStartDocument() throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return staxStreamReader.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return staxStreamReader.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return staxStreamReader.getLocation().getPublicId();
        }
        public String getSystemId() {
            return staxStreamReader.getLocation().getSystemId();
        }
        public String getXMLVersion() {
            return staxStreamReader.getVersion();
        }
        public String getEncoding() {
            return staxStreamReader.getEncoding();
        }
     });
    _sax.startDocument();
}
 
Example #24
Source File: StAXStream2SAX.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private void handleStartDocument() throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return staxStreamReader.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return staxStreamReader.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return staxStreamReader.getLocation().getPublicId();
        }
        public String getSystemId() {
            return staxStreamReader.getLocation().getSystemId();
        }
        public String getXMLVersion() {
            return staxStreamReader.getVersion();
        }
        public String getEncoding() {
            return staxStreamReader.getEncoding();
        }
     });
    _sax.startDocument();
}
 
Example #25
Source File: StAXEvent2SAX.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void handleStartDocument(final XMLEvent event) throws SAXException {
    _sax.setDocumentLocator(new Locator2() {
        public int getColumnNumber() {
            return event.getLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return event.getLocation().getLineNumber();
        }
        public String getPublicId() {
            return event.getLocation().getPublicId();
        }
        public String getSystemId() {
            return event.getLocation().getSystemId();
        }
        public String getXMLVersion(){
            return version;
        }
        public String getEncoding(){
            return encoding;
        }

    });
    _sax.startDocument();
}
 
Example #26
Source File: SAX2DOM.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void setDocumentInfo() {
    //try to set document version
    if (locator == null) return;
    try{
        _document.setXmlVersion(((Locator2)locator).getXMLVersion());
    }catch(ClassCastException e){}

}
 
Example #27
Source File: Digester.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Process notification of the beginning of the document being reached.
 *
 * @exception SAXException if a parsing error is to be reported
 */
@SuppressWarnings("deprecation")
@Override
public void startDocument() throws SAXException {

    if (saxLog.isDebugEnabled()) {
        saxLog.debug("startDocument()");
    }

    if (locator instanceof Locator2) {
        if (root instanceof DocumentProperties.Charset) {
            String enc = ((Locator2) locator).getEncoding();
            if (enc != null) {
                try {
                    ((DocumentProperties.Charset) root).setCharset(B2CConverter.getCharset(enc));
                } catch (UnsupportedEncodingException e) {
                    log.warn(sm.getString("disgester.encodingInvalid", enc), e);
                }
            }
        } else if (root instanceof DocumentProperties.Encoding) {
            ((DocumentProperties.Encoding) root).setEncoding(((Locator2) locator).getEncoding());
        }
    }

    // ensure that the digester is properly configured, as
    // the digester could be used as a SAX ContentHandler
    // rather than via the parse() methods.
    configure();
}
 
Example #28
Source File: SerializerBase.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected void setDocumentInfo() {
    if (m_locator == null)
            return;
    try{
        String strVersion = ((Locator2)m_locator).getXMLVersion();
        if (strVersion != null)
            setVersion(strVersion);
        /*String strEncoding = ((Locator2)m_locator).getEncoding();
        if (strEncoding != null)
            setEncoding(strEncoding); */

    }catch(ClassCastException e){}
}
 
Example #29
Source File: SerializerBase.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected void setDocumentInfo() {
    if (m_locator == null)
            return;
    try{
        String strVersion = ((Locator2)m_locator).getXMLVersion();
        if (strVersion != null)
            setVersion(strVersion);
        /*String strEncoding = ((Locator2)m_locator).getEncoding();
        if (strEncoding != null)
            setEncoding(strEncoding); */

    }catch(ClassCastException e){}
}
 
Example #30
Source File: SerializerBase.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
protected void setDocumentInfo() {
    if (m_locator == null)
            return;
    try{
        String strVersion = ((Locator2)m_locator).getXMLVersion();
        if (strVersion != null)
            setVersion(strVersion);
        /*String strEncoding = ((Locator2)m_locator).getEncoding();
        if (strEncoding != null)
            setEncoding(strEncoding); */

    }catch(ClassCastException e){}
}