001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package makedep;
028:
029: public class FileName {
030: private String dir;
031: private String prefix;
032: private String stem;
033: private String suffix;
034: private String inverseDir;
035: private String altSuffix;
036:
037: private String dpss;
038: private String psa;
039: private String dpsa;
040: private String pss;
041:
042: private Platform plat;
043:
044: /** None of the passed strings may be null. */
045:
046: public FileName(Platform plat, String dir, String prefix,
047: String stem, String suffix, String inverseDir,
048: String altSuffix) {
049: if ((dir == null) || (prefix == null) || (stem == null)
050: || (suffix == null) || (inverseDir == null)
051: || (altSuffix == null)) {
052: throw new NullPointerException(
053: "All arguments must be non-null");
054: }
055:
056: this .plat = plat;
057:
058: this .dir = dir;
059: this .prefix = prefix;
060: this .stem = stem;
061: this .suffix = suffix;
062: this .inverseDir = inverseDir;
063: this .altSuffix = altSuffix;
064:
065: pss = prefix + stem + suffix;
066: dpss = dir + prefix + stem + suffix;
067: psa = prefix + stem + altSuffix;
068: dpsa = dir + prefix + stem + altSuffix;
069:
070: checkLength(plat);
071: }
072:
073: public void checkLength(Platform p) {
074: int len;
075: String s;
076: int suffLen = suffix.length();
077: int altSuffLen = altSuffix.length();
078: if (suffLen >= altSuffLen) {
079: len = suffLen;
080: s = suffix;
081: } else {
082: len = altSuffLen;
083: s = altSuffix;
084: }
085: len += prefix.length() + stem.length();
086: int lim = p.fileNameLengthLimit();
087: if (len > lim) {
088: p.fatalError(prefix + stem + s + " is too long: " + len
089: + " >= " + lim);
090: }
091: }
092:
093: public String dirPreStemSuff() {
094: return dpss;
095: }
096:
097: public String preStemSuff() {
098: return pss;
099: }
100:
101: public String dirPreStemAltSuff() {
102: return dpsa;
103: }
104:
105: public String preStemAltSuff() {
106: return psa;
107: }
108:
109: public FileName copyStem(String newStem) {
110: return new FileName(plat, dir, prefix, newStem, suffix,
111: inverseDir, altSuffix);
112: }
113:
114: String nameOfList() {
115: return stem;
116: }
117:
118: String getInvDir() {
119: return inverseDir;
120: }
121: }
|