Path: blob/master/sourcetools/com.ibm.jpp.preprocessor/com/ibm/jpp/om/ClassPathEntry.java
6004 views
/*******************************************************************************1* Copyright (c) 1999, 2019 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.jpp.om;2223/**24* This class represents a classpath entry for use in the JPP Eclipse Plugin.25*/26public class ClassPathEntry {27private final String type;28private final String path;29private final String sourcePath;30private final boolean isExported;3132/**33* Main constructor for ClassPathEntry34*35* @param path the path associated with this entry36* @param type the type of classpath37*/38public ClassPathEntry(String path, String type) {39this(path, type, null, false);40}4142/**43* Main constructor for ClassPathEntry44*45* @param path the path associated with this entry46* @param type the type of classpath47* @param isExported <code>true</code> if this entry is contributed to dependent projects also, <code>false</code> otherwise48*/49public ClassPathEntry(String path, String type, boolean isExported) {50this(path, type, null, isExported);51}5253/**54* Main constructor for ClassPathEntry55*56* @param path the path associated with this entry57* @param type the type of classpath58* @param sourcePath the source path associated with this entry59*/60public ClassPathEntry(String path, String type, String sourcePath) {61this(path, type, sourcePath, false);62}6364/**65* Main constructor for ClassPathEntry66*67* @param path the path associated with this entry68* @param type the type of classpath69* @param sourcePath the source path associated with this entry70* @param isExported <code>true</code> if this entry is contributed to dependent projects also, <code>false</code> otherwise71*/72public ClassPathEntry(String path, String type, String sourcePath, boolean isExported) {73this.path = path;74this.type = type;75this.sourcePath = sourcePath;76this.isExported = isExported;77}7879/**80* Returns this entry's path81*82* @return the path.83*/84public String getPath() {85return path;86}8788/**89* Returns the short form of type of this classpath (one of: var, src, lib, pro, or con)90*91* @return the classpath type in short form.92*93* @see #isVariable()94* @see #isSource()95* @see #isLibrary()96* @see #isProject()97* @see #isContainer()98*99*/100public String getType() {101return type;102}103104/**105* Returns the source path associated with this classpath106*107* @return the classpath's source path108*/109public String getSourcePath() {110return sourcePath;111}112113/**114* Returns the classpath type115*116* @return the classpath type117*/118public String getTypeString() {119if (isVariable()) {120return "variable";121} else if (isSource()) {122return "source";123} else if (isLibrary()) {124return "library";125} else if (isProject()) {126return "project";127} else if (isContainer()) {128return "container";129} else {130return "unknown";131}132}133134/**135* Returns whether or not this classpath sets up a variable or not136*137* @return <code>true</code> if this classpath sets up a variable, <code>false</code> otherwise138*/139public boolean isVariable() {140return (type.trim().equals("var"));141}142143/**144* Returns whether or not this classpath points to a source folder or not145*146* @return <code>true</code> if this classpath points to a source folder, <code>false</code> otherwise147*/148public boolean isSource() {149return (type.trim().equals("src") && !(path.startsWith("/") || path.startsWith(":", 1)));150}151152/**153* Returns whether or not this classpath points to a library or not154*155* @return <code>true</code> if this classpath points to a library, <code>false</code> otherwise156*/157public boolean isLibrary() {158return (type.trim().equals("lib"));159}160161/**162* Returns whether or not this classpath points to a local library163*164* @return <code>true</code> if this points to a local library, <code>false</code> otherwise165*/166public boolean isLocalLibrary() {167return (type.trim().equals("lib") && !path.startsWith("/"));168}169170/**171* Returns whether or not this classpath points to a project or not172*173* @return <code>true</code> if this classpath points to a project, <code>false</code> otherwise174*/175public boolean isProject() {176return (type.trim().equals("src") && path.startsWith("/"));177}178179/**180* Returns whether or not this classpath points to a container or not181*182* @return <code>true</code> if this classpath points to a container, <code>false</code> otherwise183*/184public boolean isContainer() {185return (type.trim().equals("con"));186}187188/**189* Returns whether or not this classpath is to be exported to dependent projects190*191* @return <code>true</code> if this entry is contributed to dependent projects also, <code>false</code> otherwise192*/193public boolean isExported() {194return isExported;195}196}197198199