KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.io.File JavaDoc;
21 import org.apache.tools.ant.types.DataType;
22 import org.apache.tools.ant.taskdefs.condition.IsSigned;
23
24 /**
25  * Selector that chooses files based on whether they are signed or not.
26  *
27  * @since 1.7
28  */

29 public class SignedSelector extends DataType implements FileSelector {
30     private IsSigned isSigned = new IsSigned();
31
32     /**
33      * The signature name to check jarfile for.
34      *
35      * @param name signature to look for.
36      */

37     public void setName(String JavaDoc name) {
38         isSigned.setName(name);
39     }
40
41     /**
42      * The heart of the matter. This is where the selector gets to decide
43      * on the inclusion of a file in a particular fileset.
44      *
45      * @param basedir not used by this selector
46      * @param filename not used by this selector
47      * @param file path to file to be selected
48      * @return whether the file should be selected or not
49      */

50     public boolean isSelected(File JavaDoc basedir, String JavaDoc filename, File JavaDoc file) {
51         if (file.isDirectory()) {
52             return false; // Quick return: directories cannot be signed
53
}
54         isSigned.setProject(getProject());
55         isSigned.setFile(file);
56         return isSigned.eval();
57     }
58 }
59
Popular Tags