org.xml.sax.ext.LexicalHandler Java Examples

The following examples show how to use org.xml.sax.ext.LexicalHandler. 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: XStreamMarshaller.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected void marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
		throws XmlMappingException {

	SaxWriter saxWriter = new SaxWriter(this.nameCoder);
	saxWriter.setContentHandler(contentHandler);
	doMarshal(graph, saxWriter, null);
}
 
Example #2
Source File: ToHTMLSAXHandler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #3
Source File: ToHTMLSAXHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #4
Source File: StAXStream2SAX.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void setContentHandler(ContentHandler handler) throws
    NullPointerException
{
    _sax = handler;
    if (handler instanceof LexicalHandler) {
        _lex = (LexicalHandler) handler;
    }

    if (handler instanceof SAXImpl) {
        _saxImpl = (SAXImpl)handler;
    }
}
 
Example #5
Source File: StAXSource.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #6
Source File: XMLKit.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void output(Object e, ContentHandler ch) throws SAXException {
    if (ch instanceof LexicalHandler) {
        output(e, ch, (LexicalHandler) ch);
    } else {
        output(e, ch, null);
    }
}
 
Example #7
Source File: StAXEvent2SAX.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void setContentHandler(ContentHandler handler) throws
    NullPointerException
{
    _sax = handler;
    if (handler instanceof LexicalHandler) {
        _lex = (LexicalHandler) handler;
    }

    if (handler instanceof SAXImpl) {
        _saxImpl = (SAXImpl)handler;
    }
}
 
Example #8
Source File: ToSAXHandler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ToSAXHandler(
    ContentHandler hdlr,
    LexicalHandler lex,
    String encoding)
{
    setContentHandler(hdlr);
    setLexHandler(lex);
    setEncoding(encoding);
}
 
Example #9
Source File: JAXBBridgeSource.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #10
Source File: SAXBufferProcessor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #11
Source File: XMLKit.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void output(Object e, ContentHandler ch) throws SAXException {
    if (ch instanceof LexicalHandler) {
        output(e, ch, (LexicalHandler) ch);
    } else {
        output(e, ch, null);
    }
}
 
Example #12
Source File: ToSAXHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public ToSAXHandler(
    ContentHandler hdlr,
    LexicalHandler lex,
    String encoding)
{
    setContentHandler(hdlr);
    setLexHandler(lex);
    setEncoding(encoding);
}
 
Example #13
Source File: JibxMarshaller.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected void marshalSaxHandlers(Object graph, ContentHandler contentHandler, @Nullable LexicalHandler lexicalHandler)
		throws XmlMappingException {
	try {
		// JiBX does not support SAX natively, so we write to a buffer first, and transform that to the handlers
		SAXResult saxResult = new SAXResult(contentHandler);
		saxResult.setLexicalHandler(lexicalHandler);
		transformAndMarshal(graph, saxResult);
	}
	catch (IOException ex) {
		throw new MarshallingFailureException("JiBX marshalling exception", ex);
	}
}
 
Example #14
Source File: AbstractXMLReader.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Throws a {@code SAXNotRecognizedException} exception when the given property does not signify a lexical
 * handler. The property name for a lexical handler is {@code http://xml.org/sax/properties/lexical-handler}.
 */
@Override
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
	if ("http://xml.org/sax/properties/lexical-handler".equals(name)) {
		this.lexicalHandler = (LexicalHandler) value;
	}
	else {
		throw new SAXNotRecognizedException(name);
	}
}
 
Example #15
Source File: StAXStream2SAX.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void setContentHandler(ContentHandler handler) throws
    NullPointerException
{
    _sax = handler;
    if (handler instanceof LexicalHandler) {
        _lex = (LexicalHandler) handler;
    }

    if (handler instanceof SAXImpl) {
        _saxImpl = (SAXImpl)handler;
    }
}
 
Example #16
Source File: SAXBufferProcessor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #17
Source File: SAXBufferProcessor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #18
Source File: SAXParserTest02.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #19
Source File: RejectDoctypeSaxFilter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void setProperty(String name, Object value)
throws SAXNotRecognizedException, SAXNotSupportedException {
    if (LEXICAL_HANDLER_PROP.equals(name)) {
        lexicalHandler = (LexicalHandler) value;
    } else {
        super.setProperty(name, value);
    }
}
 
Example #20
Source File: StAXStream2SAX.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void setContentHandler(ContentHandler handler) throws
    NullPointerException
{
    _sax = handler;
    if (handler instanceof LexicalHandler) {
        _lex = (LexicalHandler) handler;
    }

    if (handler instanceof SAXImpl) {
        _saxImpl = (SAXImpl)handler;
    }
}
 
Example #21
Source File: CastorMarshaller.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected void marshalSaxHandlers(Object graph, ContentHandler contentHandler, @Nullable LexicalHandler lexicalHandler)
		throws XmlMappingException {

	Assert.state(this.xmlContext != null, "CastorMarshaller not initialized");
	Marshaller marshaller = this.xmlContext.createMarshaller();
	marshaller.setContentHandler(contentHandler);
	doMarshal(graph, marshaller);
}
 
Example #22
Source File: StAXStream2SAX.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void setContentHandler(ContentHandler handler) throws
    NullPointerException
{
    _sax = handler;
    if (handler instanceof LexicalHandler) {
        _lex = (LexicalHandler) handler;
    }

    if (handler instanceof SAXImpl) {
        _saxImpl = (SAXImpl)handler;
    }
}
 
Example #23
Source File: ToSAXHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public ToSAXHandler(
    ContentHandler hdlr,
    LexicalHandler lex,
    String encoding)
{
    setContentHandler(hdlr);
    setLexHandler(lex);
    setEncoding(encoding);
}
 
Example #24
Source File: DOM2SAX.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setContentHandler(ContentHandler handler) throws
    NullPointerException
{
    _sax = handler;
    if (handler instanceof LexicalHandler) {
        _lex = (LexicalHandler) handler;
    }

    if (handler instanceof SAXImpl) {
        _saxImpl = (SAXImpl)handler;
    }
}
 
Example #25
Source File: StAXSource.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #26
Source File: CastorMarshaller.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected void marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
		throws XmlMappingException {

	Marshaller marshaller = xmlContext.createMarshaller();
	marshaller.setContentHandler(contentHandler);
	doMarshal(graph, marshaller);
}
 
Example #27
Source File: StAXSource.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #28
Source File: ToXMLSAXHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public ToXMLSAXHandler(
    ContentHandler handler,
    LexicalHandler lex,
    String encoding)
{
    super(handler, lex, encoding);

    initCDATA();
    //      initNamespaces();
    m_prefixMap = new NamespaceMappings();
}
 
Example #29
Source File: SAXBufferProcessor.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #30
Source File: XMLKit.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void output(Object e, ContentHandler ch, LexicalHandler lh) throws SAXException {
    new Outputter(ch, lh).output(e);
}