Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/sourcetools/com.ibm.jpp.preprocessor/com/ibm/jpp/om/ClassPathEntry.java
6004 views
1
/*******************************************************************************
2
* Copyright (c) 1999, 2019 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.jpp.om;
23
24
/**
25
* This class represents a classpath entry for use in the JPP Eclipse Plugin.
26
*/
27
public class ClassPathEntry {
28
private final String type;
29
private final String path;
30
private final String sourcePath;
31
private final boolean isExported;
32
33
/**
34
* Main constructor for ClassPathEntry
35
*
36
* @param path the path associated with this entry
37
* @param type the type of classpath
38
*/
39
public ClassPathEntry(String path, String type) {
40
this(path, type, null, false);
41
}
42
43
/**
44
* Main constructor for ClassPathEntry
45
*
46
* @param path the path associated with this entry
47
* @param type the type of classpath
48
* @param isExported <code>true</code> if this entry is contributed to dependent projects also, <code>false</code> otherwise
49
*/
50
public ClassPathEntry(String path, String type, boolean isExported) {
51
this(path, type, null, isExported);
52
}
53
54
/**
55
* Main constructor for ClassPathEntry
56
*
57
* @param path the path associated with this entry
58
* @param type the type of classpath
59
* @param sourcePath the source path associated with this entry
60
*/
61
public ClassPathEntry(String path, String type, String sourcePath) {
62
this(path, type, sourcePath, false);
63
}
64
65
/**
66
* Main constructor for ClassPathEntry
67
*
68
* @param path the path associated with this entry
69
* @param type the type of classpath
70
* @param sourcePath the source path associated with this entry
71
* @param isExported <code>true</code> if this entry is contributed to dependent projects also, <code>false</code> otherwise
72
*/
73
public ClassPathEntry(String path, String type, String sourcePath, boolean isExported) {
74
this.path = path;
75
this.type = type;
76
this.sourcePath = sourcePath;
77
this.isExported = isExported;
78
}
79
80
/**
81
* Returns this entry's path
82
*
83
* @return the path.
84
*/
85
public String getPath() {
86
return path;
87
}
88
89
/**
90
* Returns the short form of type of this classpath (one of: var, src, lib, pro, or con)
91
*
92
* @return the classpath type in short form.
93
*
94
* @see #isVariable()
95
* @see #isSource()
96
* @see #isLibrary()
97
* @see #isProject()
98
* @see #isContainer()
99
*
100
*/
101
public String getType() {
102
return type;
103
}
104
105
/**
106
* Returns the source path associated with this classpath
107
*
108
* @return the classpath's source path
109
*/
110
public String getSourcePath() {
111
return sourcePath;
112
}
113
114
/**
115
* Returns the classpath type
116
*
117
* @return the classpath type
118
*/
119
public String getTypeString() {
120
if (isVariable()) {
121
return "variable";
122
} else if (isSource()) {
123
return "source";
124
} else if (isLibrary()) {
125
return "library";
126
} else if (isProject()) {
127
return "project";
128
} else if (isContainer()) {
129
return "container";
130
} else {
131
return "unknown";
132
}
133
}
134
135
/**
136
* Returns whether or not this classpath sets up a variable or not
137
*
138
* @return <code>true</code> if this classpath sets up a variable, <code>false</code> otherwise
139
*/
140
public boolean isVariable() {
141
return (type.trim().equals("var"));
142
}
143
144
/**
145
* Returns whether or not this classpath points to a source folder or not
146
*
147
* @return <code>true</code> if this classpath points to a source folder, <code>false</code> otherwise
148
*/
149
public boolean isSource() {
150
return (type.trim().equals("src") && !(path.startsWith("/") || path.startsWith(":", 1)));
151
}
152
153
/**
154
* Returns whether or not this classpath points to a library or not
155
*
156
* @return <code>true</code> if this classpath points to a library, <code>false</code> otherwise
157
*/
158
public boolean isLibrary() {
159
return (type.trim().equals("lib"));
160
}
161
162
/**
163
* Returns whether or not this classpath points to a local library
164
*
165
* @return <code>true</code> if this points to a local library, <code>false</code> otherwise
166
*/
167
public boolean isLocalLibrary() {
168
return (type.trim().equals("lib") && !path.startsWith("/"));
169
}
170
171
/**
172
* Returns whether or not this classpath points to a project or not
173
*
174
* @return <code>true</code> if this classpath points to a project, <code>false</code> otherwise
175
*/
176
public boolean isProject() {
177
return (type.trim().equals("src") && path.startsWith("/"));
178
}
179
180
/**
181
* Returns whether or not this classpath points to a container or not
182
*
183
* @return <code>true</code> if this classpath points to a container, <code>false</code> otherwise
184
*/
185
public boolean isContainer() {
186
return (type.trim().equals("con"));
187
}
188
189
/**
190
* Returns whether or not this classpath is to be exported to dependent projects
191
*
192
* @return <code>true</code> if this entry is contributed to dependent projects also, <code>false</code> otherwise
193
*/
194
public boolean isExported() {
195
return isExported;
196
}
197
}
198
199