本文整理汇总了Java中org.xml.sax.ext.LexicalHandler类的典型用法代码示例。如果您正苦于以下问题:Java LexicalHandler类的具体用法?Java LexicalHandler怎么用?Java LexicalHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LexicalHandler类属于org.xml.sax.ext包,在下文中一共展示了LexicalHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setResult
import org.xml.sax.ext.LexicalHandler; //导入依赖的package包/类
@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;
}
}
示例2: lexicalHandler
import org.xml.sax.ext.LexicalHandler; //导入依赖的package包/类
@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);
}
示例3: setProperty
import org.xml.sax.ext.LexicalHandler; //导入依赖的package包/类
/**
* <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);
}
}
示例4: setProperty
import org.xml.sax.ext.LexicalHandler; //导入依赖的package包/类
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);
}
}
示例5: setProperty
import org.xml.sax.ext.LexicalHandler; //导入依赖的package包/类
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);
}
示例6: setProperty
import org.xml.sax.ext.LexicalHandler; //导入依赖的package包/类
@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);
}
示例7: SaxSerializer
import org.xml.sax.ext.LexicalHandler; //导入依赖的package包/类
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;
}
}
示例8: setProperty
import org.xml.sax.ext.LexicalHandler; //导入依赖的package包/类
public void setProperty(String name, Object value)
throws SAXNotRecognizedException, SAXNotSupportedException {
if (LEXICAL_HANDLER_PROP.equals(name)) {
lexicalHandler = (LexicalHandler) value;
} else {
super.setProperty(name, value);
}
}
示例9: setContentHandler
import org.xml.sax.ext.LexicalHandler; //导入依赖的package包/类
public void setContentHandler(ContentHandler handler) throws
NullPointerException
{
_sax = handler;
if (handler instanceof LexicalHandler) {
_lex = (LexicalHandler) handler;
}
if (handler instanceof SAXImpl) {
_saxImpl = (SAXImpl)handler;
}
}
示例10: ToXMLSAXHandler
import org.xml.sax.ext.LexicalHandler; //导入依赖的package包/类
public ToXMLSAXHandler(
ContentHandler handler,
LexicalHandler lex,
String encoding)
{
super(handler, lex, encoding);
initCDATA();
// initNamespaces();
m_prefixMap = new NamespaceMappings();
}
示例11: ToHTMLSAXHandler
import org.xml.sax.ext.LexicalHandler; //导入依赖的package包/类
/**
* 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);
}
示例12: ToSAXHandler
import org.xml.sax.ext.LexicalHandler; //导入依赖的package包/类
public ToSAXHandler(
ContentHandler hdlr,
LexicalHandler lex,
String encoding)
{
setContentHandler(hdlr);
setLexHandler(lex);
setEncoding(encoding);
}
示例13: output
import org.xml.sax.ext.LexicalHandler; //导入依赖的package包/类
public static void output(Object e, ContentHandler ch) throws SAXException {
if (ch instanceof LexicalHandler) {
output(e, ch, (LexicalHandler) ch);
} else {
output(e, ch, null);
}
}
示例14: setProperty
import org.xml.sax.ext.LexicalHandler; //导入依赖的package包/类
@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);
}
}
示例15: setContentHandler
import org.xml.sax.ext.LexicalHandler; //导入依赖的package包/类
public void setContentHandler(ContentHandler handler) throws
NullPointerException
{
_sax = handler;
if (handler instanceof LexicalHandler) {
_lex = (LexicalHandler)handler;
}
if (handler instanceof SAXImpl) {
_saxImpl = (SAXImpl)handler;
}
}