KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > types > selectors > DependSelector


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18
19 package org.apache.tools.ant.types.selectors;
20
21 import java.io.File JavaDoc;
22
23 /**
24  * Selector that filters files based on whether they are newer than
25  * a matching file in another directory tree. It can contain a mapper
26  * element, so isn't available as an ExtendSelector (since those
27  * parameters can't hold other elements).
28  *
29  * @since 1.5
30  */

31 public class DependSelector extends MappingSelector {
32
33     /**
34      * Creates a new <code>DependSelector</code> instance.
35      *
36      */

37     public DependSelector() {
38
39     }
40
41     /**
42      * @return a string describing this object
43      */

44     public String JavaDoc toString() {
45         StringBuffer JavaDoc buf = new StringBuffer JavaDoc("{dependselector targetdir: ");
46         if (targetdir == null) {
47             buf.append("NOT YET SET");
48         } else {
49             buf.append(targetdir.getName());
50         }
51         buf.append(" granularity: ");
52         buf.append(granularity);
53         if (map != null) {
54             buf.append(" mapper: ");
55             buf.append(map.toString());
56         } else if (mapperElement != null) {
57             buf.append(" mapper: ");
58             buf.append(mapperElement.toString());
59         }
60         buf.append("}");
61         return buf.toString();
62     }
63
64
65     /**
66      * this test is our selection test that compared the file with the destfile
67      * @param srcfile the source file
68      * @param destfile the destination file
69      * @return true if destination is out of date
70      */

71     public boolean selectionTest(File JavaDoc srcfile, File JavaDoc destfile) {
72         boolean selected = SelectorUtils.isOutOfDate(srcfile, destfile,
73                 granularity);
74         return selected;
75     }
76
77 }
78
79
Popular Tags