本文整理汇总了Java中org.xml.sax.ext.DeclHandler类的典型用法代码示例。如果您正苦于以下问题:Java DeclHandler类的具体用法?Java DeclHandler怎么用?Java DeclHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DeclHandler类属于org.xml.sax.ext包,在下文中一共展示了DeclHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testProperty06
import org.xml.sax.ext.DeclHandler; //导入依赖的package包/类
/**
* Test to set and get the declaration-handler.
*
* @param saxparser a SAXParser instance.
* @throws SAXException If any parse errors occur.
*/
@Test(dataProvider = "parser-provider")
public void testProperty06(SAXParser saxparser) throws SAXException {
MyDeclHandler myDeclHandler = new MyDeclHandler();
saxparser.setProperty(DECL_HANDLER, myDeclHandler);
assertTrue(saxparser.getProperty(DECL_HANDLER) instanceof DeclHandler);
}
示例2: DocTypeTextLexicalHandler
import org.xml.sax.ext.DeclHandler; //导入依赖的package包/类
public DocTypeTextLexicalHandler(DeclHandler dh) throws SAXException {
// this.dh = dh;
xmlReader = XMLReaderFactory.createXMLReader();
// xmlReader.setProperty(
// "http://xml.org/sax/properties/lexical-handler",
// lh);
// DTD
xmlReader.setFeature(
"http://xml.org/sax/features/resolve-dtd-uris", false);
// *skip* resolving entities like DTDs
xmlReader.setEntityResolver(new NoEntityResolver());
xmlReader.setProperty(
"http://xml.org/sax/properties/declaration-handler", dh);
}
示例3: _setProperty
import org.xml.sax.ext.DeclHandler; //导入依赖的package包/类
protected boolean _setProperty(String name, Object value) throws SAXNotSupportedException{
if(LEXICAL_HANDLER.equals(name) || LEXICAL_HANDLER_ALT.equals(name)){
if(value==null || value instanceof LexicalHandler){
handler.setLexicalHandler((LexicalHandler)value);
return true;
}else
throw new SAXNotSupportedException("value must implement "+LexicalHandler.class);
}else if(DECL_HANDLER.equals(name) || DECL_HANDLER_ALT.equals(name)){
if(value==null || value instanceof DeclHandler){
handler.setDeclHandler((DeclHandler)value);
return true;
}else
throw new SAXNotSupportedException("value must implement "+DeclHandler.class);
}else
return false;
}
示例4: setProperty
import org.xml.sax.ext.DeclHandler; //导入依赖的package包/类
@Override
public void setProperty(String name, Object value)
throws SAXNotRecognizedException, SAXNotSupportedException
{
SAXProperty prop = SAXProperty.findByUri(name);
if (prop == SAXProperty.DECLARATION_HANDLER) {
mDeclHandler = (DeclHandler) value;
return;
} else if (prop == SAXProperty.DOCUMENT_XML_VERSION) {
; // read-only
} else if (prop == SAXProperty.DOM_NODE) {
; // read-only
} else if (prop == SAXProperty.LEXICAL_HANDLER) {
mLexicalHandler = (LexicalHandler) value;
return;
} else if (prop == SAXProperty.XML_STRING) {
; // read-only
} else {
throw new SAXNotRecognizedException("Property '"+name+"' not recognized");
}
// Trying to modify read-only properties?
throw new SAXNotSupportedException("Property '"+name+"' is read-only, can not be modified");
}
示例5: externalEntityDecl
import org.xml.sax.ext.DeclHandler; //导入依赖的package包/类
public void externalEntityDecl(String name, String publicId, String systemId)
throws SAXException
{
if (validatorDeclHandlers.size() > 0)
{
for (DeclHandler h : this.validatorDeclHandlers)
{
h.externalEntityDecl(name, publicId, systemId);
}
}
if (context.version == EPUBVersion.VERSION_3)
{
report.message(MessageId.HTM_003,
EPUBLocation.create(path, getLineNumber(), getColumnNumber(), name), name);
return;
}
entities.add(name);
}
示例6: setProperty
import org.xml.sax.ext.DeclHandler; //导入依赖的package包/类
/**
* Set the property of a value on the underlying XMLReader.
*/
@Override
public void setProperty (final String prop, final Object value) throws SAXNotRecognizedException,
SAXNotSupportedException
{
if ((PROP_PREFIX + "lexical-handler").equals (prop))
setLexicalHandler ((LexicalHandler) value);
else
if ((PROP_PREFIX + "declaration-handler").equals (prop))
setDeclHandler ((DeclHandler) value);
else
super.setProperty (prop, value);
}
示例7: setProperty
import org.xml.sax.ext.DeclHandler; //导入依赖的package包/类
public void setProperty(String name, Object value)
throws SAXNotRecognizedException, SAXNotSupportedException
{
if (parser != null)
throw new IllegalStateException("parsing in progress");
final String FEATURES = "http://xml.org/sax/features/";
final String PROPERTIES = "http://xml.org/sax/properties/";
final String GNU_FEATURES = "http://gnu.org/sax/features/";
if ((FEATURES + "namespaces").equals(name))
namespaceAware = Boolean.TRUE.equals(value);
else if ((FEATURES + "namespace-prefixes").equals(name))
{
// NOOP
}
else if ((FEATURES + "string-interning").equals(name))
stringInterning = Boolean.TRUE.equals(value);
else if ((FEATURES + "use-attributes2").equals(name))
{
// NOOP
}
else if ((FEATURES + "validation").equals(name))
validating = Boolean.TRUE.equals(value);
else if ((FEATURES + "external-general-entities").equals(name))
externalEntities = Boolean.TRUE.equals(value);
else if ((FEATURES + "external-parameter-entities").equals(name))
externalEntities = Boolean.TRUE.equals(value);
else if ((PROPERTIES + "declaration-handler").equals(name))
declHandler = (DeclHandler) value;
else if ((PROPERTIES + "lexical-handler").equals(name))
lexicalHandler = (LexicalHandler) value;
else if ((GNU_FEATURES + "xml-base").equals(name))
baseAware = Boolean.TRUE.equals(value);
else if ((GNU_FEATURES + "coalescing").equals(name))
coalescing = Boolean.TRUE.equals(value);
else
throw new SAXNotSupportedException(name);
}
示例8: setProperty
import org.xml.sax.ext.DeclHandler; //导入依赖的package包/类
public void setProperty (String name, Object value)
throws SAXNotRecognizedException, SAXNotSupportedException
{
checkPropertyName (name);
String key = name.substring (PROPERTIES_PREFIX.length ());
if ("declaration-handler".equals (key))
{
setDeclarationHandler ((DeclHandler) value);
}
else if ("lexical-handler".equals (key))
{
setLexicalHandler ((LexicalHandler) value);
}
}
示例9: setProperty
import org.xml.sax.ext.DeclHandler; //导入依赖的package包/类
/**
* <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);
}
示例10: setProperty
import org.xml.sax.ext.DeclHandler; //导入依赖的package包/类
/**
* <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);
}
示例11: setContentHandler
import org.xml.sax.ext.DeclHandler; //导入依赖的package包/类
@Override
public void setContentHandler(ContentHandler pHandler) {
//Called by XOM during builder construction - grab a reference to the handler so we can pass it to the decoder
mContentHandler = pHandler;
mDecoder.setLexicalHandler((LexicalHandler) mContentHandler);
mDecoder.setDeclHandler((DeclHandler) mContentHandler);
}
示例12: setProperty
import org.xml.sax.ext.DeclHandler; //导入依赖的package包/类
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 if ("http://xml.org/sax/properties/declaration-handler"
.equals(name)) {
this.declHandler = (DeclHandler) value;
} else {
throw new SAXNotRecognizedException(name);
}
}
示例13: setHandler
import org.xml.sax.ext.DeclHandler; //导入依赖的package包/类
/**
* Registers given handler with all its implementing interfaces.
* This would be handy if you want to register to all interfaces
* implemented by given handler object
*
* @param handler Object implementing one or more sax handler interfaces
*/
public void setHandler(Object handler){
if(handler instanceof ContentHandler)
setContentHandler((ContentHandler)handler);
if(handler instanceof EntityResolver)
setEntityResolver((EntityResolver)handler);
if(handler instanceof ErrorHandler)
setErrorHandler((ErrorHandler)handler);
if(handler instanceof DTDHandler)
setDTDHandler((DTDHandler)handler);
if(handler instanceof LexicalHandler)
setLexicalHandler((LexicalHandler)handler);
if(handler instanceof DeclHandler)
setDeclHandler((DeclHandler)handler);
}
示例14: setProperty
import org.xml.sax.ext.DeclHandler; //导入依赖的package包/类
@Override
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException{
if(LEXICAL_HANDLER.equals(name) || LEXICAL_HANDLER_ALT.equals(name)){
if(value==null || value instanceof LexicalHandler)
lexicalHandler = (LexicalHandler)value;
else
throw new SAXNotSupportedException("value must implement "+LexicalHandler.class);
}else if(DECL_HANDLER.equals(name) || DECL_HANDLER_ALT.equals(name)){
if(value==null || value instanceof DeclHandler)
declHandler = (DeclHandler)value;
else
throw new SAXNotSupportedException("value must implement "+DeclHandler.class);
}else
throw new SAXNotRecognizedException();
}
示例15: addDeclHandler
import org.xml.sax.ext.DeclHandler; //导入依赖的package包/类
public void addDeclHandler(DeclHandler handler)
{
if (handler != null)
{
validatorDeclHandlers.add(handler);
}
}