0
|
1 /*
|
|
2 * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 *
|
|
5 * This code is free software; you can redistribute it and/or modify it
|
|
6 * under the terms of the GNU General Public License version 2 only, as
|
|
7 * published by the Free Software Foundation.
|
|
8 *
|
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 * version 2 for more details (a copy is included in the LICENSE file that
|
|
13 * accompanied this code).
|
|
14 *
|
|
15 * You should have received a copy of the GNU General Public License version
|
|
16 * 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 *
|
|
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 * have any questions.
|
|
22 *
|
|
23 */
|
|
24
|
|
25 public class FileName {
|
|
26 private String dir;
|
|
27 private String prefix;
|
|
28 private String stem;
|
|
29 private String suffix;
|
|
30 private String inverseDir;
|
|
31 private String altSuffix;
|
|
32
|
|
33 private String dpss;
|
|
34 private String psa;
|
|
35 private String dpsa;
|
|
36 private String pss;
|
|
37
|
|
38 private Platform plat;
|
|
39
|
|
40 /** None of the passed strings may be null. */
|
|
41
|
|
42 public FileName(Platform plat, String dir, String prefix,
|
|
43 String stem, String suffix,
|
|
44 String inverseDir, String altSuffix) {
|
|
45 if ((dir == null) ||
|
|
46 (prefix == null) ||
|
|
47 (stem == null) ||
|
|
48 (suffix == null) ||
|
|
49 (inverseDir == null) ||
|
|
50 (altSuffix == null)) {
|
|
51 throw new NullPointerException("All arguments must be non-null");
|
|
52 }
|
|
53
|
|
54 this.plat = plat;
|
|
55
|
|
56 this.dir = dir;
|
|
57 this.prefix = prefix;
|
|
58 this.stem = stem;
|
|
59 this.suffix = suffix;
|
|
60 this.inverseDir = inverseDir;
|
|
61 this.altSuffix = altSuffix;
|
|
62
|
|
63 pss = prefix + stem + suffix;
|
|
64 dpss = dir + prefix + stem + suffix;
|
|
65 psa = prefix + stem + altSuffix;
|
|
66 dpsa = dir + prefix + stem + altSuffix;
|
|
67
|
|
68 checkLength(plat);
|
|
69 }
|
|
70
|
|
71 public void checkLength(Platform p) {
|
|
72 int len;
|
|
73 String s;
|
|
74 int suffLen = suffix.length();
|
|
75 int altSuffLen = altSuffix.length();
|
|
76 if (suffLen >= altSuffLen) {
|
|
77 len = suffLen;
|
|
78 s = suffix;
|
|
79 } else {
|
|
80 len = altSuffLen;
|
|
81 s = altSuffix;
|
|
82 }
|
|
83 len += prefix.length() + stem.length();
|
|
84 int lim = p.fileNameLengthLimit();
|
|
85 if (len > lim) {
|
|
86 p.fatalError(prefix + stem + s + " is too long: " +
|
|
87 len + " >= " + lim);
|
|
88 }
|
|
89 }
|
|
90
|
|
91 public String dirPreStemSuff() {
|
|
92 return dpss;
|
|
93 }
|
|
94
|
|
95 public String preStemSuff() {
|
|
96 return pss;
|
|
97 }
|
|
98
|
|
99 public String dirPreStemAltSuff() {
|
|
100 return dpsa;
|
|
101 }
|
|
102
|
|
103 public String preStemAltSuff() {
|
|
104 return psa;
|
|
105 }
|
|
106
|
|
107 public FileName copyStem(String newStem) {
|
|
108 return new FileName(plat, dir, prefix, newStem,
|
|
109 suffix, inverseDir, altSuffix);
|
|
110 }
|
|
111
|
|
112 String nameOfList() {
|
|
113 return stem;
|
|
114 }
|
|
115
|
|
116 String getInvDir() {
|
|
117 return inverseDir;
|
|
118 }
|
|
119 }
|