Java Code Examples for org.w3c.dom.Element#getElementsByTagName()

The following examples show how to use org.w3c.dom.Element#getElementsByTagName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModuleComboParameter.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void loadValueFromXML(Element xmlElement) {
  NodeList items = xmlElement.getElementsByTagName("module");

  for (int i = 0; i < items.getLength(); i++) {
    Element moduleElement = (Element) items.item(i);
    String name = moduleElement.getAttribute("name");
    for (int j = 0; j < modulesWithParams.length; j++) {
      if (modulesWithParams[j].getModule().getName().equals(name)) {
        ParameterSet moduleParameters = modulesWithParams[j].getParameterSet();
        if (moduleParameters == null)
          continue;
        moduleParameters.loadValuesFromXML((Element) items.item(i));
      }
    }
  }
  String selectedAttr = xmlElement.getAttribute("selected");
  for (int j = 0; j < modulesWithParams.length; j++) {
    if (modulesWithParams[j].getModule().getName().equals(selectedAttr)) {
      value = modulesWithParams[j];
    }
  }
}
 
Example 2
Source File: SettingsReader.java    From jeveassets with GNU General Public License v2.0 6 votes vote down vote up
private void parseTags(Element tagsElement, Settings settings) throws XmlException {
	NodeList tagNodes = tagsElement.getElementsByTagName("tag");
	for (int a = 0; a < tagNodes.getLength(); a++) {
		Element tagNode = (Element) tagNodes.item(a);
		String name = getString(tagNode, "name");
		String background = getString(tagNode, "background");
		String foreground = getString(tagNode, "foreground");

		TagColor color = new TagColor(background, foreground);
		Tag tag = new Tag(name, color);
		settings.getTags().put(tag.getName(), tag);

		NodeList idNodes = tagNode.getElementsByTagName("tagid");
		for (int b = 0; b < idNodes.getLength(); b++) {
			Element idNode = (Element) idNodes.item(b);
			String tool = getString(idNode, "tool");
			long id = getLong(idNode, "id");

			TagID tagID = new TagID(tool, id);
			tag.getIDs().add(tagID);
			settings.getTags(tagID).add(tag);
		}
	}
}
 
Example 3
Source File: XMLLoader.java    From xlsbeans with Apache License 2.0 6 votes vote down vote up
private static Map<String, String> getAttributes(Element annotations) throws XMLException {
  Map<String, String> map = new HashMap<String, String>();
  NodeList attrs = annotations.getElementsByTagName("attribute");
  for (int i = 0; i < attrs.getLength(); i++) {
    Element attr = (Element) attrs.item(i);
    String name = attr.getAttribute("name");
    String value = getChildText(attr);

    if (name == null || name.length() == 0) {
      throw new XMLException("'name' attribute is required.");
    }

    map.put(name, value);
  }
  return map;
}
 
Example 4
Source File: SqlXMLConfigParse.java    From sagacity-sqltoy with Apache License 2.0 6 votes vote down vote up
/**
 * @todo 解析Link 查询
 * @param sqlToyConfig
 * @param link
 */
private static void parseLink(SqlToyConfig sqlToyConfig, NodeList linkNode) {
	if (linkNode == null || linkNode.getLength() == 0)
		return;
	Element link = (Element) linkNode.item(0);
	LinkModel linkModel = new LinkModel();
	linkModel.setColumn(link.getAttribute("column"));
	if (link.hasAttribute("id-column")) {
		linkModel.setIdColumn(link.getAttribute("id-column"));
	}
	if (link.hasAttribute("sign")) {
		linkModel.setSign(link.getAttribute("sign"));
	}
	NodeList nodeList = link.getElementsByTagName("decorate");
	if (nodeList.getLength() > 0) {
		Element decorateElt = (Element) nodeList.item(0);
		if (decorateElt.hasAttribute("align")) {
			linkModel.setDecorateAlign(decorateElt.getAttribute("align").toLowerCase());
		}
		linkModel.setDecorateAppendChar(decorateElt.getAttribute("char"));
		linkModel.setDecorateSize(Integer.parseInt(decorateElt.getAttribute("size")));
	}
	sqlToyConfig.setLinkModel(linkModel);
}
 
