本文整理汇总了Java中org.exolab.castor.xml.Unmarshaller.setIgnoreExtraElements方法的典型用法代码示例。如果您正苦于以下问题:Java Unmarshaller.setIgnoreExtraElements方法的具体用法?Java Unmarshaller.setIgnoreExtraElements怎么用?Java Unmarshaller.setIgnoreExtraElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.exolab.castor.xml.Unmarshaller
的用法示例。
在下文中一共展示了Unmarshaller.setIgnoreExtraElements方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setMapping
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
/**
* Initializes the Castor mapping instance.
* @param mapping a Castor mapping. Shall not be <code>null</code>.
* @throws NullPointerException if <code>mapping</code> is <code>null</code>.
* @throws MappingException an exception indicating an invalid mapping error.
*/
private void setMapping(final Mapping mapping) throws MappingException
{
_unmarshaller = new Unmarshaller(mapping); // May throw MappingException.
_unmarshaller.setValidation(false);
_unmarshaller.setIgnoreExtraElements(true);
_marshaller = new Marshaller();
_marshaller.setMapping(mapping); // May throw MappingException.
_marshaller.setValidation(false);
//_marshaller.setDebug(true);
// Specifies whether to support XML namespaces by default. Default is false.
//_marshaller.setProperty("org.exolab.castor.parser.namespaces", "true");
// Specifies whether XML documents (as generated at marshalling) should use indentation or not. Default is false.
//_marshaller.setProperty("org.exolab.castor.indent", "true");
}
示例2: customizeUnmarshaller
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
/**
* Template method that allows for customizing of the given Castor {@link Unmarshaller}.
*/
protected void customizeUnmarshaller(Unmarshaller unmarshaller) {
unmarshaller.setValidation(this.validating);
unmarshaller.setWhitespacePreserve(this.whitespacePreserve);
unmarshaller.setIgnoreExtraAttributes(this.ignoreExtraAttributes);
unmarshaller.setIgnoreExtraElements(this.ignoreExtraElements);
unmarshaller.setObject(this.rootObject);
unmarshaller.setReuseObjects(this.reuseObjects);
unmarshaller.setClearCollections(this.clearCollections);
if (this.namespaceToPackageMapping != null) {
for (Map.Entry<String, String> mapping : this.namespaceToPackageMapping.entrySet()) {
unmarshaller.addNamespaceToPackageMapping(mapping.getKey(), mapping.getValue());
}
}
if (this.entityResolver != null) {
unmarshaller.setEntityResolver(this.entityResolver);
}
if (this.classDescriptorResolver != null) {
unmarshaller.setResolver(this.classDescriptorResolver);
}
if (this.idResolver != null) {
unmarshaller.setIDResolver(this.idResolver);
}
if (this.objectFactory != null) {
unmarshaller.setObjectFactory(this.objectFactory);
}
if (this.beanClassLoader != null) {
unmarshaller.setClassLoader(this.beanClassLoader);
}
}
示例3: createUnmarshaller
import org.exolab.castor.xml.Unmarshaller; //导入方法依赖的package包/类
/**
* Create an Unmarshaller for a specific class and configure it with our
* default configuration details. In particular, the Unmarshaller is set
* to not ignore extra attributes and elements.
*
* @param clazz the class to unmarshal
* @param preserveWhitespace whether to preserve whitespace when parsing
* @return
*/
private static <T> Unmarshaller createUnmarshaller(Class<T> clazz, boolean preserveWhitespace) {
Unmarshaller u = new Unmarshaller(clazz);
u.setIgnoreExtraAttributes(false);
u.setIgnoreExtraElements(false);
u.setWhitespacePreserve(preserveWhitespace);
return u;
}