Path: blob/master/sourcetools/com.ibm.uma/com/ibm/uma/om/VPath.java
6004 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;2223import com.ibm.uma.IPlatform;24import com.ibm.uma.UMA;25import com.ibm.uma.UMAException;26import com.ibm.uma.util.Logger;272829public class VPath extends PredicateList {3031public static final int TYPE_ROOT_PATH = 0;32public static final int TYPE_ARTIFACT = 1;33public static final int TYPE_MACRO = 2;34public static final int TYPE_RELATIVE_PATH = 3;353637int type = TYPE_ARTIFACT;38String path;39String macro;40String pattern;41boolean augmentObjects;42boolean augmentIncludes;4344public VPath(String containingFile) {45super(containingFile);46}4748public boolean isAugmentIncludes() {49return augmentIncludes;50}5152public void setAugmentIncludes(boolean augmentIncludes) {53this.augmentIncludes = augmentIncludes;54}5556public boolean isAugmentObjects() {57return augmentObjects;58}5960public void setAugmentObjects(boolean augmentObjects) {61this.augmentObjects = augmentObjects;62}6364public int getType() {65return type;66}6768public void setType(String typeString) {69if ( typeString.equalsIgnoreCase("rootpath") ) {70type = TYPE_ROOT_PATH;71} else if ( typeString.equalsIgnoreCase("artifact") ) {72type = TYPE_ARTIFACT;73} else if ( typeString.equalsIgnoreCase("relativepath") ) {74type = TYPE_RELATIVE_PATH;75} else if ( typeString.equalsIgnoreCase("macro") ) {76type = TYPE_MACRO;77}78}7980public String getPattern() {81if ( pattern == null ) return "%";82return pattern;83}8485public String getObjectFile() throws UMAException {86String objFile = "";87IPlatform platform = UMA.getUma().getPlatform();88String [] parts = pattern.split("\\.");89if ( parts.length == 1 ) {90objFile = pattern + platform.getObjectExtension();91} else {92for ( int i=0; i<parts.length-1; i++ ) {93objFile += parts[i];94}95objFile += platform.getObjectExtension();96}97return objFile;98}99100public void setFile(String file) {101this.pattern = file;102}103104public String getPath() {105return path;106}107108public void setPath(String path) {109this.path = path;110}111112@Override113public boolean evaluate() throws UMAException {114if ( !super.evaluate() ) return false;115if ( type == TYPE_MACRO ) {116macro = path;117path = UMA.getUma().getPlatform().replaceMacro(path);118type = TYPE_ARTIFACT;119}120if ( type == TYPE_ARTIFACT ) {121Artifact artifact = UMA.getUma().getArtifact(path);122if ( artifact == null ) {123/* in jvm.27 uma was updated to use an '_' instead of a '.' to define delimit scope from artifact name124* to support this change module.xml files were updated to change from '.' to '_' in jvm.27, older streams125* still use '.'.126*127* Add code here to detect the use of '.' and convert it to '_'.128* */129String underscorePath = path.replace('.', '_');130artifact = UMA.getUma().getArtifact(underscorePath);131if ( artifact == null ) {132// TODO turn this into hard-error vs. soft-error133if ( macro != null ) {134Logger.getLogger().println(Logger.WarningLog, "Warning: vpath path macro " + path + " does not expand to an artifact. [" + containingFile + "]");135} else {136Logger.getLogger().println(Logger.WarningLog, "Warning: vpath path " + path + " of type artifact not found. [" + containingFile + "]");137}138return false;139}140}141path = artifact.getContainingModule().getFullName();142type = TYPE_ROOT_PATH;143}144return true;145}146147}148149150