01: /*
02: * Copyright 1999-2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.jk.ant;
18:
19: import java.io.File;
20:
21: import org.apache.tools.ant.util.GlobPatternMapper;
22:
23: public class Source {
24: File dir;
25: String localPart;
26:
27: public Source(File dir, String localPart) {
28: this .dir = dir;
29: this .localPart = localPart;
30: }
31:
32: public String getTargetFile(GlobPatternMapper mapper) {
33: String targetNA[] = mapper.mapFileName(localPart);
34: if (targetNA == null)
35: return null; // strange, probably different extension ?
36: String target = targetNA[0];
37: return target;
38: }
39:
40: public File getFile() {
41: return new File(dir, localPart);
42: }
43:
44: public String getPackage() {
45: int lastSlash = localPart.lastIndexOf("/");
46: if (lastSlash == -1)
47: return "";
48: return localPart.substring(0, lastSlash);
49: }
50: }
|