Path: blob/master/sourcetools/com.ibm.uma/com/ibm/uma/om/parser/ModuleParser.java
6005 views
/*******************************************************************************1* Copyright (c) 2001, 2017 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/21package com.ibm.uma.om.parser;2223import java.util.Vector;2425import org.w3c.dom.Document;26import org.w3c.dom.Element;27import org.w3c.dom.Node;28import org.w3c.dom.NodeList;2930import com.ibm.uma.UMA;31import com.ibm.uma.UMAException;32import com.ibm.uma.om.Artifact;33import com.ibm.uma.om.Exports;34import com.ibm.uma.om.Flag;35import com.ibm.uma.om.Flags;36import com.ibm.uma.om.Module;37import com.ibm.uma.om.Objects;383940public class ModuleParser {4142static public Module parse(Document moduleXml, String modulePath) throws UMAException {43Module module = new Module(modulePath);4445// Initialize the Module based on the XML document46Element elem = moduleXml.getDocumentElement();47NodeList nodeList = elem.getChildNodes();48for (int i = 0; i < nodeList.getLength(); i++) {49Node node = nodeList.item(i);50String nodeName = node.getLocalName();51if ( nodeName == null ) continue;52if ( nodeName.equalsIgnoreCase("artifact")) {53Artifact artifact = ArtifactParser.parse(node, module);54module.addArtifact(artifact);55UMA.getUma().addArtifact(artifact);56} else if ( nodeName.equalsIgnoreCase("exports")) {57Exports exps = ExportsParser.parse(node, module.getContainingFile());58module.addExports(exps.getGroup(), exps);59} else if ( nodeName.equalsIgnoreCase("objects")) {60Objects objs = ObjectsParser.parse(node, module.getContainingFile());61module.addObjects(objs.getGroup(), objs);62} else if ( nodeName.equalsIgnoreCase("exportlists")) {63Vector<Exports> exports = ExportlistsParser.parse(node, module.getContainingFile());64for (Exports exps : exports) {65module.addExports(exps.getGroup(), exps);66}67} else if ( nodeName.equalsIgnoreCase("objectlists")) {68Vector<Objects> objects = ObjectlistsParser.parse(node, module.getContainingFile());69for ( Objects objs : objects ) {70module.addObjects(objs.getGroup(), objs);71}72} else if ( nodeName.equalsIgnoreCase("flaglists")) {73Vector<Flags> flags = FlaglistsParser.parse(node, module.getContainingFile());74for ( Flags f : flags ) {75//System.out.println("Flag: " + (f == null ? "null" : f.getGroup()));76module.addFlags(f.getGroup(), f);77}78} else if ( nodeName.equalsIgnoreCase("flags")) {79Flags flags = FlagsParser.parse(node, module.getContainingFile());80//System.out.println("GROUP: " + flags.getGroup());81for (Flag f : flags.getFlags()) {82/*83if (f != null) {84System.out.println("FLAG: "+ f.getName());85} else {86System.out.println("NULL FLAG");87}88*/89}90module.addFlags(flags.getGroup(), flags);91}92}93Parser.populatePredicateList(nodeList, module);94return module;95}9697}9899100101102103