本文整理匯總了Java中org.dom4j.Element.elementTextTrim方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.elementTextTrim方法的具體用法?Java Element.elementTextTrim怎麽用?Java Element.elementTextTrim使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.dom4j.Element
的用法示例。
在下文中一共展示了Element.elementTextTrim方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getConfig
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* 獲取配置
*
* @param name
* @return
* @throws Exception
*/
public static HttpConfig getConfig(String name) throws Exception {
HttpConfig hc = CONFIG_MAP.get(name);
if (hc == null) {
SAXReader reader = new SAXReader();
File xml = new File(HTTP_CONFIG_FILE);
Document doc;
Element root;
if (xml.exists()) {
try (FileInputStream in = new FileInputStream(xml); Reader read = new InputStreamReader(in, "UTF-8")) {
doc = reader.read(read);
root = doc.getRootElement();
List<Element> els = root.selectNodes("/root/configs/config");
for (Element el : els) {
String nameStr = el.attributeValue("name");
String encodeType = el.attributeValue("encodeType");
String charset = el.attributeValue("charset");
String requestType = el.attributeValue("requestType");
String sendXML = el.attributeValue("sendXML");
String packHead = el.attributeValue("packHead");
String lowercaseEncode = el.attributeValue("lowercaseEncode");
String url = el.elementTextTrim("url");
String header = el.elementTextTrim("header");
String parameter = el.elementTextTrim("parameter");
String encodeField = el.elementTextTrim("encodeField");
String encodeKey = el.elementTextTrim("encodeKey");
String contentType = el.elementTextTrim("contentType");
HttpConfig config = new HttpConfig(nameStr, url, charset, header, parameter, requestType, contentType);
config.setSendXML(Boolean.valueOf(sendXML));
config.setEncodeKey(encodeKey);
config.setEncodeType(encodeType);
config.setEncodeFieldName(encodeField);
config.setLowercaseEncode(Boolean.valueOf(lowercaseEncode));
config.setPackHead(Boolean.valueOf(packHead));
CONFIG_MAP.put(nameStr, config);
if (nameStr.equals(name)) {
hc = config;
}
}
}
}
}
return hc;
}