Example 5
Source File: DefaultTeXFontParser.java    From FlexibleRichTextView with Apache License 2.0 6 votes vote down vote up
public FontInfo[] parseFontDescriptions(FontInfo[] fi)
		throws ResourceParseException, IOException {
	Element fontDescriptions = (Element) root.getElementsByTagName(
			"FontDescriptions").item(0);
	if (fontDescriptions != null) { // element present
		NodeList list = fontDescriptions.getElementsByTagName("Metrics");
		for (int i = 0; i < list.getLength(); i++) {
			// get required string attribute
			String include = getAttrValueAndCheckIfNotNull("include",
					(Element) list.item(i));
			InputStream is = null;
			if (base == null) {
				fi = parseFontDescriptions(fi, is = AjLatexMath
						.getAssetManager().open(include), include);
			} else {
				fi = parseFontDescriptions(fi, is = AjLatexMath
						.getAssetManager().open(include), include);
			}
			is.close();
		}
	}
	return fi;
}
 
Example 6
Source File: ReadAssistLogic.java    From erflute with Apache License 2.0 5 votes vote down vote up
public double getDoubleValue(Element element, String tagname) {
    final NodeList nodeList = element.getElementsByTagName(tagname);
    if (nodeList.getLength() == 0) {
        return 0;
    }
    final Node node = nodeList.item(0);
    if (node.getFirstChild() == null) {
        return 0;
    }
    final String value = node.getFirstChild().getNodeValue();
    return Double.valueOf(value).doubleValue();
}
 
Example 7
Source File: KursBot.java    From java-telegram-bot-api with Apache License 2.0 5 votes vote down vote up
private String cbkurses() {
    String url = "http://www.cbr.ru/scripts/XML_daily.asp";
    String result = "ЦБ";
    try {
        String xml_str = readStringFromUrl(url);
        DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document doc = db.parse(new InputSource(new StringReader(xml_str)));

        Element root = (Element) doc.getElementsByTagName("ValCurs").item(0);
        String date = root.getAttribute("Date");
        String usd = "", eur = "";
        ;
        NodeList valutes = root.getElementsByTagName("Valute");
        for (int i = 0; i < valutes.getLength(); i++) {
            Element valute = (Element) valutes.item(i);
            if (valute.getAttribute("ID").equals("R01235")) {
                usd = valute.getElementsByTagName("Value").item(0).getFirstChild().getNodeValue();
            } else if (valute.getAttribute("ID").equals("R01239")) {
                eur = valute.getElementsByTagName("Value").item(0).getFirstChild().getNodeValue();
            }
        }
        return result + " на " + date + "\nДоллар : " + usd + "\nЕвро : " + eur;

    } catch (IOException | ParserConfigurationException | SAXException e) {
        e.printStackTrace();
    }
    return result;
}
 
Example 8
Source File: XMLResponse.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns a string from an xml element.
 * 
 * @param ele
 * @param tagName
 * @return
 */
protected String getTextValueFromElements(Element ele, String tagName) {
    String textVal = null;
    NodeList nl = ele.getElementsByTagName(tagName);
    if (nl != null && nl.getLength() > 0) {
        Element el = (Element) nl.item(0);
        textVal = el.getFirstChild().getNodeValue();
    }
    return textVal;
}
 
Example 9
Source File: MessageBuilder.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * <p>
 * Loop through descriptors and write appropriate output to the properties
 * and dita files.
 * </p>
 */
private void processMessages(File input, PrintWriter propertiesPW) throws Exception {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(input);
    Element root = doc.getDocumentElement();    // framing "messages" element
    NodeList sections = root.getElementsByTagName("section");

    propertiesPW.println(PROPERTIES_BOILERPLATE);
    processSections(propertiesPW, sections);
}
 
Example 10
Source File: XmlUtils.java    From alipay-sdk with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the immediately child elements list from the parent element.
 *
 * @param parent the parent element in the element tree
 * @param tagName the specified tag name
 * @return the NOT NULL immediately child elements list
 */
public static List<Element> getChildElements(Element parent, String tagName) {
    NodeList nodes = parent.getElementsByTagName(tagName);
    List<Element> elements = new ArrayList<Element>();

    for (int i = 0; i < nodes.getLength(); i++) {
        Node node = nodes.item(i);
        if (node instanceof Element && node.getParentNode() == parent) {
            elements.add((Element) node);
        }
    }

    return elements;
}
 
