KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > unix > AbstractAccessTask


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 /*
20  * Since the initial version of this file was deveolped on the clock on
21  * an NSF grant I should say the following boilerplate:
22  *
23  * This material is based upon work supported by the National Science
24  * Foundaton under Grant No. EIA-0196404. Any opinions, findings, and
25  * conclusions or recommendations expressed in this material are those
26  * of the author and do not necessarily reflect the views of the
27  * National Science Foundation.
28  */

29
30 package org.apache.tools.ant.taskdefs.optional.unix;
31
32 import java.io.File JavaDoc;
33
34 import org.apache.tools.ant.BuildException;
35 import org.apache.tools.ant.taskdefs.condition.Os;
36 import org.apache.tools.ant.types.Commandline;
37 import org.apache.tools.ant.types.FileSet;
38
39 /**
40  * @since Ant 1.6
41  *
42  * @ant.task category="filesystem"
43  */

44
45 public abstract class AbstractAccessTask
46     extends org.apache.tools.ant.taskdefs.ExecuteOn {
47
48     /**
49      * Chmod task for setting file and directory permissions.
50      */

51     public AbstractAccessTask() {
52         super.setParallel(true);
53         super.setSkipEmptyFilesets(true);
54     }
55
56     /**
57      * Set the file which should have its access attributes modified.
58      * @param src the file to modify
59      */

60     public void setFile(File JavaDoc src) {
61         FileSet fs = new FileSet();
62         fs.setFile(src);
63         addFileset(fs);
64     }
65
66     /**
67      * Prevent the user from specifying a different command.
68      *
69      * @ant.attribute ignore="true"
70      * @param cmdl A user supplied command line that we won't accept.
71      */

72     public void setCommand(Commandline cmdl) {
73         throw new BuildException(getTaskType()
74                                  + " doesn\'t support the command attribute",
75                                  getLocation());
76     }
77
78     /**
79      * Prevent the skipping of empty filesets
80      *
81      * @ant.attribute ignore="true"
82      * @param skip A user supplied boolean we won't accept.
83      */

84     public void setSkipEmptyFilesets(boolean skip) {
85         throw new BuildException(getTaskType() + " doesn\'t support the "
86                                  + "skipemptyfileset attribute",
87                                  getLocation());
88     }
89
90     /**
91      * Prevent the use of the addsourcefile atribute.
92      *
93      * @ant.attribute ignore="true"
94      * @param b A user supplied boolean we won't accept.
95      */

96     public void setAddsourcefile(boolean b) {
97         throw new BuildException(getTaskType()
98             + " doesn\'t support the addsourcefile attribute", getLocation());
99     }
100
101     /**
102      * Automatically approve Unix OS's.
103      * @return true if a valid OS, for unix this is always true, otherwise
104      * use the superclasses' test (user set).
105      */

106     protected boolean isValidOs() {
107         return Os.isFamily("unix") && super.isValidOs();
108     }
109 }
110
Popular Tags