1 16 17 18 19 package org.apache.taglibs.standard.lang.jstl; 20 21 22 23 import java.lang.reflect.Array ; 24 25 import java.util.Collection ; 26 27 import java.util.Map ; 28 29 30 31 44 45 46 47 public class EmptyOperator 48 49 extends UnaryOperator 50 51 { 52 53 55 57 59 60 61 public static final EmptyOperator SINGLETON = 62 63 new EmptyOperator (); 64 65 66 67 69 76 77 public EmptyOperator () 78 79 { 80 81 } 82 83 84 85 87 89 91 98 99 public String getOperatorSymbol () 100 101 { 102 103 return "empty"; 104 105 } 106 107 108 109 111 118 119 public Object apply (Object pValue, 120 121 Object pContext, 122 123 Logger pLogger) 124 125 throws ELException 126 127 { 128 129 131 if (pValue == null) { 132 133 return PrimitiveObjects.getBoolean (true); 134 135 } 136 137 138 139 141 else if ("".equals (pValue)) { 142 143 return PrimitiveObjects.getBoolean (true); 144 145 } 146 147 148 149 151 else if (pValue.getClass ().isArray () && 152 153 Array.getLength (pValue) == 0) { 154 155 return PrimitiveObjects.getBoolean (true); 156 157 } 158 159 160 161 163 else if (pValue instanceof Collection && 164 165 ((Collection ) pValue).isEmpty ()) { 166 167 return PrimitiveObjects.getBoolean (true); 168 169 } 170 171 172 173 175 else if (pValue instanceof Map && 176 177 ((Map ) pValue).isEmpty ()) { 178 179 return PrimitiveObjects.getBoolean (true); 180 181 } 182 183 184 185 187 else { 188 189 return PrimitiveObjects.getBoolean (false); 190 191 } 192 193 } 194 195 196 197 199 } 200 201 | Popular Tags |