Java 类org.xml.sax.ext.Locator2 实例源码

项目:OpenJSharp    文件:StAXEvent2SAX.java   
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();
}
项目:OpenJSharp    文件:StAXStream2SAX.java   
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();
}
项目:openjdk-jdk10    文件:StAXEvent2SAX.java   
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();
}
项目:openjdk-jdk10    文件:StAXStream2SAX.java   
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();
}
项目:openjdk9    文件:StAXEvent2SAX.java   
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();
}
项目:openjdk9    文件:StAXStream2SAX.java   
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();
}
项目:google-cloud-eclipse    文件:PositionalXmlHandlerTest.java   
@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());
}
项目:google-cloud-eclipse    文件:PositionalXmlHandlerTest.java   
@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());
}
项目:google-cloud-eclipse    文件:PositionalXmlHandlerTest.java   
@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());
}
项目:lookaside_java-1.8.0-openjdk    文件:StAXEvent2SAX.java   
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();
}
项目:lookaside_java-1.8.0-openjdk    文件:StAXStream2SAX.java   
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();
}
项目:infobip-open-jdk-8    文件:StAXEvent2SAX.java   
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();
}
项目:infobip-open-jdk-8    文件:StAXStream2SAX.java   
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();
}
项目:OLD-OpenJDK8    文件:StAXEvent2SAX.java   
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();
}
项目:OLD-OpenJDK8    文件:StAXStream2SAX.java   
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();
}
项目:openjdk-icedtea7    文件:StAXEvent2SAX.java   
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();
}
项目:openjdk-icedtea7    文件:StAXStream2SAX.java   
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();
}
项目:OpenJSharp    文件:SAX2DOM.java   
private void setDocumentInfo() {
    //try to set document version
    if (locator == null) return;
    try{
        _document.setXmlVersion(((Locator2)locator).getXMLVersion());
    }catch(ClassCastException e){}

}
项目:OpenJSharp    文件:SerializerBase.java   
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){}
}
项目:openjdk-jdk10    文件:SAX2DOM.java   
private void setDocumentInfo() {
    //try to set document version
    if (locator == null) return;
    try{
        _document.setXmlVersion(((Locator2)locator).getXMLVersion());
    }catch(ClassCastException e){}

}
项目:openjdk-jdk10    文件:SerializerBase.java   
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){}
}
项目:openjdk9    文件:SAX2DOM.java   
private void setDocumentInfo() {
    //try to set document version
    if (locator == null) return;
    try{
        _document.setXmlVersion(((Locator2)locator).getXMLVersion());
    }catch(ClassCastException e){}

}
项目:openjdk9    文件:SerializerBase.java   
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){}
}
项目:lookaside_java-1.8.0-openjdk    文件:SAX2DOM.java   
private void setDocumentInfo() {
    //try to set document version
    if (locator == null) return;
    try{
        _document.setXmlVersion(((Locator2)locator).getXMLVersion());
    }catch(ClassCastException e){}

}
项目:lookaside_java-1.8.0-openjdk    文件:SerializerBase.java   
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){}
}
项目:infobip-open-jdk-8    文件:SAX2DOM.java   
private void setDocumentInfo() {
    //try to set document version
    if (locator == null) return;
    try{
        _document.setXmlVersion(((Locator2)locator).getXMLVersion());
    }catch(ClassCastException e){}

}
项目:infobip-open-jdk-8    文件:SerializerBase.java   
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){}
}
项目:Lucee    文件:RSSHandler.java   
@Override
public void setDocumentLocator(Locator locator) { 
      if (locator instanceof Locator2) {
        Locator2 locator2 = (Locator2) locator;
        properties.setEL("encoding", locator2.getEncoding());
      } 
    }
