1 55 56 package org.apache.commons.el; 57 58 import java.lang.reflect.Array ; 59 import java.util.Collection ; 60 import java.util.Map ; 61 import javax.servlet.jsp.el.ELException ; 62 63 70 71 public class EmptyOperator 72 extends UnaryOperator 73 { 74 78 public static final EmptyOperator SINGLETON = 79 new EmptyOperator (); 80 81 86 public EmptyOperator () 87 { 88 } 89 90 97 public String getOperatorSymbol () 98 { 99 return "empty"; 100 } 101 102 107 public Object apply (Object pValue, 108 Logger pLogger) 109 throws ELException 110 { 111 if (pValue == null) { 113 return PrimitiveObjects.getBoolean (true); 114 } 115 116 else if ("".equals (pValue)) { 118 return PrimitiveObjects.getBoolean (true); 119 } 120 121 else if (pValue.getClass ().isArray () && 123 Array.getLength (pValue) == 0) { 124 return PrimitiveObjects.getBoolean (true); 125 } 126 127 else if (pValue instanceof Map && 129 ((Map ) pValue).isEmpty ()) { 130 return PrimitiveObjects.getBoolean (true); 131 } 132 133 else if (pValue instanceof Collection && 135 ((Collection ) pValue).isEmpty ()) { 136 return PrimitiveObjects.getBoolean (true); 137 } 138 139 else { 141 return PrimitiveObjects.getBoolean (false); 142 } 143 } 144 145 } 147 | Popular Tags |