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

项目:fluentxml4j    文件:AbstractSAXFilter.java   
@Override
public void setResult(Result result) throws IllegalArgumentException
{
    SAXResult saxResult = toSAXResult(result);

    ContentHandler handler = saxResult.getHandler();
    this.nextContentHandler = handler;
    if (handler instanceof LexicalHandler)
    {
        this.nextLexicalHandler = (LexicalHandler) handler;
    }
    if (handler instanceof DTDHandler)
    {
        this.nextDtdHandler = (DTDHandler) handler;
    }

}
项目:spring4-understanding    文件:AbstractStaxXMLReaderTestCase.java   
@Test
public void lexicalHandler() throws Exception {
    Resource testLexicalHandlerXml = new ClassPathResource("testLexicalHandler.xml", getClass());

    LexicalHandler expectedLexicalHandler = mockLexicalHandler();
    standardReader.setContentHandler(null);
    standardReader.setProperty("http://xml.org/sax/properties/lexical-handler", expectedLexicalHandler);
    standardReader.parse(new InputSource(testLexicalHandlerXml.getInputStream()));
    inputFactory.setProperty("javax.xml.stream.isCoalescing", Boolean.FALSE);
    inputFactory.setProperty("http://java.sun.com/xml/stream/properties/report-cdata-event", Boolean.TRUE);
    inputFactory.setProperty("javax.xml.stream.isReplacingEntityReferences", Boolean.FALSE);
    inputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities", Boolean.FALSE);

    LexicalHandler actualLexicalHandler = mockLexicalHandler();
    willAnswer(new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            return invocation.getArguments()[0] = "element";
        }
    }).given(actualLexicalHandler).startDTD(anyString(), anyString(), anyString());
    AbstractStaxXMLReader staxXmlReader = createStaxXmlReader(testLexicalHandlerXml.getInputStream());
    staxXmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", actualLexicalHandler);
    staxXmlReader.parse(new InputSource());

    verifyIdenticalInvocations(expectedLexicalHandler, actualLexicalHandler);
}
项目:ph-stx    文件:DOMDriver.java   
/**
 * <b>SAX2</b>: Assigns the specified property. Like SAX1 handlers, these may
 * be changed at any time.
 */