Example 11
Source File: AlbumsPluginImpl.java    From socialauth with MIT License 5 votes vote down vote up
private String getUserId() throws Exception {
	if (this.userId != null) {
		return this.userId;
	} else {
		String profileUrl = String.format(PROFILE_URL, providerSupport
				.getAccessGrant().getKey());
		Response response = providerSupport.api(profileUrl,
				MethodType.GET.toString(), null, null, null);
		Element root;
		try {
			root = XMLParseUtil.loadXmlResource(response.getInputStream());
		} catch (Exception e) {
			throw new ServerDataException(
					"Failed to parse the User from response." + profileUrl,
					e);
		}
		String id = "";
		if (root != null) {
			NodeList uList = root.getElementsByTagName("user");
			if (uList != null && uList.getLength() > 0) {
				Element user = (Element) uList.item(0);
				id = user.getAttribute("nsid");
			}

		}
		return id;
	}
}
 
Example 12
Source File: CommonsManagerImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * From EntityProducer
 */
public String merge(String siteId, Element root, String archivePath, String fromSiteId, Map attachmentNames, Map userIdTrans, Set userListAllowImport) {

    log.debug("merge(siteId:{},root tagName:{},archivePath:{},fromSiteId:{})", siteId, root.getTagName(), archivePath, fromSiteId);

    StringBuilder results = new StringBuilder();

    int postCount = 0;

    NodeList postNodes = root.getElementsByTagName(XmlDefs.POST);
    final int numberPosts = postNodes.getLength();

    for (int i = 0; i < numberPosts; i++) {
        Node child = postNodes.item(i);
        if (child.getNodeType() != Node.ELEMENT_NODE) {
            log.error("Post nodes should be elements. Skipping ...");
            continue;
        }

        Element postElement = (Element) child;

        Post post = new Post();
        post.fromXml(postElement);
        post.setSiteId(siteId);

        savePost(post);

        for (Comment comment : post.getComments()) {
            comment.setPostId(post.getId());
            saveComment(siteId, comment);
        }

        postCount++;
    }

    results.append("Stored " + postCount + " posts.");

    return results.toString();
}
 
Example 13
Source File: SiftsXMLParser.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * <entity type="protein" entityId="A">
 */
private SiftsEntity getSiftsEntity(Element empEl) {

	//for each <employee> element get text or int values of
	//name ,id, age and name

	String type = empEl.getAttribute("type");
	String entityId = empEl.getAttribute("entityId");

	//Create a new Employee with the value read from the xml nodes
	SiftsEntity entity = new SiftsEntity(type,entityId);

	// get nodelist of segments...
	NodeList nl = empEl.getElementsByTagName("segment");
	if(nl != null && nl.getLength() > 0) {
		for(int i = 0 ; i < nl.getLength();i++) {

			//get the entity element
			Element el = (Element)nl.item(i);

			SiftsSegment s = getSiftsSegment(el);

			logger.debug("new segment: " + s);
			entity.addSegment(s);

		}
	}

	logger.debug("new SIFTS entity: " + entity);
	return entity;
}
 
Example 14
Source File: FileConfigurationParser.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void parseBrokerPlugins(final Element e, final Configuration config) {
   NodeList brokerPlugins = e.getElementsByTagName(BROKER_PLUGINS_ELEMENT_NAME);
   if (brokerPlugins.getLength() != 0) {
      Element node = (Element) brokerPlugins.item(0);
      NodeList list = node.getElementsByTagName(BROKER_PLUGIN_ELEMENT_NAME);
      for (int i = 0; i < list.getLength(); i++) {
         ActiveMQServerPlugin plugin = parseActiveMQServerPlugin(list.item(i));
         config.registerBrokerPlugin(plugin);
      }
   }
}
 
Example 15
Source File: DomainSuffixesReader.java    From sparkler with Apache License 2.0 4 votes vote down vote up
void readCCTLDs(DomainSuffixes tldEntries, Element el) throws IOException {
    NodeList children = el.getElementsByTagName("tld");
    for (int i = 0; i < children.getLength(); i++) {
        tldEntries.addDomainSuffix(readCCTLD((Element) children.item(i)));
    }
}
 
