本文整理匯總了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;
}