KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > condition > IsNotSet


1 /**
2  * $Id: IsNotSet.java 180 2007-03-15 12:56:38Z ssmc $
3  * Copyright 2002-2004 iDare Media, Inc. All rights reserved.
4  *
5  * Originally written by iDare Media, Inc. for release into the public domain. This
6  * library, source form and binary form, is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2.1 of the License, or (at your option) any
9  * later version.<p>
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU LGPL (GNU Lesser General Public License) for more details.<p>
14  *
15  * You should have received a copy of the GNU Lesser General Public License along with this
16  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite
17  * 330, Boston, MA 02111-1307 USA. The LGPL can be found online at
18  * http://www.fsf.org/copyleft/lesser.html<p>
19  *
20  * This product has been influenced by several projects within the open-source community.
21  * The JWare developers wish to acknowledge the open-source community's support. For more
22  * information regarding the open-source products used within JWare, please visit the
23  * JWare website.
24  *----------------------------------------------------------------------------------------*
25  * WEBSITE- http://www.jware.info EMAIL- inquiries@jware.info
26  *----------------------------------------------------------------------------------------*
27  **/

28
29 package com.idaremedia.antx.condition;
30
31 import com.idaremedia.antx.parameters.Handling;
32 import com.idaremedia.antx.parameters.IgnoreWhitespaceEnabled;
33 import com.idaremedia.antx.parameters.IsA;
34
35 /**
36  * Simple Is-Not-Set condition check. Example usage:
37  * <pre>
38  * &lt;isnotset property="jdk14.present"/&gt;
39  * &lt;isnotset property="module.id" whitespace="ignore"/&gt;
40  * &lt;isnotset variable="__loopcount"/&gt;
41  * &lt;isnotset reference="build.num"/&gt;
42  *</pre>
43  *
44  * @since JWare/AntX 0.1
45  * @author ssmc, &copy;2002-2004 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
46  * @version 0.5
47  * @.safety single
48  * @.group api,infra
49  **/

50
51 public class IsNotSet extends SimpleFlexCondition implements IgnoreWhitespaceEnabled
52 {
53     /**
54      * Initializes new IsNotSet condition. A value type must be
55      * specified before this condition is evaluated.
56      **/

57     public IsNotSet()
58     {
59         super();
60     }
61
62
63     /**
64      * Initializes a fully-defined IsNotSet condition.
65      * @param property the property against which condition checks
66      **/

67     public IsNotSet(String JavaDoc property)
68     {
69         setProperty(property);
70     }
71
72
73     /**
74      * Initializes an IsNotSet condition to either a property or
75      * a variable value check.
76      * @param value the property or varaible against which
77      * condition checks
78      * @param isP <i>true</i> if <span class="src">value</span> is
79      * property's name
80      **/

81     public IsNotSet(String JavaDoc value, boolean isP)
82     {
83         if (isP) {
84             setProperty(value);
85         } else {
86             setVariable(value);
87         }
88     }
89
90
91
92     /**
93      * Sets whether a property containing only whitespace is
94      * considered "not-set."
95      **/

96     public void setWhitespace(Handling response)
97     {
98         getValueHelper().setWhitespace(response);
99     }
100
101
102     /**
103      * Returns <i>true</i> if values of all whitespace will be
104      * ignored (as if not set). Defaults <i>false</i>.
105      **/

106     public final boolean ignoreWhitespace()
107     {
108         return getValueHelper().isIgnoreWhitespace();
109     }
110
111
112
113     /**
114      * Marks this condition's property as the default field
115      * set by a value URI.
116      * @since JWare/AntX 0.5
117      * @return IsA.PROPERTY always.
118      */

119     protected IsA getDefaultIsAForURI()
120     {
121         return IsA.PROPERTY;
122     }
123
124
125
126     /**
127      * Returns <i>true</i> if this condition's property, reference,
128      * or variable has not been explicitly set.
129      **/

130     public boolean eval()
131     {
132         verifyCanEvaluate_("eval");
133
134         if (isReference()) {
135             Object JavaDoc o = getProject().getReference(getResolvedFlexValue());
136             if (!(o instanceof String JavaDoc)) {//otherwise apply modifiers(ssmc)
137
return o==null;
138             }
139         }
140
141         return getValueHelper().getValue()==null;
142     }
143 }
144
145 /* end-of-IsNotSet.java */
146
Popular Tags