Example 16
Source File: XMLRelationSerializer.java    From MogwaiERDesignerNG with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void deserialize(Model aModel, Document aDocument) {

	// And finally, parse the relations
	NodeList theElements = aDocument.getElementsByTagName(RELATION);
	for (int i = 0; i < theElements.getLength(); i++) {
		Element theElement = (Element) theElements.item(i);

		Relation theRelation = new Relation();
		theRelation.setOwner(aModel);
		deserializeProperties(theElement, theRelation);
		deserializeCommentElement(theElement, theRelation);

		theRelation.setOnDelete(CascadeType.fromString(theElement.getAttribute(ONDELETE)));
		theRelation.setOnUpdate(CascadeType.fromString(theElement.getAttribute(ONUPDATE)));

		String theStartTableID = theElement.getAttribute(IMPORTINGTABLEREFID);
		String theEndTableID = theElement.getAttribute(EXPORTINGTABLEREFID);

		Table theTempTable = aModel.getTables().findBySystemId(theStartTableID);
		if (theTempTable == null) {
			throw new IllegalArgumentException("Cannot find table with id " + theStartTableID);
		}
		theRelation.setImportingTable(theTempTable);
		theTempTable = aModel.getTables().findBySystemId(theEndTableID);
		if (theTempTable == null) {
			throw new IllegalArgumentException("Cannot find table with id " + theEndTableID);
		}

		theRelation.setExportingTable(theTempTable);

		Index thePrimaryKey = theRelation.getExportingTable().getPrimarykey();

		// Parse the mapping
		NodeList theMappings = theElement.getElementsByTagName(MAPPING);
		for (int j = 0; j < theMappings.getLength(); j++) {
			Element theAttributeElement = (Element) theMappings.item(j);

			String theImportingAttributeId = theAttributeElement.getAttribute(IMPORTINGATTRIBUTEREFID);
			String theExportingExpressionId = theAttributeElement.getAttribute(EXPORTINGEXPRESSIONREFID);

			Attribute<Table> theImportingAttribute = aModel.getTables().findAttributeBySystemId(theImportingAttributeId);
			if (theImportingAttribute == null) {
				throw new IllegalArgumentException("Cannot find attribute with id " + theImportingAttributeId);
			}

			IndexExpression theExpression = thePrimaryKey.getExpressions().findBySystemId(theExportingExpressionId);
			if (theExpression == null) {
				throw new IllegalArgumentException("Cannot find expression with id " + theExportingExpressionId);
			}
			theRelation.getMapping().put(theExpression, theImportingAttribute);
		}

		aModel.getRelations().add(theRelation);
	}
}
 
Example 17
Source File: DefaultTeXFontParser.java    From AndroidMathKeyboard with Apache License 2.0 4 votes vote down vote up
public String[] parseDefaultTextStyleMappings()
		throws ResourceParseException {
	String[] res = new String[4];
	Element defaultTextStyleMappings = (Element) root.getElementsByTagName(
			"DefaultTextStyleMapping").item(0);
	if (defaultTextStyleMappings == null)
		return res;
	else { // element present
			// iterate all mappings
		NodeList list = defaultTextStyleMappings
				.getElementsByTagName("MapStyle");
		for (int i = 0; i < list.getLength(); i++) {
			Element mapping = (Element) list.item(i);
			// get range name and check if it's valid
			String code = getAttrValueAndCheckIfNotNull("code", mapping);
			Object codeMapping = rangeTypeMappings.get(code);
			if (codeMapping == null) // unknown range name
				throw new XMLResourceParseException(RESOURCE_NAME,
						"MapStyle", "code",
						"contains an unknown \"range name\" '" + code
								+ "'!");
			// get mapped style and check if it exists
			String textStyleName = getAttrValueAndCheckIfNotNull(
					"textStyle", mapping);
			Object styleMapping = parsedTextStyles.get(textStyleName);
			if (styleMapping == null) // unknown text style
				throw new XMLResourceParseException(RESOURCE_NAME,
						"MapStyle", "textStyle",
						"contains an unknown text style '" + textStyleName
								+ "'!");
			// now check if the range is defined within the mapped text
			// style
			CharFont[] charFonts = parsedTextStyles.get(textStyleName);
			int index = ((Integer) codeMapping).intValue();
			if (charFonts[index] == null) // range not defined
				throw new XMLResourceParseException(RESOURCE_NAME
						+ ": the default text style mapping '"
						+ textStyleName + "' for the range '" + code
						+ "' contains no mapping for that range!");
			else
				// everything OK, put mapping in table
				res[index] = textStyleName;
		}
	}
	return res;
}
 