项目:Lucee    文件:FeedHandler.java   
@Override
public void setDocumentLocator(Locator locator) { 
    if (locator instanceof Locator2) {
        Locator2 locator2 = (Locator2) locator;
        root.put("encoding", locator2.getEncoding());
    } 
}
项目:ph-commons    文件:MicroSAXHandler.java   
public void setDocumentLocator (@Nullable final Locator aLocator)
{
  if (m_bTrackPosition)
  {
    m_aLocator = aLocator;
    _updatePosition ("setLocator");
    if (aLocator instanceof Locator2)
    {
      m_sSourceXMLVersion = ((Locator2) aLocator).getXMLVersion ();
      m_sSourceXMLEncoding = ((Locator2) aLocator).getEncoding ();
    }
  }
}
项目:class-guard    文件:StaxEventXMLReader.java   
private void handleStartDocument(final XMLEvent event) throws SAXException {
    if (event.isStartDocument()) {
        StartDocument startDocument = (StartDocument) event;
        String xmlVersion = startDocument.getVersion();
        if (StringUtils.hasLength(xmlVersion)) {
            this.xmlVersion = xmlVersion;
        }
        if (startDocument.encodingSet()) {
            this.encoding = startDocument.getCharacterEncodingScheme();
        }
    }
    if (getContentHandler() != null) {
        final Location location = event.getLocation();
        getContentHandler().setDocumentLocator(new Locator2() {
            public int getColumnNumber() {
                return (location != null ? location.getColumnNumber() : -1);
            }
            public int getLineNumber() {
                return (location != null ? location.getLineNumber() : -1);
            }
            public String getPublicId() {
                return (location != null ? location.getPublicId() : null);
            }
            public String getSystemId() {
                return (location != null ? location.getSystemId() : null);
            }
            public String getXMLVersion() {
                return xmlVersion;
            }
            public String getEncoding() {
                return encoding;
            }
        });
        getContentHandler().startDocument();
    }
}
项目:class-guard    文件:StaxStreamXMLReader.java   
private void handleStartDocument() throws SAXException {
    if (XMLStreamConstants.START_DOCUMENT == this.reader.getEventType()) {
        String xmlVersion = this.reader.getVersion();
        if (StringUtils.hasLength(xmlVersion)) {
            this.xmlVersion = xmlVersion;
        }
        this.encoding = this.reader.getCharacterEncodingScheme();
    }
    if (getContentHandler() != null) {
        final Location location = this.reader.getLocation();
        getContentHandler().setDocumentLocator(new Locator2() {
            public int getColumnNumber() {
                return (location != null ? location.getColumnNumber() : -1);
            }
            public int getLineNumber() {
                return (location != null ? location.getLineNumber() : -1);
            }
            public String getPublicId() {
                return (location != null ? location.getPublicId() : null);
            }
            public String getSystemId() {
                return (location != null ? location.getSystemId() : null);
            }
            public String getXMLVersion() {
                return xmlVersion;
            }
            public String getEncoding() {
                return encoding;
            }
        });
        getContentHandler().startDocument();
        if (this.reader.standaloneSet()) {
            setStandalone(this.reader.isStandalone());
        }
    }
}
项目:OLD-OpenJDK8    文件:SAX2DOM.java   
private void setDocumentInfo() {
    //try to set document version
    if (locator == null) return;
    try{
        _document.setXmlVersion(((Locator2)locator).getXMLVersion());
    }catch(ClassCastException e){}

}
项目:OLD-OpenJDK8    文件:SerializerBase.java   
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){}
}
项目:epubcheck-web    文件:DocumentLocatorImpl.java   
public DocumentLocatorImpl(Locator locator)
{
  this.locator = locator;
  if (locator instanceof Locator2)
  {
    locator2 = (Locator2) locator;
  }
}
项目:jhove2    文件:SaxParserContentHandler.java   
/**
 * Receive a Locator object for document events.
 */
@Override
public void setDocumentLocator(Locator locator) {
    this.locator = locator;
    if (locator instanceof Locator2) {
        this.locator2 = (Locator2) locator;
    }
}
项目:openjdk-icedtea7    文件:SAX2DOM.java   
private void setDocumentInfo() {
    //try to set document version
    if (locator == null) return;
    try{
        _document.setXmlVersion(((Locator2)locator).getXMLVersion());
    }catch(ClassCastException e){}

}
项目:openjdk-icedtea7    文件:SerializerBase.java   
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){}
}
项目:FastInfoset    文件:SAX_FI_Encoder.java   
private void encodeHeader() throws IOException {
    encodeHeader((locator instanceof Locator2)?((Locator2)locator).getEncoding():null,
            isStandAlone,
            (locator instanceof Locator2)?((Locator2)locator).getXMLVersion():null,
            unparsedEntities, notations
            );

}
项目:OpenJSharp    文件:SAXLocatorWrapper.java   
public void setLocator(Locator locator) {
    fLocator = locator;
    if (locator instanceof Locator2 || locator == null) {
        fLocator2 = (Locator2) locator;
    }
}