List of usage examples for org.dom4j Element elements
List<Element> elements(QName qName);
From source file:com.pureinfo.ark.content.model.ContentType.java
License:Open Source License
/** * @see com.pureinfo.force.xml.IXMLSupporter#fromXML(org.dom4j.Element) *//*from www. j a v a2 s .c om*/ public void fromXML(Element _element) throws PureException { this.setId(XMLUtil.getAttributeValueAsInt(_element, "type")); this.setContentClass(XMLUtil.getAttributeValueTrim(_element, "class")); this.setDesc(XMLUtil.getAttributeValueTrim(_element, "desc")); this.setManagerId(XMLUtil.getAttributeValueTrim(_element, "manager")); this.setCacheId(XMLUtil.getAttributeValueTrim(_element, "cache")); /** * @since 1.2 to define whether this object has any appendix */ this.setHasAppendix(XMLUtil.getAttributeValueAsBool(_element, "has-appendix", false)); //to read listeners List elements = _element.elements("listener"); if (elements == null || elements.isEmpty()) { m_arrListenerIds = null; } else { int nTotal = elements.size(); Set listeners = new HashSet(nTotal); try { for (int i = 0; i < nTotal; i++) { Element eleChild = (Element) elements.get(i); String sId = eleChild.attributeValue("id"); if (!listeners.contains(sId)) { listeners.add(sId); } } if (listeners.isEmpty()) { m_arrListenerIds = null; } else { m_arrListenerIds = new String[listeners.size()]; listeners.toArray(m_arrListenerIds); } } finally { elements.clear(); listeners.clear(); } } //endif }
From source file:com.pureinfo.dolphin.mapping.EntityRelative.java
License:Open Source License
/** * @see com.pureinfo.force.xml.IXMLSupporter#fromXML(org.dom4j.Element) *///from ww w . jav a2 s . c o m public void fromXML(Element _element) throws PureException { this.clear(); //to load attributes this.setAlias(_element.attributeValue("alias")); this.setType(_element.attributeValue("type")); this.setJoinCondition(_element.attributeValue("join-condition")); this.setDepends(_element.attributeValue("depends")); //to read properties List list = _element.elements("property"); if (list == null || list.isEmpty()) { m_hPropertyDescs = null; } else { Element ele; String sName, sDesc; m_hPropertyDescs = new HashMap(list.size()); for (int i = 0; i < list.size(); i++) { ele = (Element) list.get(i); sName = ele.attributeValue("name"); sDesc = ele.attributeValue("desc"); m_hPropertyDescs.put(sName, sDesc); } list.clear(); } }
From source file:com.pureinfo.dolphin.mapping.PropertyRef.java
License:Open Source License
/** * @see com.pureinfo.force.xml.IXMLSupporter#fromXML(org.dom4j.Element) *//*ww w . j a va 2s . c om*/ public void fromXML(Element _element) throws PureException { m_sType = _element.attributeValue("type"); m_sKey = _element.attributeValue("key"); m_sLocator = _element.attributeValue("locator"); //to read indexes List list = _element.elements("index"); int nSize = list == null ? 0 : list.size(); m_indexes = new RefIndex[1 + nSize]; RefIndex index; index = new RefIndex(); index.setName(m_sKey); m_indexes[0] = index; for (int i = 0; i < nSize; i++) { index = new RefIndex(); index.fromXML((Element) list.get(i)); m_indexes[i + 1] = index; } }
From source file:com.pureinfo.dolphin.script.formatter.model.Formatter.java
License:Open Source License
/** * Returns the formatters mapping in the specified element. <BR> * Mapping format: <formatter-id(String), formatter(Formatter)> * /* w w w. ja va 2s .c om*/ * @param _element * @throws PureException */ public static void readFormatters(Element _element, Map _container) throws PureException { CheckUtils.checkRequestNotNull(_element); List fmtEleList = _element.elements(ELEMENT_FORMATTER); for (Iterator iter = fmtEleList.iterator(); iter.hasNext();) { Element fmtEle = (Element) iter.next(); Formatter formatter = new Formatter(); formatter.fromXML(fmtEle); _container.put(formatter.getId(), formatter); } }
From source file:com.pureinfo.dolphin.script.formatter.model.FormatterMetadata.java
License:Open Source License
/** * Returns the formatter metadatas mapping in the specified element. <BR> * Mapping format://from w ww . ja va 2s. c o m * <formatter-type(String),formatterMedatada(FormatterMedatada)><br> * * @param _element * @return Empty map if has no formatters * @throws PureException */ public static Map getFormatters(Element _element) throws PureException { CheckUtils.checkRequestNotNull(_element); List elements = _element.elements(ELEMENT_FORMATTER); Map formatters = new HashMap(); for (Iterator iter = elements.iterator(); iter.hasNext();) { Element fmtEle = (Element) iter.next(); FormatterMetadata fmtMeta = new FormatterMetadata(); fmtMeta.fromXML(fmtEle); formatters.put(fmtMeta.getType(), fmtMeta); } return formatters; }
From source file:com.pureinfo.dolphin.script.param.Parameter.java
License:Open Source License
/** * // w w w. jav a 2 s . c o m * @param _element * @param _bRequired * @throws PureException */ public static void readParameters(Element _element, Map _container, boolean _bRequired) throws PureException { if (_element == null && _bRequired) { throw new PureException(PureException.INVALID_REQUEST, "_element can't be null."); } List paramEleList = _element.elements(ELEMENT_PARAMETER); for (Iterator iter = paramEleList.iterator(); iter.hasNext();) { Element paramEle = (Element) iter.next(); Parameter param = new Parameter(); param.fromXML(paramEle); _container.put(param.getName(), param.getValue()); } }
From source file:com.pureinfo.dolphin.script.param.ParameterMetadata.java
License:Open Source License
/** * Get the metadatas of the parameters from a dom4j <code>Element</code> * // www . j a v a 2s . c o m * @param _element * a dom4j <code>Element</code> * @return @throws * Exception */ public static Map getParameterMetadatas(Element _element, boolean _bRequired) throws PureException { Map params = new HashMap(); if (_element == null) { if (_bRequired) { throw new PureException(PureException.INVALID_REQUEST, "_element can't be null."); } return params; } List paramEleList = _element.elements(ELEMENT_PARAMETER); for (Iterator iter = paramEleList.iterator(); iter.hasNext();) { Element paramEle = (Element) iter.next(); ParameterMetadata param = new ParameterMetadata(); param.fromXML(paramEle); params.put(param.getName(), param); } return params; }
From source file:com.pureinfo.dolphinview.common.model.ResourceMetadata.java
License:Open Source License
/** * @param _element//from ww w . j a va 2 s.co m * @throws PureException */ public static void readResources(Element _element, Map _container) throws PureException { CheckUtils.checkRequestNotNull(_element); List resEleList = _element.elements(ELEMENT_RESOURCE); for (Iterator iter = resEleList.iterator(); iter.hasNext();) { Element resEle = (Element) iter.next(); ResourceMetadata res = new ResourceMetadata(); res.fromXML(resEle); _container.put(res.getId(), res); } }
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 ww w . java 2 s.co m 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.force.runtime.engine.EngineServer.java
License:Open Source License
/** * Loads engine beans from resource./*from www. j a v a 2 s . c o m*/ * * @throws PureException * if failed. */ private void loadEngineBeans() throws PureException { logger.debug("engine server: to load beans from " + RESOURCE); String sFileName = ClassResourceUtil.mapFullPath(RESOURCE, false); if (sFileName != null) { Element xml = XMLUtil.fileToElement(sFileName); List list = xml.elements("engine"); Element element; EngineBean bean; for (int i = 0; i < list.size(); i++) { element = (Element) list.get(i); bean = new EngineBean(); bean.fromXML(element); m_hEngineBeans.put(bean.getId(), bean); } } logger.debug("engine server: loaded beans from " + sFileName); }