public void setProperty (final String propertyId, final Object property) throws SAXNotRecognizedException,
                                                                         SAXNotSupportedException
{
  if (propertyId.equals ("http://xml.org/sax/properties/lexical-handler"))
  {
    if (property instanceof LexicalHandler)
    {
      lexicalHandler = (LexicalHandler) property;
    }
    else
    {
      throw new SAXNotSupportedException ("Lexical Handler must be instance of org.xml.sax.ext.LexicalHandler");
    }
  }
  else
  {
    throw new SAXNotRecognizedException (propertyId);
  }
}
项目:OpenJSharp    文件:SAXBufferProcessor.java   
public void setProperty(String name, Object value)
        throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name.equals(Properties.LEXICAL_HANDLER_PROPERTY)) {
        if (value instanceof LexicalHandler) {
            setLexicalHandler((LexicalHandler)value);
        } else {
            throw new SAXNotSupportedException(Properties.LEXICAL_HANDLER_PROPERTY);
        }
    } else {
        throw new SAXNotRecognizedException("Property not recognized: " + name);
    }
}
项目:OpenJSharp    文件:JAXBBridgeSource.java   
public void setProperty(String name, Object value) throws SAXNotRecognizedException {
    if( "http://xml.org/sax/properties/lexical-handler".equals(name) ) {
        this.lexicalHandler = (LexicalHandler)value;
        return;
    }
    throw new SAXNotRecognizedException(name);
}
项目:OpenJSharp    文件:StAXSource.java   
@Override
public void setProperty(String name, Object value) throws SAXNotRecognizedException {
    if( "http://xml.org/sax/properties/lexical-handler".equals(name) ) {
        this.lexicalHandler = (LexicalHandler)value;
        return;
    }
    throw new SAXNotRecognizedException(name);
}
项目:OpenJSharp    文件:SaxSerializer.java   
public SaxSerializer(ContentHandler handler,LexicalHandler lex, boolean indenting) {
    if(!indenting) {
        writer = handler;
        lexical = lex;
    } else {
        IndentingXMLFilter indenter = new IndentingXMLFilter(handler, lex);
        writer = indenter;
        lexical = indenter;
    }
}
项目:OpenJSharp    文件:RejectDoctypeSaxFilter.java   
public void setProperty(String name, Object value)
throws SAXNotRecognizedException, SAXNotSupportedException {
    if (LEXICAL_HANDLER_PROP.equals(name)) {
        lexicalHandler = (LexicalHandler) value;
    } else {
        super.setProperty(name, value);
    }
}
项目:OpenJSharp    文件:JAXBSource.java   
public void setProperty(String name, Object value) throws SAXNotRecognizedException {
    if( "http://xml.org/sax/properties/lexical-handler".equals(name) ) {
        this.lexicalHandler = (LexicalHandler)value;
        return;
    }
    throw new SAXNotRecognizedException(name);
}
项目:OpenJSharp    文件:DOM2SAX.java   
public void setContentHandler(ContentHandler handler) throws
    NullPointerException
{
    _sax = handler;
    if (handler instanceof LexicalHandler) {
        _lex = (LexicalHandler) handler;
    }

    if (handler instanceof SAXImpl) {
        _saxImpl = (SAXImpl)handler;
    }
}
项目:OpenJSharp    文件:StAXEvent2SAX.java   
public void setContentHandler(ContentHandler handler) throws
    NullPointerException
{
    _sax = handler;
    if (handler instanceof LexicalHandler) {
        _lex = (LexicalHandler) handler;
    }

    if (handler instanceof SAXImpl) {
        _saxImpl = (SAXImpl)handler;
    }
}
项目:OpenJSharp    文件:StAXStream2SAX.java   
public void setContentHandler(ContentHandler handler) throws
    NullPointerException
{
    _sax = handler;
    if (handler instanceof LexicalHandler) {
        _lex = (LexicalHandler) handler;
    }

    if (handler instanceof SAXImpl) {
        _saxImpl = (SAXImpl)handler;
    }
}
项目:OpenJSharp    文件:ToXMLSAXHandler.java   
public ToXMLSAXHandler(
    ContentHandler handler,
    LexicalHandler lex,
    String encoding)
{
    super(handler, lex, encoding);

    initCDATA();
    //      initNamespaces();
    m_prefixMap = new NamespaceMappings();
}
项目:OpenJSharp    文件:ToHTMLSAXHandler.java   
/**
 * A constructor.
 * @param handler the wrapped SAX content handler
 * @param lex the wrapped lexical handler
 * @param encoding the encoding of the output HTML document
 */
