KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.apache.tools.ant.Project;
20
21 /** Define name/value, value is optional
22  * The define will take place if the condition
23  * is met.
24  *
25  * A <so> task should include all the defines it supports,
26  * with the default value. This allows the builder to customize
27  * without having to look at the source.
28  */

29 public class Def {
30     String JavaDoc name;
31     String JavaDoc info;
32     String JavaDoc value;
33     String JavaDoc ifCond;
34     String JavaDoc unlessCond;
35     Project project;
36
37     public Def() {
38     }
39
40     public void setProject( Project p ) {
41     project=p;
42     }
43     
44     public void setName(String JavaDoc n) {
45     name=n;
46     }
47
48     public void setValue( String JavaDoc v ) {
49     value=v;
50     }
51
52     public void setIf( String JavaDoc ifCond ) {
53     this.ifCond=ifCond;
54     }
55
56     public void setUnless( String JavaDoc unlessCond ) {
57     this.unlessCond=unlessCond;
58     }
59
60     /** Informations about the option
61      */

62     public void setInfo(String JavaDoc n ) {
63     info=n;
64     }
65
66     // -------------------- Getters --------------------
67

68     /** Return the name of the define, or null if the define is not
69      * valid ( if/unless conditions )
70      */

71     public String JavaDoc getName() {
72     if( ifCond!=null && project.getProperty(ifCond) == null )
73         return null;
74     if (unlessCond != null && project.getProperty(unlessCond) != null)
75         return null;
76     return name;
77     }
78
79     public String JavaDoc getValue() {
80     return value;
81     }
82 }
83
Popular Tags