List of usage examples for org.dom4j Element elementIterator
Iterator<Element> elementIterator(QName qName);
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 w w. j a va2 s . c om*/ 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.pureinfo.srm.view.function.IsOutlayPayoutPropertyEnabledFunctionHandler.java
License:Open Source License
/** * @see com.pureinfo.dolphinview.parser.function.FunctionHandlerDVImplBase#perform(java.lang.Object[], * com.pureinfo.dolphinview.context.model.IDVContext) *///from w ww . j av a2 s .c om public Object perform(Object[] _args, IDVContext _context) throws PureException { if (_args.length < MIN_ARG_NUM) { throw new PureException(ScriptExceptionTypes.FUNCTION_ARGS_NUM_NOTMATCH, "required " + MIN_ARG_NUM + " but actual " + _args.length); } String sFileName = ClassResourceUtil.mapFullPath("OutlayPayout.cfg.xml", true); String sProperty = (String) _args[PROPERTY_NAME]; String sResult = ""; Element m_root; Element singleElement; m_root = XMLUtil.fileToElement(sFileName); if (m_root == null) return ""; for (Iterator iter = m_root.elementIterator("property"); iter.hasNext();) { singleElement = (Element) iter.next(); if (XMLUtil.getAttributeValueTrim(singleElement, "name").equals(sProperty)) { sResult = XMLUtil.getAttributeValueTrim(singleElement, "enabled"); return new Boolean(sResult); } } return new Boolean(sResult); }
From source file:com.qagen.osfe.core.loaders.DelimitedColumnLoader.java
License:Apache License
public void load(Element parent) { delimitedColumnMap = new HashMap<String, DelimitedColumn>(); delimitedColumns = new ArrayList<DelimitedColumn>(); final Iterator it = parent.elementIterator(ELEMENT.delimitedColumn.name()); while (it.hasNext()) { final Element element = (Element) it.next(); final String name = DomReader.getRequiredValue(element, ATTRIBUTE.name.name()); final String type = DomReader.getRequiredValue(element, ATTRIBUTE.type.name()); final String format = DomReader.getValue(element, ATTRIBUTE.format.name()); final DelimitedColumn column = new DelimitedColumn(name, type, format); delimitedColumnMap.put(name, column); delimitedColumns.add(column);/*from www . ja va 2s . c om*/ } }
From source file:com.qagen.osfe.core.loaders.PhasesLoader.java
License:Apache License
public void load(Element parent) { list = new ArrayList<PhaseInfo>(); final Iterator it = parent.elementIterator(ELEMENT.phase.name()); while (it.hasNext()) { final Element element = (Element) it.next(); final String ref = DomReader.getRequiredValue(element, ATTRIBUTE.ref.name()); final Boolean enable = DomReader.getRequiredBooleanValue(element, ATTRIBUTE.enable.name()); list.add(new PhaseInfo(ref, enable)); }//from w ww .jav a 2 s. c om }
From source file:com.qagen.osfe.core.loaders.PropertiesLoader.java
License:Apache License
public void load(Element parent) { map = new HashMap<String, String>(); list = new ArrayList<Property>(); final Iterator it = parent.elementIterator(ELEMENT.property.name()); while (it.hasNext()) { final Element element = (Element) it.next(); final String name = DomReader.getRequiredValue(element, ATTRIBUTE.name.name()); final String value = DomReader.getRequiredValue(element, ATTRIBUTE.value.name()); final String type = DomReader.getRequiredValue(element, ATTRIBUTE.type.name()); final String format = DomReader.getValue(element, ATTRIBUTE.format.name()); map.put(name, value);/*from ww w .j av a 2 s . c o m*/ list.add(new Property(name, value, type, format)); } }
From source file:com.qagen.osfe.core.loaders.ReferencesLoader.java
License:Apache License
public void load(Element parent) { map = new HashMap<String, String>(); list = new ArrayList<Reference>(); final Iterator it = parent.elementIterator(ELEMENT.reference.name()); while (it.hasNext()) { final Element element = (Element) it.next(); final String name = DomReader.getRequiredValue(element, ATTRIBUTE.name.name()); final String reference = DomReader.getRequiredValue(element, ATTRIBUTE.ref.name()); map.put(name, reference);/*from www. j a v a 2 s . co m*/ list.add(new Reference(name, reference)); } }
From source file:com.qagen.osfe.core.loaders.SaxEventPhaseElementLoader.java
License:Apache License
/** * Contains the instructions for parsing data from child elements within * the parent element. If the element is complex, other loaders should * be used within this method to parse different sub elements. * * @param parent container of child element to parse. *///from w ww .j a v a 2s .c om public void load(Element parent) { phases = new ArrayList<SaxEventPhaseInfo>(); final Iterator it = parent.elementIterator(ELEMENT.saxEventPhase.name()); while (it.hasNext()) { final Element element = (Element) it.next(); final String nameSpace = DomReader.getRequiredValue(element, ATTRIBUTE.nameSpace.name()); final String eventType = DomReader.getRequiredValue(element, ATTRIBUTE.event.name()); final EventTypeEnum event = EventTypeEnum.valueOf(eventType); final List<PhaseInfo> phaseInfoList = loadPhases(element); final SaxEventPhaseInfo info = new SaxEventPhaseInfo(nameSpace, event, phaseInfoList); phases.add(info); } }
From source file:com.rohanclan.afae.modes.ModeReader.java
License:Open Source License
/** * Read in a mode file by filename// www. j a va 2s. c om * * @param filename */ @SuppressWarnings("unchecked") public void read(String filename) { SAXReader reader = new SAXReader(); Document doc = null; try { doc = reader.read(AfaeEditorTools.getFile(filename)); } catch (DocumentException e) { AfaePlugin.logError("read() on file " + filename, e, ModeReader.class); e.printStackTrace(); return; } catch (IOException ioe) { AfaePlugin.logError("read() on file " + filename, ioe, ModeReader.class); ioe.printStackTrace(); } Element root = doc.getRootElement(); // parse the properties (if they exist) if (root.element(TAG_PROPS) != null) { for (Iterator<Element> z = root.element(TAG_PROPS).elements(TAG_PROPERTY).iterator(); z.hasNext();) { Element singleprop = (Element) z.next(); String name = singleprop.attributeValue(ATTR_NAME, ""); String value = singleprop.attributeValue(ATTR_VALUE); // if we get the start and end comments set them into the mode if (name.equals(ATTR_VALUE_START_COMMENT)) { listener.setStartComment(value); } else if (name.equals(ATTR_VALUE_STOP_COMMENT)) { listener.setEndComment(value); } //Should we add the properties we don't understand? } } // Loop over all the rule in the mode file for (Iterator<Element> iter = root.elementIterator(TAG_RULES); iter.hasNext();) { Element rulesElement = (Element) iter.next(); createRule(rulesElement); /* * Because order of rules is important we must read the elements in * order instead of using elementIterators("SPAN", etc) */ List<Element> allTypes = rulesElement.elements(); for (Iterator<Element> allTypesI = allTypes.iterator(); allTypesI.hasNext();) { Element element = (Element) allTypesI.next(); // does a bit switch... createType(element); } } }
From source file:com.smartwork.im.utils.XMLProperties.java
License:Open Source License
/** * Return all values who's path matches the given property * name as a String array, or an empty array if the if there * are no children. This allows you to retrieve several values * with the same property name. For example, consider the * XML file entry:// w ww. ja va 2 s . c om * <pre> * <foo> * <bar> * <prop>some value</prop> * <prop>other value</prop> * <prop>last value</prop> * </bar> * </foo> * </pre> * If you call getProperties("foo.bar.prop") will return a string array containing * {"some value", "other value", "last value"}. * * @param name the name of the property to retrieve * @return all child property values for the given node name. */ public Iterator getChildProperties(String name) { String[] propName = parsePropertyName(name); // Search for this property by traversing down the XML heirarchy, // stopping one short. Element element = document.getRootElement(); for (int i = 0; i < propName.length - 1; i++) { element = element.element(propName[i]); if (element == null) { // This node doesn't match this part of the property name which // indicates this property doesn't exist so return empty array. return Collections.EMPTY_LIST.iterator(); } } // We found matching property, return names of children. Iterator iter = element.elementIterator(propName[propName.length - 1]); ArrayList<String> props = new ArrayList<String>(); while (iter.hasNext()) { props.add(((Element) iter.next()).getText()); } return props.iterator(); }
From source file:com.smartwork.im.utils.XMLProperties.java
License:Open Source License
/** * Sets a property to an array of values. Multiple values matching the same property * is mapped to an XML file as multiple elements containing each value. * For example, using the name "foo.bar.prop", and the value string array containing * {"some value", "other value", "last value"} would produce the following XML: * <pre>/* w ww .j a va 2s. co m*/ * <foo> * <bar> * <prop>some value</prop> * <prop>other value</prop> * <prop>last value</prop> * </bar> * </foo> * </pre> * * @param name the name of the property. * @param values the values for the property (can be empty but not null). */ public void setProperties(String name, List<String> values) { String[] propName = parsePropertyName(name); // Search for this property by traversing down the XML heirarchy, // stopping one short. Element element = document.getRootElement(); for (int i = 0; i < propName.length - 1; i++) { // If we don't find this part of the property in the XML heirarchy // we add it as a new node if (element.element(propName[i]) == null) { element.addElement(propName[i]); } element = element.element(propName[i]); } String childName = propName[propName.length - 1]; // We found matching property, clear all children. List toRemove = new ArrayList(); Iterator iter = element.elementIterator(childName); while (iter.hasNext()) { toRemove.add(iter.next()); } for (iter = toRemove.iterator(); iter.hasNext();) { element.remove((Element) iter.next()); } // Add the new children. for (String value : values) { element.addElement(childName).setText(value); } saveProperties(); // Generate event. Map<String, Object> params = new HashMap<String, Object>(); params.put("value", values); PropertyEventDispatcher.dispatchEvent(name, PropertyEventDispatcher.EventType.xml_property_set, params); }