public ToHTMLSAXHandler(
    ContentHandler handler,
    LexicalHandler lex,
    String encoding)
{
    super(handler,lex,encoding);
}
项目:OpenJSharp    文件:ToSAXHandler.java   
public ToSAXHandler(
    ContentHandler hdlr,
    LexicalHandler lex,
    String encoding)
{
    setContentHandler(hdlr);
    setLexHandler(lex);
    setEncoding(encoding);
}
项目:jdk8u-jdk    文件:XMLKit.java   
public static void output(Object e, ContentHandler ch) throws SAXException {
    if (ch instanceof LexicalHandler) {
        output(e, ch, (LexicalHandler) ch);
    } else {
        output(e, ch, null);
    }
}
项目:openjdk-jdk10    文件:XMLKit.java   
public static void output(Object e, ContentHandler ch) throws SAXException {
    if (ch instanceof LexicalHandler) {
        output(e, ch, (LexicalHandler) ch);
    } else {
        output(e, ch, null);
    }
}
项目:openjdk-jdk10    文件:SAXBufferProcessor.java   
public void setProperty(String name, Object value)
        throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name.equals(Properties.LEXICAL_HANDLER_PROPERTY)) {
        if (value instanceof LexicalHandler) {
            setLexicalHandler((LexicalHandler)value);
        } else {
            throw new SAXNotSupportedException(Properties.LEXICAL_HANDLER_PROPERTY);
        }
    } else {
        throw new SAXNotRecognizedException("Property not recognized: " + name);
    }
}
项目:openjdk-jdk10    文件:JAXBBridgeSource.java   
public void setProperty(String name, Object value) throws SAXNotRecognizedException {
    if( "http://xml.org/sax/properties/lexical-handler".equals(name) ) {
        this.lexicalHandler = (LexicalHandler)value;
        return;
    }
    throw new SAXNotRecognizedException(name);
}
项目:openjdk-jdk10    文件:StAXSource.java   
@Override
public void setProperty(String name, Object value) throws SAXNotRecognizedException {
    if( "http://xml.org/sax/properties/lexical-handler".equals(name) ) {
        this.lexicalHandler = (LexicalHandler)value;
        return;
    }
    throw new SAXNotRecognizedException(name);
}
项目:openjdk-jdk10    文件:RejectDoctypeSaxFilter.java   
@Override
public void setProperty(String name, Object value)
throws SAXNotRecognizedException, SAXNotSupportedException {
    if (LEXICAL_HANDLER_PROP.equals(name)) {
        lexicalHandler = (LexicalHandler) value;
    } else {
        super.setProperty(name, value);
    }
}
项目:openjdk-jdk10    文件:SaxSerializer.java   
public SaxSerializer(ContentHandler handler,LexicalHandler lex, boolean indenting) {
    if(!indenting) {
        writer = handler;
        lexical = lex;
    } else {
        IndentingXMLFilter indenter = new IndentingXMLFilter(handler, lex);
        writer = indenter;
        lexical = indenter;
    }
}
项目:openjdk-jdk10    文件:JAXBSource.java   
public void setProperty(String name, Object value) throws SAXNotRecognizedException {
    if( "http://xml.org/sax/properties/lexical-handler".equals(name) ) {
        this.lexicalHandler = (LexicalHandler)value;
        return;
    }
    throw new SAXNotRecognizedException(name);
}
项目:openjdk-jdk10    文件:DOM2SAX.java   
public void setContentHandler(ContentHandler handler) throws
    NullPointerException
{
    _sax = handler;
    if (handler instanceof LexicalHandler) {
        _lex = (LexicalHandler)handler;
    }

    if (handler instanceof SAXImpl) {
        _saxImpl = (SAXImpl)handler;
    }
}
项目:openjdk-jdk10    文件:StAXEvent2SAX.java   
public void setContentHandler(ContentHandler handler) throws
    NullPointerException
{
    _sax = handler;
    if (handler instanceof LexicalHandler) {
        _lex = (LexicalHandler) handler;
    }

    if (handler instanceof SAXImpl) {
        _saxImpl = (SAXImpl)handler;
    }
}
项目:openjdk-jdk10    文件:StAXStream2SAX.java   
public void setContentHandler(ContentHandler handler) throws
    NullPointerException
{
    _sax = handler;
    if (handler instanceof LexicalHandler) {
        _lex = (LexicalHandler) handler;
    }

    if (handler instanceof SAXImpl) {
        _saxImpl = (SAXImpl)handler;
    }
}
项目:openjdk-jdk10    文件:ToXMLSAXHandler.java   
public ToXMLSAXHandler(
    ContentHandler handler,
    LexicalHandler lex,
    String encoding)
{
    super(handler, lex, encoding);

    initCDATA();
    //      initNamespaces();
    m_prefixMap = new NamespaceMappings();
}
项目:openjdk-jdk10    文件:ToHTMLSAXHandler.java   
/**
 * A constructor.
 * @param handler the wrapped SAX content handler
 * @param lex the wrapped lexical handler
 * @param encoding the encoding of the output HTML document
 */
public ToHTMLSAXHandler(
    ContentHandler handler,
    LexicalHandler lex,
    String encoding)
{
    super(handler,lex,encoding);
}
项目:openjdk-jdk10    文件:SAX2DOMTest.java   
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
    if (LEXICAL_HANDLER_PROP.equals(name)) {
        lexicalHandler = (LexicalHandler) value;
    } else {
        super.setProperty(name, value);
    }
}
项目:openjdk-jdk10    文件:SAXParserTest02.java   
/**
 * Test to set and get the lexical-handler.
 *
 * @param saxparser a SAXParser instance.
 * @throws SAXException If any parse errors occur.
 */
