List of usage examples for org.dom4j Element getText
String getText();
From source file:com.xia.ssm.tools.ocr.CheckPic.java
/** * ?/* w w w .ja v a 2s .c o m*/ * @Title: sendBankToWt * @param thPhoneDTO * @return * @createDate 20161026;?6:39:23 * @author luy */ public static ClaimPhoneDTO sendBankToWt(ClaimPhoneDTO thPhoneDTO) { String result = ""; String file = thPhoneDTO.getAppPath() + thPhoneDTO.getPhotoNames();//? long beginTime = System.currentTimeMillis(); try { log.info("file======" + file); result = WTUtils.invokeRemoteFuc(thPhoneDTO.getPicType(), WTUtils.WT_USERNAME, file, WTUtils.WT_PAR_BAK, WTUtils.WT_PIC_KIND, thPhoneDTO.getWtAddrUrl()); log.info("result======" + result); } catch (Exception e) { // TODO: handle exception thPhoneDTO.setResponseCode(ExceptionClaimCode.BANK_FAILED); ErrorsLogPrintUtil.printToLog4j(log, e); } String[] encData = result.split("==@@"); long times = System.currentTimeMillis() - beginTime; log.info("" + times); String dataString = encData[0].replaceAll("<!\\[CDATA\\[", "").replaceAll("\\]\\]>", ""); Document doc; String insertString = ""; try { doc = DocumentHelper.parseText(dataString); String status = doc.selectSingleNode("/data/message/status").getText(); String value = doc.selectSingleNode("/data/message/value").getText(); if ("?".equals(value)) { List list = doc.selectNodes("/data/cardsinfo/card/item"); for (int j = 1; j < list.size() - 1; j++) { Element term = (Element) list.get(j); String returString = term.getText(); insertString += "'" + returString + "'" + ","; String name = term.attribute("desc").getText(); if ("???".equals(name)) { thPhoneDTO.setPlateNo(returString); } if ("".equals(name)) { thPhoneDTO.setVehicleType(returString); } if ("".equals(name)) { thPhoneDTO.setCustomerName(returString); } if ("??".equals(name)) { thPhoneDTO.setAddress(returString); } if ("??".equals(name)) { thPhoneDTO.setVehicleModels(returString); } if ("?".equals(name)) { thPhoneDTO.setVin(returString); } if ("???".equals(name)) { thPhoneDTO.setEngineNo(returString); } if ("".equals(name)) { thPhoneDTO.setRegisterDate(returString); } if ("??".equals(name)) { thPhoneDTO.setIssueDate(returString); } if ("".equals(name)) { thPhoneDTO.setUseType(returString); } thPhoneDTO.setConsumeTime("" + String.valueOf(times) + ""); thPhoneDTO.setState(value); thPhoneDTO.setStatus(status); } } else { thPhoneDTO.setConsumeTime("" + String.valueOf(times) + ""); thPhoneDTO.setState(value); thPhoneDTO.setStatus(status); thPhoneDTO.setResponseCode(ExceptionClaimCode.DRIVERLICENSE_FAILED); } } catch (Exception e) { thPhoneDTO.setResponseCode(ExceptionClaimCode.DRIVERLICENSE_FAILED); ErrorsLogPrintUtil.printToLog4j(log, e); } return thPhoneDTO; }
From source file:com.xpn.xwiki.doc.XWikiAttachment.java
License:Open Source License
public void fromXML(Element docel) throws XWikiException { setFilename(docel.element("filename").getText()); setFilesize(Integer.parseInt(docel.element("filesize").getText())); setAuthor(docel.element("author").getText()); setVersion(docel.element("version").getText()); setComment(docel.element("comment").getText()); String sdate = docel.element("date").getText(); Date date = new Date(Long.parseLong(sdate)); setDate(date);//from w w w .j a v a2 s .c om Element contentel = docel.element("content"); if (contentel != null) { String base64content = contentel.getText(); byte[] content = Base64.decodeBase64(base64content.getBytes()); setContent(content); } Element archiveel = docel.element("versions"); if (archiveel != null) { String archive = archiveel.getText(); setArchive(archive); } }
From source file:com.xpn.xwiki.doc.XWikiDocument.java
License:Open Source License
protected String getElement(Element docel, String name) { Element el = docel.element(name); if (el == null) { return ""; } else {/*from w ww .ja v a2 s. c o m*/ return el.getText(); } }
From source file:com.xpn.xwiki.objects.BaseObject.java
License:Open Source License
public void fromXML(Element oel) throws XWikiException { Element cel = oel.element("class"); BaseClass bclass = new BaseClass(); if (cel != null) { bclass.fromXML(cel);//from w w w . ja v a 2 s. c o m setClassName(bclass.getName()); } setName(oel.element("name").getText()); String number = oel.element("number").getText(); if (number != null) { setNumber(Integer.parseInt(number)); } // If no GUID exists in the XML, then use the one randomly generated at initialization Element guidElement = oel.element("guid"); if (guidElement != null && guidElement.getText() != null) { this.guid = guidElement.getText(); } List list = oel.elements("property"); for (int i = 0; i < list.size(); i++) { Element pcel = (Element) ((Element) list.get(i)).elements().get(0); String name = pcel.getName(); PropertyClass pclass = (PropertyClass) bclass.get(name); if (pclass != null) { BaseProperty property = pclass.newPropertyfromXML(pcel); property.setName(name); property.setObject(this); safeput(name, property); } } }
From source file:com.xpn.xwiki.objects.classes.BaseClass.java
License:Open Source License
public void fromXML(Element cel) throws XWikiException { try {/*from w ww .j a v a2 s .c o m*/ int j = 1; setName(cel.element("name").getText()); Element cclel = cel.element("customClass"); if (cclel != null) { setCustomClass(cclel.getText()); j++; } Element cmapel = cel.element("customMapping"); if (cmapel != null) { setCustomMapping(cmapel.getText()); j++; } Element cdvsel = cel.element("defaultViewSheet"); if (cdvsel != null) { setDefaultViewSheet(cdvsel.getText()); j++; } Element cdesel = cel.element("defaultEditSheet"); if (cdesel != null) { setDefaultViewSheet(cdesel.getText()); j++; } Element cdwel = cel.element("defaultWeb"); if (cdwel != null) { setDefaultWeb(cdwel.getText()); j++; } Element cnfel = cel.element("nameField"); if (cnfel != null) { setNameField(cnfel.getText()); j++; } Element valel = cel.element("validationScript"); if (valel != null) { setValidationScript(valel.getText()); j++; } @SuppressWarnings("unchecked") List<Element> list = cel.elements(); for (int i = j; i < list.size(); i++) { Element pcel = list.get(i); String name = pcel.getName(); String classType = pcel.element("classType").getText(); PropertyClass property = (PropertyClass) Class.forName(classType).newInstance(); property.setName(name); property.setObject(this); property.fromXML(pcel); safeput(name, property); } } catch (Exception e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CLASSES, XWikiException.ERROR_XWIKI_CLASSES_PROPERTY_CLASS_INSTANCIATION, "Error instanciating property class", e, null); } }
From source file:com.xpn.xwiki.objects.classes.DateClass.java
License:Open Source License
@Override public BaseProperty newPropertyfromXML(Element ppcel) { String value = ppcel.getText(); BaseProperty property = newProperty(); if (StringUtils.isEmpty(value)) { return property; }// www .j a v a 2 s . co m SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); try { property.setValue(sdf.parse(value)); } catch (ParseException e) { SimpleDateFormat sdf2 = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy", Locale.US); try { if (LOG.isWarnEnabled()) { LOG.warn("Failed to parse date [" + value + "] using format [" + sdf.toString() + "]. Trying again with format [" + sdf2.toString() + "]"); } property.setValue(sdf2.parse(value)); } catch (ParseException e2) { if (LOG.isWarnEnabled()) { LOG.warn("Failed to parse date [" + value + "] using format [" + sdf2.toString() + "]. Defaulting to the current date."); } property.setValue(new Date()); } } return property; }
From source file:com.xpn.xwiki.objects.classes.ListClass.java
License:Open Source License
@Override public BaseProperty newPropertyfromXML(Element ppcel) { if (!isMultiSelect()) { return super.newPropertyfromXML(ppcel); }//from w ww .j a va 2s .c om @SuppressWarnings("unchecked") List<Element> elist = ppcel.elements("value"); BaseProperty lprop = newProperty(); if (lprop instanceof ListProperty) { List<String> llist = ((ListProperty) lprop).getList(); for (int i = 0; i < elist.size(); i++) { Element el = elist.get(i); llist.add(el.getText()); } } else { for (int i = 0; i < elist.size(); i++) { Element el = elist.get(i); ((StringProperty) lprop).setValue(el.getText()); } } return lprop; }
From source file:com.xpn.xwiki.objects.classes.PropertyClass.java
License:Open Source License
public BaseProperty newPropertyfromXML(Element ppcel) { String value = ppcel.getText(); return fromString(value); }
From source file:com.xpn.xwiki.plugin.packaging.Package.java
License:Open Source License
protected String getElementText(Element docel, String name) { Element el = docel.element(name); if (el == null) { return ""; } else {/*ww w.j a v a 2s .com*/ return el.getText(); } }
From source file:com.xpn.xwiki.store.migration.hibernate.R40000XWIKI6990DataMigration.java
License:Open Source License
/** * Calls callback for each custom mapped XClass defined. If needed, the mapping is added and injected at the end of * the processing into the hibernate session factory. * /*www . j a va 2s . c o m*/ * @param store the hibernate store * @param callback the callback to be called * @param context th current XWikiContext * @throws XWikiException when an unexpected error occurs */ private void processCustomMappings(final XWikiHibernateStore store, final CustomMappingCallback callback, final XWikiContext context) throws XWikiException { if (store.executeRead(context, new HibernateCallback<Boolean>() { @Override public Boolean doInHibernate(Session session) throws XWikiException { boolean hasProcessedMapping = false; try { boolean hasDynamicMapping = context.getWiki().hasDynamicCustomMappings(); SAXReader saxReader = new SAXReader(); @SuppressWarnings("unchecked") List<Object[]> results = session .createQuery("select doc.fullName, doc.xWikiClassXML from " + XWikiDocument.class.getName() + " as doc where (doc.xWikiClassXML like '<%')") .list(); // Inspect all defined classes for custom mapped ones... for (Object[] result : results) { String docName = (String) result[0]; String classXML = (String) result[1]; Element el = saxReader.read(new StringReader(classXML)).getRootElement() .element("customMapping"); String mapping = (el != null) ? el.getText() : ""; if (StringUtils.isEmpty(mapping) && "XWiki.XWikiPreferences".equals(docName)) { mapping = INTERNAL; } if (StringUtils.isNotEmpty(mapping)) { hasProcessedMapping |= (!INTERNAL.equals(mapping) && hasDynamicMapping && store.injectCustomMapping(docName, mapping, context)); callback.processCustomMapping(store, docName, mapping, hasDynamicMapping); } } } catch (Exception e) { throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_MIGRATION, getName() + " migration failed", e); } return hasProcessedMapping; } })) { store.injectUpdatedCustomMappings(context); } }