Cast an Object value to the corresponding boolean value.

@param in Object to cast into boolean
@return boolean value corresponding to the cast of the object
@throws PSQLException PSQLState.CANNOT_COERCE
776357
static boolean castToBoolean(final Object in) throws PSQLException {
    if (LOGGER.isLoggable(Level.FINE)) {
      LOGGER.log(Level.FINE, "Cast to boolean: \"{0}\"", String.valueOf(in));
    }
    if (in instanceof Boolean) {
      return (Boolean) in;
    }
    if (in instanceof String) {
      return fromString((String) in);
    }
    if (in instanceof Character) {
      return fromCharacter((Character) in);
    }
    if (in instanceof Number) {
      return fromNumber((Number) in);
    }
    throw new PSQLException("Cannot cast to boolean", PSQLState.CANNOT_COERCE);
  }
1323121
def convert_boolean(value, parameter, default=False):
    '''
    
    '''
    value = _check_default(value, parameter, ( '', '-', None ))
    if isinstance(value, bool):
        return value
    if isinstance(value, str) and len(value) > 0:
        value = value[0]
    return value not in ( 'f', 'F', '0', False, None )
1365421
@Override
    public boolean getValue() throws OntopConnectionException {
        if (hasRead)
            throw new IllegalStateException("getValue() can only called once!");
        hasRead = true;
        try {
            return set.next();
        } catch (SQLException e) {
            throw new OntopConnectionException(e);
        }
    }
1123502
def get_as_nullable_boolean(self, key):
        
        value = self.get(key)
        return BooleanConverter.to_nullable_boolean(value)
911567
public Object javaToSql(Object source)
    {
        if (source instanceof Boolean)
        {
            if (source.equals(Boolean.TRUE))
            {
                return I_TRUE;
            }
            else
            {
                return I_FALSE;
            }
        }
        else
        {
            return source;
        }
    }
1010806
public static Boolean toBoolean(Object o, Boolean defaultValue) {
	if (o instanceof Boolean) return ((Boolean) o);
	else if (o instanceof Number) return ((Number) o).intValue() == 0 ? Boolean.FALSE : Boolean.TRUE;
	else if (o instanceof String) {
	    int rtn = stringToBooleanValueEL(o.toString());
	    if (rtn == 1) return Boolean.TRUE;
	    else if (rtn == 0) return Boolean.FALSE;
	    else {
		double dbl = toDoubleValue(o.toString(), Double.NaN);
		if (!Double.isNaN(dbl)) return toBooleanValue(dbl) ? Boolean.TRUE : Boolean.FALSE;
	    }

	}
	// else if(o instanceof Clob) return toBooleanValueEL(toStringEL(o));
	else if (o instanceof Castable) {
	    return ((Castable) o).castToBoolean(defaultValue);
	}
	else if (o instanceof ObjectWrap) return toBoolean(((ObjectWrap) o).getEmbededObject(defaultValue), defaultValue);

	else if (o == null) return toBoolean("", defaultValue);
	return defaultValue;
    }
261713
@SuppressFBWarnings(value = "NP_BOOLEAN_RETURN_NULL", justification = "That's the point (but dubious)")
    public static Boolean falseToNull(Boolean bool) {
        if (bool != null && bool) {
            return true;
        }
        return null;
    }
734531
public static boolean toBooleanValue(String str) throws PageException {
	Boolean b = toBoolean(str, null);
	if (b != null) return b.booleanValue();
	throw new CasterException("Can't cast String [" + CasterException.crop(str) + "] to a boolean");
    }
555715
final public Selector BooleanTerm() throws ParseException {
                           Selector left, right=null;
    left = BooleanFactor();
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case AND:
      jj_consume_token(AND);
      right = BooleanTerm();
      break;
    default:
      jj_la1[1] = jj_gen;
      ;
    }
    if (right == null) {if (true) return left;}
    else {if (true) return new OperatorImpl(Operator.AND, left, right);}
    throw new Error("Missing return statement in function");
  }
888761
public static boolean getBoolean(JSONValue value) {
        if (value == null)
            return false;
        if (!(value instanceof JSONBoolean))
            throw new JSONException(NOT_A_BOOLEAN);
        return ((JSONBoolean)value).booleanValue();
    }
652369
public Boolean evaluate(Object o) {

        EntityClassReader classReader = EntityClassReader.getClassReaderFor(o.getClass());

        if (classReader.getPropertyType(propertyName) != Boolean.class)
                throw new RuntimeException("Property " + propertyName + " on object " + o + " is not of type Boolean");

        Object result = null;
        try {
            result = classReader.getPropertyValue(o, propertyName);
        }
        catch (InvalidObjectReaderException e) {
            ; // can never occur
        }

        return (Boolean)result;
    }
795380
def to_boolean_with_default(value, default_value):
        
        result = BooleanConverter.to_nullable_boolean(value)
        return result if result != None else default_value