@Test(dataProvider = "parser-provider")
public void testProperty05(SAXParser saxparser) throws SAXException {
    MyLexicalHandler myLexicalHandler = new MyLexicalHandler();
    saxparser.setProperty(LEXICAL_HANDLER, myLexicalHandler);
    assertTrue(saxparser.getProperty(LEXICAL_HANDLER) instanceof LexicalHandler);
}
项目:lookaside_java-1.8.0-openjdk    文件:StAXStream2SAX.java   
public void setContentHandler(ContentHandler handler) throws
    NullPointerException
{
    _sax = handler;
    if (handler instanceof LexicalHandler) {
        _lex = (LexicalHandler) handler;
    }

    if (handler instanceof SAXImpl) {
        _saxImpl = (SAXImpl)handler;
    }
}
项目:openjdk9    文件:XMLKit.java   
public static void output(Object e, ContentHandler ch) throws SAXException {
    if (ch instanceof LexicalHandler) {
        output(e, ch, (LexicalHandler) ch);
    } else {
        output(e, ch, null);
    }
}
项目:openjdk9    文件:SAXBufferProcessor.java   
public void setProperty(String name, Object value)
        throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name.equals(Properties.LEXICAL_HANDLER_PROPERTY)) {
        if (value instanceof LexicalHandler) {
            setLexicalHandler((LexicalHandler)value);
        } else {
            throw new SAXNotSupportedException(Properties.LEXICAL_HANDLER_PROPERTY);
        }
    } else {
        throw new SAXNotRecognizedException("Property not recognized: " + name);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ToSAXHandler.java   
public ToSAXHandler(
    ContentHandler hdlr,
    LexicalHandler lex,
    String encoding)
{
    setContentHandler(hdlr);
    setLexHandler(lex);
    setEncoding(encoding);
}
项目:javify    文件:DomParser.java   
/**
 * <b>SAX2</b>:  Assigns the specified property.  At this time only
 * declaration and lexical handlers, and the initial DOM document, are
 * supported.  These must not be changed to values of the wrong type.
 * Like SAX1 handlers, these handlers may be changed at any time.
 * Like SAX1 input source or document URI, the initial DOM document
 * may not be changed during a parse.
 */
public void setProperty (String name, Object state)
throws SAXNotRecognizedException, SAXNotSupportedException
{
    if ((HANDLERS + "declaration-handler").equals (name)) {
        if (!(state instanceof DeclHandler || state == null))
            throw new SAXNotSupportedException (name);
        declHandler = (DeclHandler) state;
        return;
    }

    if ((HANDLERS + "lexical-handler").equals (name)) {
        if (!(state instanceof LexicalHandler || state == null))
            throw new SAXNotSupportedException (name);
        lexicalHandler = (LexicalHandler) state;
        return;
    }

    if ((HANDLERS + "dom-node").equals (name)) {
        if (state == null || state instanceof Node) {
            if (current != null)
                throw new SAXNotSupportedException (
                    "property is readonly during parse:  " + name);
            setStart ((Node) state);
            return;
        }
        throw new SAXNotSupportedException ("not a DOM Node");
    }

    // unknown properties
    throw new SAXNotRecognizedException (name);
}
项目:openjdk9    文件:StAXSource.java   
@Override
public void setProperty(String name, Object value) throws SAXNotRecognizedException {
    if( "http://xml.org/sax/properties/lexical-handler".equals(name) ) {
        this.lexicalHandler = (LexicalHandler)value;
        return;
    }
    throw new SAXNotRecognizedException(name);
}
项目:openjdk9    文件:RejectDoctypeSaxFilter.java   
public void setProperty(String name, Object value)
throws SAXNotRecognizedException, SAXNotSupportedException {
    if (LEXICAL_HANDLER_PROP.equals(name)) {
        lexicalHandler = (LexicalHandler) value;
    } else {
        super.setProperty(name, value);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ToHTMLSAXHandler.java   
/**
 * A constructor.
 * @param handler the wrapped SAX content handler
 * @param lex the wrapped lexical handler
 * @param encoding the encoding of the output HTML document
 */
public ToHTMLSAXHandler(
    ContentHandler handler,
    LexicalHandler lex,
    String encoding)
{
    super(handler,lex,encoding);
}
项目:openjdk9    文件:SaxSerializer.java   
public SaxSerializer(ContentHandler handler,LexicalHandler lex, boolean indenting) {
    if(!indenting) {
        writer = handler;
        lexical = lex;
    } else {
        IndentingXMLFilter indenter = new IndentingXMLFilter(handler, lex);
        writer = indenter;
        lexical = indenter;
    }
}
项目:openjdk9    文件:JAXBSource.java   
public void setProperty(String name, Object value) throws SAXNotRecognizedException {
    if( "http://xml.org/sax/properties/lexical-handler".equals(name) ) {
        this.lexicalHandler = (LexicalHandler)value;
        return;
    }
    throw new SAXNotRecognizedException(name);
}