Example 18
Source File: SiblingsFileWrapper.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public List<String> getLevelSiblings(String dimensionName, String hierarchyName, String levelName) {

		List<String> siblingsNames = new ArrayList<String>();

		// <dimension> get dimensions elements
		NodeList dimensions = getDimensions(document);
		for (int i = 0; i < dimensions.getLength(); i++) {
			Node dimension = dimensions.item(i);

			// logger.debug("\nCurrent Element :" + dimension.getNodeName());

			if (dimension.getNodeType() == Node.ELEMENT_NODE) {
				Element dimensionElement = (Element) dimension;
				String currentDimensionName = dimensionElement.getAttribute("name");
				// logger.debug("Dimension name : " + currentDimensionName);
				if (currentDimensionName.equals(dimensionName)) {
					// <hierarchies> get hierarchies elements of the specific dimension (dimensionName)
					NodeList hierarchies = dimensionElement.getElementsByTagName("hierarchies");
					for (int j = 0; j < hierarchies.getLength(); j++) {
						Node hierarchiesNode = hierarchies.item(j);
						// <hierarchy> get hierarchy nodes of hierarchiesNode
						NodeList hierarchyNodes = hierarchiesNode.getChildNodes();
						for (int y = 0; y < hierarchyNodes.getLength(); y++) {
							Node hierarchy = hierarchyNodes.item(y);

							if (hierarchy.getNodeType() == Node.ELEMENT_NODE) {
								Element hierarchyElement = (Element) hierarchy;
								String hierarchyElementName = hierarchyElement.getAttribute("name");
								// logger.debug("Hierarchy name : " + hierarchyElementName);
								if (hierarchyElementName.equals(hierarchyName)) {
									// <level> get level elements of the specific hierarchy (hierarchyName)
									NodeList levelNodes = hierarchyElement.getElementsByTagName("level");
									for (int z = 0; z < levelNodes.getLength(); z++) {
										Node levelNode = levelNodes.item(z);

										if (levelNode.getNodeType() == Node.ELEMENT_NODE) {
											Element levelElement = (Element) levelNode;
											String levelElementName = levelElement.getAttribute("name");
											// logger.debug("Level name : " + levelElementName);
											if (levelElementName.equals(levelName)) {
												// Found searched level
												siblingsNames = getColumnsNames(levelElement);
												return siblingsNames;
											}
										}

									}
								}
							}
						}

					}
				}

			}
		}

		return siblingsNames;

	}
 
Example 19
Source File: ForumPostConfig.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
public void parseXML(Element element) {
	this.id = element.getAttribute("id");
	this.parent = element.getAttribute("parent");
	this.forum = element.getAttribute("forum");
	this.views = element.getAttribute("views");
	this.dailyViews = element.getAttribute("dailyViews");
	this.weeklyViews = element.getAttribute("weeklyViews");
	this.monthlyViews = element.getAttribute("monthlyViews");
	this.isAdmin = Boolean.valueOf(element.getAttribute("isAdmin"));
	this.replyCount = element.getAttribute("replyCount");
	this.isFlagged = Boolean.valueOf(element.getAttribute("isFlagged"));
	this.isFeatured = Boolean.valueOf(element.getAttribute("isFeatured"));
	this.creator = element.getAttribute("creator");
	this.creationDate = element.getAttribute("creationDate");
	if (element.getAttribute("thumbsUp") != null && element.getAttribute("thumbsUp").trim().length() > 0) {
		this.thumbsUp = Integer.valueOf(element.getAttribute("thumbsUp"));
	}
	if (element.getAttribute("thumbsDown") != null && element.getAttribute("thumbsDown").trim().length() > 0) {
		this.thumbsDown = Integer.valueOf(element.getAttribute("thumbsDown"));
	}
	if (element.getAttribute("stars") != null && element.getAttribute("stars").trim().length() > 0) {
		this.stars = element.getAttribute("stars");
	}
	
	Node node = element.getElementsByTagName("summary").item(0);
	if (node != null) {
		this.summary = node.getTextContent();
	}
	node = element.getElementsByTagName("details").item(0);
	if (node != null) {
		this.details = node.getTextContent();
	}
	node = element.getElementsByTagName("detailsText").item(0);
	if (node != null) {
		this.detailsText = node.getTextContent();
	}
	node = element.getElementsByTagName("topic").item(0);
	if (node != null) {
		this.topic = node.getTextContent();
	}
	node = element.getElementsByTagName("tags").item(0);
	if (node != null) {
		this.tags = node.getTextContent();
	}
	node = element.getElementsByTagName("flaggedReason").item(0);
	if (node != null) {
		this.flaggedReason = node.getTextContent();
	}
	node = element.getElementsByTagName("avatar").item(0);
	if (node != null) {
		this.avatar = node.getTextContent();
	}
	NodeList nodes = element.getElementsByTagName("replies");
	if (nodes != null && nodes.getLength() > 0) {
		this.replies = new ArrayList<ForumPostConfig>();
		for (int index = 0; index < nodes.getLength(); index++) {
			Element reply = (Element)nodes.item(index);
			ForumPostConfig config = new ForumPostConfig();
			config.parseXML(reply);
			this.replies.add(config);
		}
	}
}
 
