Logo Search packages:      
Sourcecode: libjson-java version File versions

boolean net::sf::json::JSONArray::getBoolean ( int  index  )  [inline]

Get the boolean value associated with an index. The string values "true" and "false" are converted to boolean.

Parameters:
index The index must be between 0 and size() - 1.
Returns:
The truth.
Exceptions:
JSONException If there is no value for the index or if the value is not convertable to boolean.

Definition at line 1915 of file JSONArray.java.

Referenced by optBoolean().

                                          {
      Object o = get( index );
      if( o != null ){
         if( o.equals( Boolean.FALSE )
               || (o instanceof String && ((String) o).equalsIgnoreCase( "false" )) ){
            return false;
         }else if( o.equals( Boolean.TRUE )
               || (o instanceof String && ((String) o).equalsIgnoreCase( "true" )) ){
            return true;
         }
      }
      throw new JSONException( "JSONArray[" + index + "] is not a Boolean." );
   }


Generated by  Doxygen 1.6.0   Back to index