KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jk > ant > Source


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
20
21 import org.apache.tools.ant.util.GlobPatternMapper;
22
23 public class Source {
24     File JavaDoc dir;
25     String JavaDoc localPart;
26     
27     public Source( File JavaDoc dir, String JavaDoc localPart ) {
28     this.dir=dir;
29     this.localPart=localPart;
30     }
31
32     public String JavaDoc getTargetFile( GlobPatternMapper mapper ) {
33     String JavaDoc targetNA[]=mapper.mapFileName( localPart );
34     if( targetNA==null )
35         return null; // strange, probably different extension ?
36
String JavaDoc target=targetNA[0];
37     return target;
38     }
39
40     public File JavaDoc getFile() {
41     return new File JavaDoc( dir, localPart );
42     }
43
44     public String JavaDoc getPackage() {
45     int lastSlash=localPart.lastIndexOf("/");
46     if( lastSlash==-1 )
47         return "";
48     return localPart.substring( 0, lastSlash );
49     }
50 }
51
Popular Tags