List of usage examples for org.dom4j Element getText
String getText();
From source file:com.pureinfo.dolphin.script.param.ParameterMetadata.java
License:Open Source License
/** * @see com.pureinfo.force.xml.IXMLSupporter#fromXML(org.dom4j.Element) *//*www. ja v a 2 s. com*/ public void fromXML(Element _element) throws PureException { CheckUtils.checkRequestNotNull(_element); CheckUtils.checkElementName(_element, ELEMENT_PARAMETER); setName(XMLUtil.getRequiredAttributeValue(_element, ATTRIBUTE_NAME)); setRequired(XMLUtil.getRequiredAttributeBooleanValue(_element, ATTRIBUTE_REQUIRED)); setDescription(XMLUtil.getRequiredAttributeValue(_element, ATTRIBUTE_DESCRIPTION)); setDefault(_element.getText()); }
From source file:com.pureinfo.dolphinview.component.model.ViewComponent.java
License:Open Source License
private String getPathText(Element _elemant, String _sPath) { XPath elementPath = _elemant.createXPath(_sPath); Element element = (Element) elementPath.selectSingleNode(_elemant); if (element == null) { return ""; }/*from w w w . j a v a 2 s . c om*/ return element.getText(); }
From source file:com.pureinfo.dolphinview.style.model.ViewStyle.java
License:Open Source License
private Map getProperties(Element _element) throws PureException { List list = _element.elements(ELEMENT_PROPERTY); Map props = new HashMap(list.size()); if (list.size() == 0) { logger.warn("style[" + getName() + "] element[" + _element.getName() + "] has no element[" + ELEMENT_PROPERTY + "]"); }//from w w w .j av a2 s. c om for (Iterator iter = list.iterator(); iter.hasNext();) { Element ele = (Element) iter.next(); String sName = XMLUtil.getRequiredAttributeValue(ele, ATTRIBUTE_NAME); String sValue = ele.getText(); props.put(sName, sValue); } return props; }
From source file:com.pureinfo.srm.report.report.digital.parser.ReportParser.java
License:Open Source License
private static Map parseGroupers(Document _script) { List xGroupers = _script.getRootElement().element("groupers").elements("grouper"); Map groupers = new HashMap(xGroupers.size()); for (Iterator iter = xGroupers.iterator(); iter.hasNext();) { Element xQuery = (Element) iter.next(); String sId = xQuery.attributeValue("id"); Grouper grouper = new Grouper(); String sType = xQuery.attributeValue("type"); List xParams = xQuery.elements("param"); Map params = new HashMap(xParams.size()); for (Iterator iterInner = xGroupers.iterator(); iterInner.hasNext();) { Element xParam = (Element) iterInner.next(); params.put(xParam.attributeValue("name"), xParam.getText().trim()); }/*from w w w . jav a 2 s . c om*/ grouper.setType(sType); grouper.setPamrams(params); groupers.put(sId, grouper); } return groupers; }
From source file:com.pureinfo.srm.sci.model.SCIDeptObj.java
License:Open Source License
/** * @see com.pureinfo.force.xml.IXMLSupporter#fromXML(org.dom4j.Element) *//*w ww.java 2 s .co m*/ public void fromXML(Element _element) throws PureException { m_sCNName = _element.attributeValue("cn-name"); m_sType = _element.attributeValue("type"); String sNames = ""; for (Iterator iter = _element.elementIterator("en-name"); iter.hasNext();) { Element ENNameElement = (Element) iter.next(); m_hENNameMap.put(ENNameElement.getText().toLowerCase(), m_sCNName); m_sEnglishNames += ENNameElement.getText().toLowerCase() + "|"; } }
From source file:com.rdvmedecin.proprietes.Properties.java
public Properties() throws DocumentException { File fichier = new File("configuration.xml"); SAXReader reader = new SAXReader(); Document doc = reader.read(fichier); Element root = doc.getRootElement(); List attributes = root.attributes(); List elements = root.elements(); QName qName = root.getQName(); String nom = qName.getName(); // lecture du nom de l'espace de noms String nomEspaceDeNoms = qName.getNamespaceURI(); // lecture du prfixe utilis pour cet espace de nom String nomPrefix = qName.getNamespacePrefix(); String texte = root.getText(); Attribute attribute = (Attribute) attributes.iterator().next(); QName attributeQName = attribute.getQName(); String value = attribute.getValue(); String nomAttribut = attribute.getName(); }
From source file:com.rohanclan.afae.modes.ModeReader.java
License:Open Source License
/** * Invokes the listeners newTextSequence to add a new text sequence * // w w w .j ava 2 s.c o m * element from the mode file * * @param seqElement */ private void createTextSequence(Element seqElement) { boolean atLineStart = bool(seqElement, "AT_LINE_START", false); boolean atWhitespaceEnd = bool(seqElement, "AT_WHITESPACE_END", false); boolean atWordStart = bool(seqElement, "AT_WORD_START", false); String type = seqElement.attributeValue("TYPE"); String delegate = seqElement.attributeValue("DELEGATE"); listener.newTextSequence(type, seqElement.getText(), atLineStart, atWhitespaceEnd, atWordStart, delegate); }
From source file:com.rohanclan.afae.modes.ModeReader.java
License:Open Source License
/** * Invokes the listeners newEOLSpan//ww w . j a v a2 s . c o m * * @param eolElement */ private void createEOL(Element eolElement) { String type = eolElement.attributeValue("TYPE"); boolean atLineStart = bool(eolElement, "AT_LINE_START", false); boolean excludeMatch = bool(eolElement, "EXCLUDE_MATCH", false); boolean noLineBreak = bool(eolElement, "NO_LINE_BREAK", false); boolean noWordBreak = bool(eolElement, "NO_WORD_BREAK", false); boolean ignoreCase = bool(eolElement, "IGNORE_CASE", false); String delegate = eolElement.attributeValue("DELEGATE"); String escape = eolElement.attributeValue("ESCAPE"); //listener.newEOLSpan(type, eolElement.getText(), atLineStart); listener.newEOLSpan(type, eolElement.getText(), atLineStart, excludeMatch, noLineBreak, noWordBreak, ignoreCase, delegate, escape); }
From source file:com.rohanclan.afae.modes.ModeReader.java
License:Open Source License
/** * Invokes the listeners newMark//from w w w .j ava 2s . c o m * * @param markElement * @param isPrevious */ private void createMark(Element markElement, boolean isPrevious) { boolean atLineStart = bool(markElement, "AT_LINE_START", false); boolean atWhitespaceEnd = bool(markElement, "AT_WHITESPACE_END", false); boolean excludeMatch = bool(markElement, "EXCLUDE_MATCH", false); boolean atWordStart = bool(markElement, "AT_WORD_START", false); String type = markElement.attributeValue("TYPE"); String delegate = markElement.attributeValue("DELEGATE"); listener.newMark(type, markElement.getText(), atLineStart, atWhitespaceEnd, atWordStart, delegate, isPrevious, excludeMatch); }
From source file:com.seer.datacruncher.utils.generic.StreamsUtils.java
License:Open Source License
/** * Publishes stream to destination database. * /* w w w. j a v a 2 s. c o m*/ * @param datastreamDTO - keeps stream info */ public static void publishStreamToDB(DatastreamDTO datastreamDTO) { Long schemaId = datastreamDTO.getIdSchema(); QuickDBRecognizer quickDBRecognizer = new QuickDBRecognizer(schemaId); log.debug("quickDBRecognizer started"); try { List<Element> xmlTextNodes = parseStreamXml(datastreamDTO.getOutput()); StreamToDbDynamicObject streamObj = quickDBRecognizer.traceDefine(xmlTextNodes); Map<String, Map<String, String>> schemaFields = streamObj.getInsertedFields(); //boolean isLoadedFields = streamObj.isLoadedFields(); Object toPersist = streamObj.getObject(); for (Element el : xmlTextNodes) { String fieldPath = formatPathForXmlNode(el.getPath()); String fieldValue = el.getText(); for (Map.Entry<String, Map<String, String>> entry : schemaFields.entrySet()) { String entryFieldPath = getFieldPathPrefix(datastreamDTO.getIdStreamType()) + entry.getValue().get("path"); if (entry.getValue().get(IS_ATTR).equals("true")) { for (Object o : el.attributes()) { DefaultAttribute attr = (DefaultAttribute) o; String attrPath = fieldPath + "/" + attr.getName().toUpperCase(); if (attrPath.equals(entryFieldPath)) { fieldPath = attrPath; fieldValue = attr.getValue(); break; } } } if (entryFieldPath.equals(fieldPath)) { String fieldJavaType = entry.getValue().get("type"); Method meth = toPersist.getClass().getMethod("set" + entry.getKey(), Class.forName(fieldJavaType)); if (fieldJavaType.contains("String")) { meth.invoke(toPersist, fieldValue); } else if (fieldJavaType.contains("Long")) { meth.invoke(toPersist, Long.valueOf(fieldValue)); } else if (fieldJavaType.contains("Double")) { meth.invoke(toPersist, Double.valueOf(fieldValue)); } else if (fieldJavaType.contains("Integer")) { meth.invoke(toPersist, Integer.valueOf(fieldValue)); } else if (fieldJavaType.contains("Date")) { //never invoked because now all dates are of string type meth.invoke(toPersist, new Date()); } } } } toPersist.getClass().getMethod("setPath", String.class).invoke(toPersist, getAllPaths(schemaFields)); int inserito = quickDBRecognizer.insertTrace(streamObj); if (inserito > 0) { log.info("Stream published successfully"); } } catch (ReflectionException ex) { log.error(ex); } catch (ClassNotFoundException ex) { log.error(ex); } catch (IOException ex) { log.error(ex); } catch (InstantiationException ex) { log.error(ex); } catch (IllegalAccessException ex) { log.error(ex); } catch (SecurityException ex) { log.error(ex); } catch (CannotCompileException ex) { log.error(ex); } catch (NoSuchFieldException ex) { log.error(ex); } catch (NoSuchMethodException ex) { log.error(ex); } catch (InvocationTargetException ex) { log.error(ex); } catch (NotFoundException ex) { log.error(ex); } catch (DocumentException e) { log.error("Stream parse exception", e); } }