List of usage examples for org.dom4j Element elementTextTrim
String elementTextTrim(QName qname);
From source file:com.pureinfo.srm.srm2rpms.action.RPMSValidatorAction.java
License:Open Source License
/** * @see com.pureinfo.ark.interaction.ActionBase#beforeExecution() *///from www. j ava 2 s . co m protected ActionForward beforeExecution() throws PureException { String sId = request.getRequiredParameter("id", "validator id"); String sFileName = ClassResourceUtil.mapFullPath("srm2rpms-validator.cfg.xml", true); Element element = XMLUtil.fileToElement(sFileName); List list = element.elements(); try { Iterator itrList = list.iterator(); while (itrList.hasNext()) { element = (Element) itrList.next(); if (sId.equals(element.attributeValue("id"))) { m_sTitle = element.attributeValue("title"); m_sScenery = element.attributeValue("scenery"); m_sHeadTable = element.elementText("hint"); String sCondition = element.elementTextTrim("condition"); ((SearchForm) form).getQueryFilter().addCondition(sCondition); return super.beforeExecution(); } } // endwhile } finally { list.clear(); } throw new PureException(PureException.INVALID_REQUEST, "validator not found: id=" + sId); }
From source file:com.pureinfo.studio.db.rpms2srm.RPMSImporter.java
License:Open Source License
private DolphinObject makeNewObject(Class _clazz, DolphinObject _oldObj) throws Exception { DolphinObject newObj = null;//from w w w .jav a 2 s . com Element ele = m_xmlConfig.element("match"); if (ele != null && ele.hasContent()) { String strSQL = ele.elementTextTrim("sql"); StringTokenizer st = new StringTokenizer(strSQL, "$", false); StringBuffer sbuff = new StringBuffer("select * from {this} where "); try { boolean bPropertyValue = false; String sValue; while (st.hasMoreElements()) { sValue = (String) st.nextElement(); if (bPropertyValue) { sValue = _oldObj.getPropertyAsString(sValue.toUpperCase()); } sbuff.append(sValue); bPropertyValue = !bPropertyValue; } strSQL = sbuff.toString(); } finally { sbuff.setLength(0); } logger.debug("to find existing object: " + strSQL); ISession session = getSessionTo(); IStatement query = session.createQuery(strSQL, _clazz, 1); IObjects objs = null; try { objs = query.executeQuery(); newObj = objs.next(); } finally { DolphinHelper.clear(objs, query); } if (logger.isDebugEnabled()) { logger.debug("existing object: " + newObj); } } if (newObj == null) { newObj = (DolphinObject) _clazz.newInstance(); } return newObj; }
From source file:com.pureinfo.studio.db.xls2rpms.XlsImporter.java
License:Open Source License
private DolphinObject makeNewObject(Class _clazz, DolphinObject _oldObj) throws Exception { DolphinObject newObj = null;/*from w w w . ja v a 2 s .c o m*/ Element ele = m_xmlConfig.element("match"); if (ele != null && ele.hasContent()) { String strSQL = ele.elementTextTrim("sql"); StringTokenizer st = new StringTokenizer(strSQL, "$", false); StringBuffer sbuff = new StringBuffer("select * from {this} where "); try { boolean bPropertyValue = false; String sValue; while (st.hasMoreElements()) { sValue = (String) st.nextElement(); if (bPropertyValue) { sValue = _oldObj.getPropertyAsString(sValue.toUpperCase()); } sbuff.append(sValue); bPropertyValue = !bPropertyValue; } strSQL = sbuff.toString(); } finally { sbuff.setLength(0); } logger.debug("to find existing object: " + strSQL); ISession session = getSession(); IStatement query = session.createQuery(strSQL, _clazz, 1); IObjects objs = null; try { objs = query.executeQuery(); newObj = objs.next(); } finally { DolphinHelper.clear(objs, query); } if (logger.isDebugEnabled()) { logger.debug("existing object: " + newObj); } } if (newObj == null) { newObj = (DolphinObject) _clazz.newInstance(); } return newObj; }
From source file:com.stardon.carassistant.Activity.BusinessRecordFunctionList_Activity.java
/** * @: request08Q12/*from w w w.jav a 2 s . c om*/ * @: 08Q12 <br/> * <br/> * Toastmessage <br/> * <br/> * <br/> * <br/> * <br/> * @: null * @: void * @ IOException: * @ NullPointerException: */ private void request08Q12() { String jkid = "08Q12"; StringBuilder xmlData = new StringBuilder(); xmlData.append("<?xml version=\"1.0\" encoding=\"GBK\"?>"); xmlData.append("<root>"); xmlData.append("<QueryCondition>"); xmlData.append("<orgcode>" + orgcode + "</orgcode>"); xmlData.append("</QueryCondition>"); xmlData.append("</root>"); doRequest(METHOD_QUERY, jkid, xmlData.toString(), new VolleyInterface() { @Override public void onMySuccess(JSONObject result) { } @Override public void onMySuccess(String result) { Document doc = null; try { doc = DocumentHelper.parseText(result); Element root = doc.getRootElement(); Element head = root.element("head"); String code = head.elementTextTrim("code"); String message = head.elementTextTrim("message"); if (!"1".equals(code)) {// 1. MyToast.showButtom(getContext(), message); return; } { XStream xstream = new XStream(new DomDriver()); xstream.ignoreUnknownElements(); xstream.alias("root", ResponseRootVo.class); xstream.alias("head", BaseResponseMsgVO.class); xstream.alias("body", BaseResponseBodyVO.class); xstream.aliasField("vehispara", BaseResponseBodyVO.class, "bean08Q12");// xstream.alias("vehispara", Bean08Q12.class);// ResponseRootVo b = (ResponseRootVo) xstream.fromXML(result); bean08Q12 = b.getBody().getBean08Q12(); } Element body = root.element("body"); List<Element> elementList = body.element("vehispara").elements(); data08Q12 = new HashMap<String, String>(); for (Element element : elementList) { data08Q12.put(element.getName(), element.getTextTrim()); } } catch (Exception e) { e.printStackTrace(); } try { user.setOrgrecoedstate(data08Q12.get("reviewstate")); dao.saveUser(user); reviewstate = data08Q12.get("reviewstate"); code = data08Q12.get("code"); ishavephoto = data08Q12.get("ishavephoto"); pic = data08Q12.get("pic"); zzpic = data08Q12.get("zzpic"); refreshStauts(); } catch (Exception e) { } } @Override public void onMyError(VolleyError result) { } }); }
From source file:com.stardon.carassistant.Activity.BusinessRecordFunctionList_Activity.java
/** * @: request08W11/*from w w w.ja va 2s. com*/ * @: 08W11 <br/> * Toast <br/> * Toastmessage <br/> * @: null * @: void * @ IOException: * @ NullPointerException: */ private void request08W11() { String jkid = "08W11"; StringBuilder xmlData = new StringBuilder(); xmlData.append("<?xml version=\"1.0\" encoding=\"GBK\"?>"); xmlData.append("<root>"); xmlData.append("<vehispara>"); xmlData.append("<orgcode>" + orgcode + "</orgcode>"); xmlData.append("</vehispara>"); xmlData.append("</root>"); doRequest(METHOD_WRITE, jkid, xmlData.toString(), new VolleyInterface() { @Override public void onMySuccess(JSONObject result) { } @Override public void onMySuccess(String result) { Document doc = null; try { doc = DocumentHelper.parseText(result); Element root = doc.getRootElement(); Element head = root.element("head"); String code = head.elementTextTrim("code"); String message = head.elementTextTrim("message"); MyToast.showButtom(getContext(), message); if (!"1".equals(code)) {// 1. return; } user.setOrgrecoedstate("1"); dao.saveUser(user); } catch (Exception e) { e.printStackTrace(); } // itemButton.setVisibility(View.GONE); itemMessage.setVisibility(View.VISIBLE); statusItem.setText(R.string.function_list_confirmed); } @Override public void onMyError(VolleyError result) { } }); }
From source file:com.taobao.datasource.DataSourceConfigParser.java
License:Open Source License
private static LocalTxDataSourceDO createLocalTxDataSourceDO(Element localTxDatasource) { LocalTxDataSourceDO ds = new LocalTxDataSourceDO(); ds.setJndiName(localTxDatasource.elementTextTrim(JNDI_NAME)); ds.setConnectionURL(localTxDatasource.elementTextTrim(CONNECTION_URL)); ds.setDriverClass(localTxDatasource.elementTextTrim(DRIVER_CLASS)); String transactionIsolation = localTxDatasource.elementTextTrim(TRANSACTION_ISOLATION); ds.setTransactionIsolation(//from w ww. jav a 2 s . com transactionIsolation != null ? transactionIsolation : DEFAULT_TRANSACTION_ISOLATION); ds.setUserName(localTxDatasource.elementTextTrim(USER_NAME)); ds.setPassword(localTxDatasource.elementTextTrim(PASSWORD)); ds.setSecurityDomain(localTxDatasource.elementTextTrim(SECURITY_DOMAIN)); ds.setMinPoolSize( NumberUtils.toInt(localTxDatasource.elementTextTrim(MIN_POOL_SIZE), DEFAULT_MIN_POOL_SIZE)); ds.setMaxPoolSize( NumberUtils.toInt(localTxDatasource.elementTextTrim(MAX_POOL_SIZE), DEFAULT_MAX_POOL_SIZE)); ds.setBlockingTimeoutMillis(NumberUtils.toInt(localTxDatasource.elementTextTrim(BLOCKING_TIMEOUT_MILLIS), DEFAULT_BLOCKING_TIMEOUT_MILLIS)); ds.setBackgroundValidation(TRUE.equalsIgnoreCase(localTxDatasource.elementTextTrim(BACKGROUND_VALIDATION))); ds.setBackgroundValidationMinutes( NumberUtils.toLong(localTxDatasource.elementTextTrim(BACKGROUND_VALIDATION_MINUTES), DEFAULT_BACKGROUND_VALIDATION_MINUTES)); ds.setIdleTimeoutMinutes(NumberUtils.toLong(localTxDatasource.elementTextTrim(IDLE_TIMEOUT_MINUTES), DEFAULT_IDLE_TIMEOUT_MINUTES)); ds.setValidateOnMatch(!FALSE.equalsIgnoreCase(localTxDatasource.elementTextTrim(VALIDATE_ON_MATCH))); ds.setNewConnectionSQL(localTxDatasource.elementTextTrim(NEW_CONNECTION_SQL)); ds.setCheckValidConnectionSQL(localTxDatasource.elementTextTrim(CHECK_VALID_CONNECTION_SQL)); ds.setValidConnectionCheckerClassName( localTxDatasource.elementTextTrim(VALID_CONNECTION_CHECKER_CLASS_NAME)); ds.setExceptionSorterClassName(localTxDatasource.elementTextTrim(EXCEPTION_SORTER_CLASS_NAME)); String trackStatements = localTxDatasource.elementTextTrim(TRACK_STATEMENTS); ds.setTrackStatements(trackStatements != null ? trackStatements : DEFAULT_TRACK_STATEMENTS); ds.setPrefill(TRUE.equalsIgnoreCase(localTxDatasource.elementTextTrim(PREFILL))); ds.setUseFastFail(TRUE.equalsIgnoreCase(localTxDatasource.elementTextTrim(USE_FAST_FAIL))); ds.setPreparedStatementCacheSize( NumberUtils.toInt(localTxDatasource.elementTextTrim(PREPARED_STATEMENT_CACHE_SIZE), DEFAULT_PREPARED_STATEMENT_CACHE_SIZE)); ds.setSharePreparedStatements(localTxDatasource.element(SHARE_PREPARED_STATEMENTS) != null); ds.setTxQueryTimeout(localTxDatasource.element(SET_TX_QUERY_TIMEOUT) != null); ds.setQueryTimeout( NumberUtils.toInt(localTxDatasource.elementTextTrim(QUERY_TIMEOUT), DEFAULT_QUERY_TIMEOUT)); for (Element connectionProperty : (List<Element>) localTxDatasource.elements(CONNECTION_PROPERTY)) { ds.addConnectionProperty(connectionProperty.attributeValue(NAME), connectionProperty.getTextTrim()); } return ds; }
From source file:com.topsec.tsm.sim.util.TalVersionUtil.java
/** * @method: getBuildVersion /* w w w . j a va 2s.c o m*/ * ?confbuildVersion.xml,? * @author: ?(yang_xuanjia@topsec.com.cn) * @param: * @return: buildVersion ? */ public synchronized String getBuildVersion() { Element readVersionFile = readVersionFile(); String buildVersion = readVersionFile.elementTextTrim("buildVersion"); if (buildVersion == null || buildVersion.equals("")) { String version = getVersion(); writeVersionFile(version, "buildVersion"); buildVersion = version; } return buildVersion; }
From source file:com.wifi.util.msg.MessageBuilder.java
@SuppressWarnings("unchecked") public AppMessage buildAppMessage() throws DocumentException { AppMessage msg = new AppMessage(); try {//w w w. j a v a 2 s . co m Document document = DocumentHelper.parseText(this.xmlText); Element rootElt = document.getRootElement(); if (!rootElt.getName().equals(AppMessage.MESSAGE_TAG)) { System.err.println("The xml message tag is incorrect!" + rootElt.getName()); return null; } Element headElt = rootElt.element(AppMessage.HEADER_TAG); if (headElt == null) { System.err.println("The message content is incorrect [no message header]!"); return null; } MessageHeader header = new MessageHeader(); header.setDevMac(headElt.elementTextTrim(MessageHeader.DEV_MAC_TAG)); header.setHwId(headElt.elementTextTrim(MessageHeader.HW_ID_TAG)); header.setLicense(headElt.elementTextTrim(MessageHeader.LICENSE_TAG)); header.setMagic(headElt.elementTextTrim(MessageHeader.MAGIC_TAG)); header.setMsgId(headElt.elementTextTrim(MessageHeader.MSG_ID_TAG)); header.setSrcIp(headElt.elementTextTrim(MessageHeader.SRC_IP_TAG)); header.setTargetIp(headElt.elementTextTrim(MessageHeader.TARGET_IP_TAG)); msg.setHeader(header); System.out.println(header); Element bodyElt = rootElt.element(AppMessage.BODY_TAG); if (bodyElt == null) { System.out.println("The message doesn't exists message body!"); } else { MessageBody body = new MessageBody(); Map<String, String> map = new HashMap<>(); Iterator<Element> bdyIterator = bodyElt.elementIterator(); while (bdyIterator.hasNext()) { Element element = bdyIterator.next(); map.put(element.getName(), element.getTextTrim()); } body.setItemsMap(map); msg.setBody(body); System.out.println(body); } } catch (Exception e) { System.err.println("parse error: " + e.getMessage()); return null; } return msg; }
From source file:com.zia.freshdocs.cmis.CMISParser10.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from w w w.ja v a 2 s . co m public NodeRef[] parseChildren(InputStream is) { NodeRef[] children = null; HashMap<String, String> nsMap = new HashMap<String, String>(); nsMap.put("atom", ATOM_NS); nsMap.put("cmis", CMIS_NS); DocumentFactory factory = new DocumentFactory(); factory.setXPathNamespaceURIs(nsMap); SAXReader reader = new SAXReader(); reader.setDocumentFactory(factory); try { Document document = reader.read(is); List<Element> entries = (List<Element>) document.selectNodes("/atom:feed/atom:entry"); int numEntries = entries.size(); children = new NodeRef[numEntries]; Element entry; NodeRef nodeRef; // Iterate over each entry element and find corresponding attrs for (int i = 0; i < numEntries; i++) { nodeRef = new NodeRef(); children[i] = nodeRef; entry = entries.get(i); // Get either the node uuid or src uri and content type Element id = entry.element("id"); String uuid = id.getTextTrim().replace(URN_UUID, ""); nodeRef.setContent(uuid); Element content = entry.element("content"); String contentType = content.attributeValue("type"); if (contentType != null) { nodeRef.setContentType(contentType); nodeRef.setContent(content.attributeValue("src")); } List<Element> cmisProperties = entry.selectNodes(".//cmis:properties/*"); int numProperties = cmisProperties.size(); Element cmisProperty; // Iterate over each property and populate associated field in NodeRef for (int j = 0; j < numProperties; j++) { cmisProperty = cmisProperties.get(j); String attrValue = cmisProperty.attributeValue("propertyDefinitionId"); if (attrValue == null) { continue; } if (attrValue.equals("cmis:name")) { nodeRef.setName(cmisProperty.elementTextTrim("value")); } if (attrValue.equals("cmis:baseTypeId")) { String typeId = cmisProperty.elementTextTrim("value"); nodeRef.setFolder(typeId != null && typeId.equals("cmis:folder")); } if (attrValue.equals("cmis:lastModificationDate")) { nodeRef.setLastModificationDate(cmisProperty.elementTextTrim("value")); } if (attrValue.equals("cmis:lastModifiedBy")) { nodeRef.setLastModifiedBy(cmisProperty.elementTextTrim("value")); } if (attrValue.equals("cmis:versionLabel")) { nodeRef.setVersion(cmisProperty.elementTextTrim("value")); } if (attrValue.equals("cmis:createdBy")) { nodeRef.setCreateBy(cmisProperty.elementTextTrim("value")); } if (attrValue.equals("cmis:objectId")) { nodeRef.setObjectId(cmisProperty.elementTextTrim("value")); } if (attrValue.equals("cmis:parentId")) { nodeRef.setParentId(cmisProperty.elementTextTrim("value")); } if (attrValue.equals("cmis:contentStreamLength")) { nodeRef.setContentLength(Long.valueOf(cmisProperty.elementTextTrim("value"))); } } } } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } return children; }
From source file:costumetrade.common.sms.SMSActor.java
License:Open Source License
private boolean isOk(String xml) { try {/*from w ww . j av a2 s. c o m*/ Document doc = DocumentHelper.parseText(xml); Element root = doc.getRootElement();// ? String returnstatus = root.elementTextTrim("returnstatus"); return "Success".equals(returnstatus); } catch (Exception e) { LOGGER.error("????"); } return false; }