Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/sourcetools/com.ibm.uma/com/ibm/uma/om/parser/ModuleParser.java
6005 views
1
/*******************************************************************************
2
* Copyright (c) 2001, 2017 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* 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-exception
21
*******************************************************************************/
22
package com.ibm.uma.om.parser;
23
24
import java.util.Vector;
25
26
import org.w3c.dom.Document;
27
import org.w3c.dom.Element;
28
import org.w3c.dom.Node;
29
import org.w3c.dom.NodeList;
30
31
import com.ibm.uma.UMA;
32
import com.ibm.uma.UMAException;
33
import com.ibm.uma.om.Artifact;
34
import com.ibm.uma.om.Exports;
35
import com.ibm.uma.om.Flag;
36
import com.ibm.uma.om.Flags;
37
import com.ibm.uma.om.Module;
38
import com.ibm.uma.om.Objects;
39
40
41
public class ModuleParser {
42
43
static public Module parse(Document moduleXml, String modulePath) throws UMAException {
44
Module module = new Module(modulePath);
45
46
// Initialize the Module based on the XML document
47
Element elem = moduleXml.getDocumentElement();
48
NodeList nodeList = elem.getChildNodes();
49
for (int i = 0; i < nodeList.getLength(); i++) {
50
Node node = nodeList.item(i);
51
String nodeName = node.getLocalName();
52
if ( nodeName == null ) continue;
53
if ( nodeName.equalsIgnoreCase("artifact")) {
54
Artifact artifact = ArtifactParser.parse(node, module);
55
module.addArtifact(artifact);
56
UMA.getUma().addArtifact(artifact);
57
} else if ( nodeName.equalsIgnoreCase("exports")) {
58
Exports exps = ExportsParser.parse(node, module.getContainingFile());
59
module.addExports(exps.getGroup(), exps);
60
} else if ( nodeName.equalsIgnoreCase("objects")) {
61
Objects objs = ObjectsParser.parse(node, module.getContainingFile());
62
module.addObjects(objs.getGroup(), objs);
63
} else if ( nodeName.equalsIgnoreCase("exportlists")) {
64
Vector<Exports> exports = ExportlistsParser.parse(node, module.getContainingFile());
65
for (Exports exps : exports) {
66
module.addExports(exps.getGroup(), exps);
67
}
68
} else if ( nodeName.equalsIgnoreCase("objectlists")) {
69
Vector<Objects> objects = ObjectlistsParser.parse(node, module.getContainingFile());
70
for ( Objects objs : objects ) {
71
module.addObjects(objs.getGroup(), objs);
72
}
73
} else if ( nodeName.equalsIgnoreCase("flaglists")) {
74
Vector<Flags> flags = FlaglistsParser.parse(node, module.getContainingFile());
75
for ( Flags f : flags ) {
76
//System.out.println("Flag: " + (f == null ? "null" : f.getGroup()));
77
module.addFlags(f.getGroup(), f);
78
}
79
} else if ( nodeName.equalsIgnoreCase("flags")) {
80
Flags flags = FlagsParser.parse(node, module.getContainingFile());
81
//System.out.println("GROUP: " + flags.getGroup());
82
for (Flag f : flags.getFlags()) {
83
/*
84
if (f != null) {
85
System.out.println("FLAG: "+ f.getName());
86
} else {
87
System.out.println("NULL FLAG");
88
}
89
*/
90
}
91
module.addFlags(flags.getGroup(), flags);
92
}
93
}
94
Parser.populatePredicateList(nodeList, module);
95
return module;
96
}
97
98
}
99
100
101
102
103