1 28 29 package com.idaremedia.antx.condition; 30 31 import com.idaremedia.antx.helpers.Strings; 32 import com.idaremedia.antx.helpers.Tk; 33 import com.idaremedia.antx.parameters.IgnoreCaseEnabled; 34 import com.idaremedia.antx.parameters.SynonymsEnabled; 35 36 50 51 public final class IsBoolean extends SimpleFlexCondition 52 implements IgnoreCaseEnabled, SynonymsEnabled 53 { 54 58 public IsBoolean() 59 { 60 super(); 61 } 62 63 64 68 public IsBoolean(String property) 69 { 70 setProperty(property); 71 } 72 73 74 80 public IsBoolean(String value, boolean isP) 81 { 82 if (isP) { 83 setProperty(value); 84 } else { 85 setVariable(value); 86 } 87 } 88 89 90 93 public void setIgnoreCase(boolean ignore) 94 { 95 getValueHelper().setIgnoreCase(ignore); 96 } 97 98 99 103 public final boolean isIgnoreCase() 104 { 105 return getValueHelper().isIgnoreCase(); 106 } 107 108 109 114 public void setSynonyms(boolean allowAll) 115 { 116 m_allowAll = allowAll; 117 } 118 119 120 124 public final boolean allowSynonyms() 125 { 126 return m_allowAll; 127 } 128 129 130 131 135 public void setValue(String value) 136 { 137 require_(value!=null,"setValu- nonzro"); 138 setLiteral(value); 139 } 140 141 142 143 147 public boolean eval() 148 { 149 verifyCanEvaluate_("eval"); 150 151 String value = getValueHelper().getValue(); 152 if (value==null) { 153 return false; 154 } 155 156 boolean isbool; 157 if (allowSynonyms()) { 158 isbool = Tk.string2PosBool(value).booleanValue() || 159 !Tk.string2NegBool(value).booleanValue(); 160 } else { 161 isbool = Strings.TRUE.equals(value) || 162 Strings.FALSE.equals(value); 163 } 164 return isbool; 165 } 166 167 168 private boolean m_allowAll=true; 169 } 170 171 172 | Popular Tags |