693884
public boolean containsValue(final Object value) {
	return ! forEachPair( 
		new IntObjectProcedure() {
			public boolean apply(int iterKey, Object iterValue) {
				return (value != iterValue);
			}
		}
	);
}
120197
@SuppressWarnings("unchecked")
  public boolean result(final Object iRecord) {
    final ODocument record = (ODocument) iRecord;

    boolean recordUpdated = false;

    parameters.reset();

    // BIND VALUES TO UPDATE
    if (!setEntries.isEmpty()) {
      OSQLHelper.bindParameters(record, setEntries, parameters);
      recordUpdated = true;
    }

    // BIND VALUES TO INCREMENT
    for (Map.Entry<String, Number> entry : incrementEntries.entrySet()) {
      final Number prevValue = record.field(entry.getKey());

      if (prevValue == null)
        // NO PREVIOUS VALUE: CONSIDER AS 0
        record.field(entry.getKey(), entry.getValue());
      else
        // COMPUTING INCREMENT
        record.field(entry.getKey(), OType.increment(prevValue, entry.getValue()));

      recordUpdated = true;
    }

    Object v;

    // BIND VALUES TO ADD
    Collection<Object> coll;
    Object fieldValue;
    for (OPair<String, Object> entry : addEntries) {
      coll = null;
      if (!record.containsField(entry.getKey())) {
        // GET THE TYPE IF ANY
        if (record.getSchemaClass() != null) {
          OProperty prop = record.getSchemaClass().getProperty(entry.getKey());
          if (prop != null && prop.getType() == OType.LINKSET)
            // SET TYPE
            coll = new HashSet<Object>();
        }

        if (coll == null)
          // IN ALL OTHER CASES USE A LIST
          coll = new ArrayList<Object>();

        record.field(entry.getKey(), coll);
      } else {
        fieldValue = record.field(entry.getKey());

        if (fieldValue instanceof Collection<?>)
          coll = (Collection<Object>) fieldValue;
        else
          continue;
      }

      v = entry.getValue();

      if (v instanceof OSQLFilterItem)
        v = ((OSQLFilterItem) v).getValue(record, context);
      else if (v instanceof OSQLFunctionRuntime)
        v = ((OSQLFunctionRuntime) v).execute(record, this);

      coll.add(v);
      recordUpdated = true;
    }

    // BIND VALUES TO PUT (AS MAP)
    Map<String, Object> map;
    OPair<String, Object> pair;
    for (Entry<String, OPair<String, Object>> entry : putEntries.entrySet()) {
      fieldValue = record.field(entry.getKey());

      if (fieldValue == null) {
        if (record.getSchemaClass() != null) {
          final OProperty property = record.getSchemaClass().getProperty(entry.getKey());
          if (property != null
              && (property.getType() != null && (!property.getType().equals(OType.EMBEDDEDMAP) && !property.getType().equals(
                  OType.LINKMAP)))) {
            throw new OCommandExecutionException("field " + entry.getKey() + " is not defined as a map");
          }
        }
        fieldValue = new HashMap<String, Object>();
        record.field(entry.getKey(), fieldValue);
      }

      if (fieldValue instanceof Map<?, ?>) {
        map = (Map<String, Object>) fieldValue;

        pair = entry.getValue();

        if (pair.getValue() instanceof OSQLFilterItem)
          pair.setValue(((OSQLFilterItem) pair.getValue()).getValue(record, null));
        else if (pair.getValue() instanceof OSQLFunctionRuntime)
          v = ((OSQLFunctionRuntime) pair.getValue()).execute(record, this);

        map.put(pair.getKey(), pair.getValue());
        recordUpdated = true;
      }
    }

    // REMOVE FIELD IF ANY
    for (OPair<String, Object> entry : removeEntries) {
      v = entry.getValue();
      if (v == EMPTY_VALUE) {
        record.removeField(entry.getKey());
        recordUpdated = true;
      } else {
        fieldValue = record.field(entry.getKey());

        if (fieldValue instanceof Collection<?>) {
          coll = (Collection<Object>) fieldValue;
          if (coll.remove(v))
            recordUpdated = true;
        } else if (fieldValue instanceof Map<?, ?>) {
          map = (Map<String, Object>) fieldValue;
          if (map.remove(v) != null)
            recordUpdated = true;
        }
      }
    }

    if (recordUpdated) {
      record.setDirty();
      record.save();
      recordCount++;
    }

    return true;
  }
23385
def _cast_to_type(self, value):
        
        if value in (True, False):
            return bool(value)
        if value in ('t', 'True', '1'):
            return True
        if value in ('f', 'False', '0'):
            return False
        self.fail('invalid', value=value)
459610
protected Boolean eval(final Object... _value)
    {
        final Boolean ret;
        if (_value == null) {
            ret = null;
        } else if (_value[0] instanceof String) {
            ret = Boolean.valueOf((String) _value[0]);
        } else if (_value[0] instanceof Boolean) {
            ret = (Boolean) _value[0];
        } else  {
            ret = false;
        }
        return ret;
    }
202299
@Override
    public boolean condition(Object input) {
        if (input instanceof String) {
            return !schema.getMetaData(columnIdx).isValid(new Text(input.toString()));
        } else if (input instanceof Double) {
            Double d = (Double) input;
            return !schema.getMetaData(columnIdx).isValid(new DoubleWritable(d));
        } else if (input instanceof Integer) {
            Integer i = (Integer) input;
            return !schema.getMetaData(columnIdx).isValid(new IntWritable(i));
        } else if (input instanceof Long) {
            Long l = (Long) input;
            return !schema.getMetaData(columnIdx).isValid(new LongWritable(l));
        } else if (input instanceof Boolean) {
            Boolean b = (Boolean) input;
            return !schema.getMetaData(columnIdx).isValid(new BooleanWritable(b));
        }

        else
            throw new IllegalStateException("Illegal type " + input.getClass().toString());
    }