Convert an object to Boolean.
Null and empty string are false.
@param ctx the context in which this conversion is taking place
@param obj the object to convert
@return the Boolean value of the object
@throws ELException if object is not Boolean or String
490607
public static final Boolean coerceToBoolean(final ELContext ctx, final Object obj) {
    	// previous el 2.2 implementation returned false if obj is null
    	// so pass in true for primitive to force the same  behavior
    	return coerceToBoolean(ctx, obj, true);
    }
285818
public static boolean isObject( Object obj ) {
      return !isNumber( obj ) && !isString( obj ) && !isBoolean( obj ) && !isArray( obj )
            && !isFunction( obj ) || isNull( obj );
   }
360406
public Boolean get(JcBoolean bool) {
		Object val = this.getFor(bool);
		if (val != null)
			return (Boolean)val;
		return null;
	}
403065
@Nonnull
  public SoyValueProvider convert(@Nullable Object obj) {
    SoyValueProvider convertedPrimitive = convertCheap(obj);
    if (convertedPrimitive != null) {
      return convertedPrimitive;
    }
    return convertNonPrimitive(obj);
  }
940642
static boolean asBoolean(Object value) throws ProvidenceConfigException {
        if (value instanceof Boolean) {
            return (Boolean) value;
        } else if (value instanceof Double || value instanceof Float) {
            throw new ProvidenceConfigException("Unable to convert real value to boolean");
        } else if (value instanceof Number) {
            long l = ((Number) value).longValue();
            if (l == 0L) return false;
            if (l == 1L) return true;
            throw new ProvidenceConfigException("Unable to convert number " + l + " to boolean");
        }
        throw new ProvidenceConfigException("Unable to convert " + value.getClass().getSimpleName() + " to a boolean");
    }
1295813
public Boolean asBooleanObj() {
		if (current == null)
			return null;
		if (current instanceof Boolean)
			return (Boolean) current;
		return null;
	}
23842
static public Value booleanValue (String name, final boolean currentValue, final String description) {
		return new DefaultValue(name, String.valueOf(currentValue)) {
			public void showDialog () {
				JCheckBox checkBox = new JCheckBox();
				checkBox.setSelected(currentValue);
				if (showValueDialog(checkBox, description)) value = String.valueOf(checkBox.isSelected());
			}

			public Object getObject () {
				return Boolean.valueOf(value);
			}
		};
	}
1104477
public static boolean isValued(Object obj) {
		if (obj == null) return false;
		if (obj instanceof String) return isStringValued((String) obj);
		return true;
	}
561182
public boolean getBoolean(String key, boolean defaultValue) {
		Object o = getObject(key);
		if (o == null) {
			return defaultValue;
		}
		boolean b = defaultValue;
		try {
			b = Boolean.parseBoolean(o.toString());
		}
		catch (Exception e) {
			throw new IllegalArgumentException("Object ["+o+"] associated with key ["+key+"] is not of type Boolean.");
		}
		return b;
	}
1307647
@Deprecated
    public static Object getObjectElem(Object obj, Object elem, Context cx)
    {
        return getObjectElem(obj, elem, cx, getTopCallScope(cx));
    }
703597
public static Object setObjectElem(Object obj, Object elem, Object value,
                                       Context cx, Scriptable scope)
    {
        Scriptable sobj = toObjectOrNull(cx, obj, scope);
        if (sobj == null) {
            throw undefWriteError(obj, elem, value);
        }
        return setObjectElem(sobj, elem, value, cx);
    }
1089564
@Override
    public void enterObject(TagQueryParser.ObjectContext ctx) {
        Stack<String> objectStack = new Stack<>();
        stack.push(objectStack);
        String eval;
        if (ctx.getParent().getParent() == null && ctx.tagexp() != null) {
            eval = getEval(ctx.tagexp());
            evalsPostfix.add(eval);
        }
        if (ctx.logical_operator() != null) {
            TagexpContext left = ctx.object(0).tagexp();
            TagexpContext right = ctx.object(1).tagexp();
            if (left != null && right != null) {
                String lEval = getEval(left);
                String rEval = getEval(right);
                if (isNot(lEval) && !isNot(rEval)) {
                    evalsPostfix.add(rEval);
                    evalsPostfix.add(lEval);
                } else {
                    evalsPostfix.add(lEval);
                    evalsPostfix.add(rEval);
                }
            } else if (left != null && right == null) {
                String lEval = getEval(left);
                if (!isNot(lEval)) {
                    evalsPostfix.add(lEval);
                } else {
                    objectStack.push(lEval);
                }
            }  else if (left == null && right != null) {
                String rEval = getEval(right);
                evalsPostfix.add(rEval);
            }
        }
    }
1292255
public static Boolean toBooleanObject(String str) {
		return str != null ? Boolean.valueOf(str) : null;
	}
1320220
@Nullable
  private SoyValueProvider convertCheap(@Nullable Object obj) {
    if (obj == null) {
      return NullData.INSTANCE;
    }
    return cheapConverterMap.convert(obj);
  }
1092587
static boolean isBasicValueType(final Object obj) {
        return obj == null || obj instanceof String || obj instanceof Integer || obj instanceof Boolean
                || obj instanceof Long || obj instanceof Float || obj instanceof Double || obj instanceof Short
                || obj instanceof Byte || obj instanceof Character || obj.getClass().isEnum();
    }
1252217
@SuppressWarnings("unchecked")
    public static final Enum<?> coerceToEnum(final ELContext ctx, final Object obj,
            @SuppressWarnings("rawtypes") Class type) {

        if (ctx != null) {
        	boolean originalIsPropertyResolved = ctx.isPropertyResolved();
        	try {
        		Object result = ctx.getELResolver().convertToType(ctx, obj, type);
        		if (ctx.isPropertyResolved()) {
        			return (Enum<?>) result;
        		}
        	} finally {
        		ctx.setPropertyResolved(originalIsPropertyResolved);
        	}
        }

        if (obj == null || "".equals(obj)) {
            return null;
        }
        if (type.isAssignableFrom(obj.getClass())) {
            return (Enum<?>) obj;
        }

        if (!(obj instanceof String)) {
            throw new ELException(MessageFactory.get("error.convert",
                    obj, obj.getClass(), type));
        }

        Enum<?> result;
        try {
             result = Enum.valueOf(type, (String) obj);
        } catch (IllegalArgumentException iae) {
            throw new ELException(MessageFactory.get("error.convert",
                    obj, obj.getClass(), type));
        }
        return result;
    }
1092859
public boolean toBoolean(Element el, String attributeName, boolean defaultValue) {
	String value = el.getAttribute(attributeName);
	if (value == null) return defaultValue;
	return Caster.toBooleanValue(value, false);
    }