Example 20
Source File: ToolConfigurationService.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
void loadToolGroups(InputStream in) {
    Document doc = Xml.readDocumentFromStream(in);
    Element root = doc.getDocumentElement();
    if (!root.getTagName().equals("toolGroups")) {
        log.info("loadToolGroups: invalid root element (expecting \"toolGroups\"): " + root.getTagName());
        return;
    }

    NodeList groupNodes = root.getElementsByTagName("group");
    if (groupNodes != null) {
        for (int k = 0; k < groupNodes.getLength(); k++) {
            Node g_node = groupNodes.item(k);
            if (g_node.getNodeType() != Node.ELEMENT_NODE) continue;
            Element g_element = (Element) g_node;
            String groupName = StringUtils.trimToNull(g_element.getAttribute("name"));
            //
            if ((groupName != null)) {
                // group of this name already in map?
                List<String> groupList = m_toolGroups.get(groupName);
                if (groupList == null) {
                    groupList = new Vector<>();
                    m_toolGroups.put(groupName, groupList);
                }
                // add tools
                NodeList tools = g_element.getElementsByTagName("tool");
                final int toolCount = tools.getLength();
                for (int j = 0; j < toolCount; j++) {
                    Element toolElement = (Element) tools.item(j);
                    // add this tool
                    String toolId = toolElement.getAttribute("id");
                    groupList.add(toolId);
                    String req = StringUtils.trimToNull(toolElement.getAttribute("required"));
                    if ((req != null) && (Boolean.TRUE.toString().equalsIgnoreCase(req))) {
                        List<String> reqList = m_toolGroupRequired.get(groupName);
                        if (reqList == null) {
                            reqList = new ArrayList<>();
                            m_toolGroupRequired.put(groupName, reqList);
                        }
                        reqList.add(toolId);
                    }
                    String sel = StringUtils.trimToNull(toolElement.getAttribute("selected"));
                    if ((sel != null) && (Boolean.TRUE.toString().equalsIgnoreCase(sel))) {
                        List<String> selList = m_toolGroupSelected.get(groupName);
                        if (selList == null) {
                            selList = new ArrayList<>();
                            m_toolGroupSelected.put(groupName, selList);
                        }
                        selList.add(toolId);
                    }
                }
                // add group to category(s)
                String groupCategories = StringUtils.trimToNull(g_element.getAttribute("category"));
                if (groupCategories != null) {
                    List<String> list = new ArrayList<>(Arrays.asList(groupCategories.split(",")));
                    //noinspection ForLoopReplaceableByForEach
                    for (Iterator<String> itr = list.iterator(); itr.hasNext(); ) {
                        String catName = itr.next();
                        List<String> groupCategoryList = m_toolGroupCategories.get(catName);
                        if (groupCategoryList == null) {
                            groupCategoryList = new ArrayList<>();
                            m_toolGroupCategories.put(catName, groupCategoryList);
                        }
                        groupCategoryList.add(groupName);
                    }
                }
            }
        }
    }
}