Java Code Examples for org.xml.sax.ext.LexicalHandler

The following examples show how to use org.xml.sax.ext.LexicalHandler. These examples are extracted from open source projects. 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 Project: spring-analysis-note   Source File: JibxMarshaller.java    License: 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 2
Source Project: openjdk-jdk8u   Source File: XMLKit.java    License: 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 3
/**
 * 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 Project: jdk1.8-source-analysis   Source File: StAXEvent2SAX.java    License: 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 Project: jdk1.8-source-analysis   Source File: StAXStream2SAX.java    License: 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 6
Source Project: openjdk-8-source   Source File: XMLKit.java    License: 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 Project: hottub   Source File: StAXStream2SAX.java    License: 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 8
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 9
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 10
public void setContentHandler(ContentHandler handler) throws
    NullPointerException
{
    _sax = handler;
    if (handler instanceof LexicalHandler) {
        _lex = (LexicalHandler) handler;
    }

    if (handler instanceof SAXImpl) {
        _saxImpl = (SAXImpl)handler;
    }
}
 
Example 11
Source Project: openjdk-8   Source File: StAXSource.java    License: 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 12
Source Project: jdk8u60   Source File: StAXSource.java    License: 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 13
Source Project: openjdk-8   Source File: DOM2SAX.java    License: 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 14
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 15
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 16
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 17
Source Project: openjdk-8-source   Source File: StAXSource.java    License: 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 18
Source Project: spring4-understanding   Source File: XStreamMarshaller.java    License: 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 19
Source Project: openjdk-8   Source File: ToXMLSAXHandler.java    License: 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 20
Source Project: spring4-understanding   Source File: CastorMarshaller.java    License: 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 21
Source Project: hottub   Source File: ToSAXHandler.java    License: 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 22
Source Project: openjdk-jdk9   Source File: StAXStream2SAX.java    License: 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 Project: java-technology-stack   Source File: CastorMarshaller.java    License: 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 24
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 25
Source Project: openjdk-jdk9   Source File: SAXParserTest02.java    License: 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 26
/**
 * 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 27
Source Project: TencentKona-8   Source File: ToSAXHandler.java    License: 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 28
public ToSAXHandler(
    ContentHandler hdlr,
    LexicalHandler lex,
    String encoding)
{
    setContentHandler(hdlr);
    setLexHandler(lex);
    setEncoding(encoding);
}
 
Example 29
Source Project: java-technology-stack   Source File: AbstractXMLReader.java    License: 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 30
Source Project: spring-analysis-note   Source File: StaxResult.java    License: MIT License 4 votes vote down vote up
/**
 * Throws an {@code UnsupportedOperationException}.
 * @throws UnsupportedOperationException always
 */
@Override
public void setLexicalHandler(LexicalHandler handler) {
	throw new UnsupportedOperationException("setLexicalHandler is not supported");
}