本文整理汇总了Java中javax.xml.bind.Unmarshaller.setValidating方法的典型用法代码示例。如果您正苦于以下问题:Java Unmarshaller.setValidating方法的具体用法?Java Unmarshaller.setValidating怎么用?Java Unmarshaller.setValidating使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.bind.Unmarshaller
的用法示例。
在下文中一共展示了Unmarshaller.setValidating方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDatabaseInfo
import javax.xml.bind.Unmarshaller; //导入方法依赖的package包/类
static Map getDatabaseInfo() throws Exception {
URL initUrl = URLHelper.newExtendedURL((String) Config.getProperty(Config.PROP_JDBC_ENGINE_INIT));
// create a JAXBContext capable of handling classes generated into the package
JAXBContext jc = JAXBContext.newInstance("org.jaffa.persistence.engines.jdbcengine.configservice.initdomain");
// create an Unmarshaller
Unmarshaller u = jc.createUnmarshaller();
// enable validation
u.setValidating(true);
// unmarshal a document into a tree of Java content objects composed of classes from the package.
Init init = (Init) u.unmarshal(XmlHelper.stripDoctypeDeclaration(initUrl));
Database database = null;
for (Iterator i = init.getDatabase().iterator(); i.hasNext(); ) {
database = (Database) i.next();
if (database.getName().equals("default"))
break;
}
if (database == null)
throw new Exception("The 'default' database has not been defined in init.xml ");
Map info = new HashMap();
info.put(ENGINE, database.getEngine());
for (Iterator i = database.getConnectionFactory().getParam().iterator(); i.hasNext(); ) {
Param param = (Param) i.next();
if (URL.equals(param.getName()))
info.put(URL, param.getValue());
else if (DRIVER_CLASS.equals(param.getName()))
info.put(DRIVER_CLASS, param.getValue());
else if (USER.equals(param.getName()))
info.put(USER, param.getValue());
else if (PASSWORD.equals(param.getName()))
info.put(PASSWORD, param.getValue());
else if (MAXIMUM_CONNECTIONS.equals(param.getName()))
info.put(MAXIMUM_CONNECTIONS, param.getValue());
}
return info;
}