bson/src/main/org/bson/BasicBSONObject.java
public boolean getBoolean(final String key, final boolean def) {
        Object foo = get(key);
        if (foo == null) {
            return def;
        }
        if (foo instanceof Number) {
            return ((Number) foo).intValue() > 0;
        }
        if (foo instanceof Boolean) {
            return (Boolean) foo;
        }
        throw new IllegalArgumentException("can't coerce to bool:" + foo.getClass());
    }
public boolean getBoolean(final String key, final boolean def) {
        Object foo = get(key);
        if (foo == null) {
            return def;
        }
        if (foo instanceof Number) {
            return ((Number) foo).intValue() > 0;
        }
        if (foo instanceof Boolean) {
            return (Boolean) foo;
        }
        throw new IllegalArgumentException("can't coerce to bool:" + foo.getClass());
    }
public boolean getBoolean ( final String key , final boolean def ) { Object foo = get ( key ) ; if ( foo == null ) { return def ; } if ( foo instanceof Number ) { return ( ( Number ) foo ) . intValue ( ) > 0 ; } if ( foo instanceof Boolean ) { return ( Boolean ) foo ; } throw new IllegalArgumentException ( "can't coerce to bool:" + foo . getClass ( ) ) ; }
Returns the value of a field as a boolean

@param key the field to look up
@param def the default value in case the field is not found
@return the value of the field, converted to a string
Returns the value of a field as a boolean