本文整理汇总了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;
}