Java Code Examples for org.eclipse.birt.core.data.DataTypeUtil#toBoolean()
The following examples show how to use
org.eclipse.birt.core.data.DataTypeUtil#toBoolean() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReportItemExecutor.java From birt with Eclipse Public License 1.0 | 6 votes |
protected Boolean evaluateBoolean( Expression expr ) { try { Object value = context.evaluate( expr ); return DataTypeUtil.toBoolean( value ); } catch ( BirtException ex ) { getLogger( ).log( Level.WARNING, "Invalid boolean expression:" + ( expr == null ? "null" : expr.toString( ) ) ); } return null; }
Example 2
Source File: TemplateMessageServiceBaseImpl.java From axelor-open-suite with GNU Affero General Public License v3.0 | 6 votes |
private Object convertValue(String type, String value) throws BirtException { if (DesignChoiceConstants.PARAM_TYPE_BOOLEAN.equals(type)) { return DataTypeUtil.toBoolean(value); } else if (DesignChoiceConstants.PARAM_TYPE_DATETIME.equals(type)) { return DataTypeUtil.toDate(value); } else if (DesignChoiceConstants.PARAM_TYPE_DATE.equals(type)) { return DataTypeUtil.toSqlDate(value); } else if (DesignChoiceConstants.PARAM_TYPE_TIME.equals(type)) { return DataTypeUtil.toSqlTime(value); } else if (DesignChoiceConstants.PARAM_TYPE_DECIMAL.equals(type)) { return DataTypeUtil.toBigDecimal(value); } else if (DesignChoiceConstants.PARAM_TYPE_FLOAT.equals(type)) { return DataTypeUtil.toDouble(value); } else if (DesignChoiceConstants.PARAM_TYPE_STRING.equals(type)) { return DataTypeUtil.toLocaleNeutralString(value); } else if (DesignChoiceConstants.PARAM_TYPE_INTEGER.equals(type)) { return DataTypeUtil.toInteger(value); } return value; }
Example 3
Source File: EngineTask.java From birt with Eclipse Public License 1.0 | 5 votes |
public static Object convertParameterType( Object value, String type ) throws BirtException { if ( DesignChoiceConstants.PARAM_TYPE_BOOLEAN.equals( type ) ) { return DataTypeUtil.toBoolean( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_DATETIME.equals( type ) ) { return DataTypeUtil.toDate( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_DATE.equals( type ) ) { return DataTypeUtil.toSqlDate( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_TIME.equals( type ) ) { return DataTypeUtil.toSqlTime( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_DECIMAL.equals( type ) ) { return DataTypeUtil.toBigDecimal( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_FLOAT.equals( type ) ) { return DataTypeUtil.toDouble( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_STRING.equals( type ) ) { return DataTypeUtil.toLocaleNeutralString( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_INTEGER.equals( type ) ) { return DataTypeUtil.toInteger( value ); } return value; }
Example 4
Source File: FunctionProviderBaseImpl.java From birt with Eclipse Public License 1.0 | 5 votes |
private static boolean extractBoolean( String strValue, boolean ifNull ) throws BirtException { boolean booleanValue = strValue == null ? ifNull : DataTypeUtil.toBoolean( strValue ); return booleanValue; }
Example 5
Source File: DataUtil.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Try convert an object to given type Types supported: * <p> * <ul> * <li>IScalarParameterDefn.TYPE_INTEGER</li> * <li>IScalarParameterDefn.TYPE_DECIMAL</li> * <li>IScalarParameterDefn.TYPE_BOOLEAN</li> * <li>IScalarParameterDefn.TYPE_DATE_TIME</li> * <li>IScalarParameterDefn.TYPE_FLOAT</li> * <li>IScalarParameterDefn.TYPE_STRING</li> * <li>IScalarParameterDefn.TYPE_DATE</li> * <li>IScalarParameterDefn.TYPE_TIME</li> * <ul> * </p> * * @param source * @param toType * @return * @throws BirtException */ public static Object convert( Object source, int toType ) throws BirtException { if ( source == null ) return null; // if any type, return directly. if ( toType == IScalarParameterDefn.TYPE_ANY ) return source; switch ( toType ) { case IScalarParameterDefn.TYPE_INTEGER : return DataTypeUtil.toInteger( source ); case IScalarParameterDefn.TYPE_DECIMAL : return DataTypeUtil.toBigDecimal( source ); case IScalarParameterDefn.TYPE_BOOLEAN : return DataTypeUtil.toBoolean( source ); case IScalarParameterDefn.TYPE_DATE_TIME : return DataTypeUtil.toDate( source ); case IScalarParameterDefn.TYPE_FLOAT : return DataTypeUtil.toDouble( source ); case IScalarParameterDefn.TYPE_STRING : return DataTypeUtil.toString( source ); case IScalarParameterDefn.TYPE_DATE : return DataTypeUtil.toSqlDate( source ); case IScalarParameterDefn.TYPE_TIME : return DataTypeUtil.toSqlTime( source ); default : throw new CoreException( "Invalid type." ); //$NON-NLS-1$ } }
Example 6
Source File: ImportValueDialog.java From birt with Eclipse Public License 1.0 | 5 votes |
private Object validateValue( String value ) throws BirtException { String tempdefaultValue = value; if ( !( ( DesignChoiceConstants.PARAM_TYPE_STRING.equals( style ) ) || ( DesignChoiceConstants.PARAM_TYPE_BOOLEAN.equals( style ) ) ) ) { if ( DesignChoiceConstants.PARAM_TYPE_DATETIME.equals( style ) ) { tempdefaultValue = ParameterUtil.convertToStandardFormat( DataTypeUtil.toDate( tempdefaultValue ) ); } else if ( DesignChoiceConstants.PARAM_TYPE_DATE.equals( style ) ) { tempdefaultValue = ParameterUtil.convertToStandardFormat( DataTypeUtil.toSqlDate( tempdefaultValue ) ); } else if ( DesignChoiceConstants.PARAM_TYPE_TIME.equals( style ) ) { tempdefaultValue = ParameterUtil.convertToStandardFormat( DataTypeUtil.toSqlTime( tempdefaultValue ) ); } return ParameterValidationUtil.validate( style, ParameterUtil.STANDARD_DATE_TIME_PATTERN, tempdefaultValue, ULocale.getDefault( ) ); } if ( DesignChoiceConstants.PARAM_TYPE_BOOLEAN.equals( style ) ) { if ( tempdefaultValue != null && tempdefaultValue.equals( Messages.getString( "ParameterDialog.Choice.NoDefault" ) ) ) //$NON-NLS-1$ { return DataTypeUtil.toBoolean( null ); } return DataTypeUtil.toBoolean( tempdefaultValue ); } else return tempdefaultValue; }
Example 7
Source File: ParameterUtil.java From birt with Eclipse Public License 1.0 | 5 votes |
public static Object convert( Object value, String dataType ) throws BirtException { if ( DesignChoiceConstants.PARAM_TYPE_BOOLEAN.equals( dataType ) ) { return DataTypeUtil.toBoolean( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_DATETIME.equals( dataType ) ) { return DataTypeUtil.toDate( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_DATE.equals( dataType ) ) { return DataTypeUtil.toSqlDate( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_TIME.equals( dataType ) ) { return DataTypeUtil.toSqlTime( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_DECIMAL.equals( dataType ) ) { return DataTypeUtil.toBigDecimal( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_FLOAT.equals( dataType ) ) { return DataTypeUtil.toDouble( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_STRING.equals( dataType ) ) { return DataTypeUtil.toString( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_INTEGER.equals( dataType ) ) { return DataTypeUtil.toInteger( value ); } return value; }
Example 8
Source File: DataTypeConvertUtil.java From birt with Eclipse Public License 1.0 | 5 votes |
public static Object convert( Object value, String type ) throws BirtException { if ( DesignChoiceConstants.PARAM_TYPE_BOOLEAN.equals( type ) ) { return DataTypeUtil.toBoolean( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_DATETIME.equals( type ) ) { return DataTypeUtil.toDate( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_DECIMAL.equals( type ) ) { return DataTypeUtil.toBigDecimal( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_FLOAT.equals( type ) ) { return DataTypeUtil.toDouble( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_STRING.equals( type ) ) { return DataTypeUtil.toString( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_INTEGER.equals( type ) ) { return DataTypeUtil.toInteger( value ); } return value; }
Example 9
Source File: ParameterSelectionChoice.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * set parameter choice value. The string value is in English locale, and needs to be parsed * back into object value based on the data type. * * @param value the string value for the object * @param type the parameter data type */ public void setValue(String value, int type) { try { switch (type) { case IScalarParameterDefn.TYPE_BOOLEAN: this.value = DataTypeUtil.toBoolean(value); break; case IScalarParameterDefn.TYPE_DATE_TIME: this.value = DataTypeUtil.toDate(value); break; case IScalarParameterDefn.TYPE_DECIMAL: this.value = DataTypeUtil.toBigDecimal(value); break; case IScalarParameterDefn.TYPE_FLOAT: this.value = DataTypeUtil.toDouble(value); break; case IScalarParameterDefn.TYPE_INTEGER: this.value = DataTypeUtil.toInteger( value ); break; case IScalarParameterDefn.TYPE_DATE: this.value = DataTypeUtil.toSqlDate( value ); break; case IScalarParameterDefn.TYPE_TIME: this.value = DataTypeUtil.toSqlTime( value ); break; case IScalarParameterDefn.TYPE_STRING: default: this.value = DataTypeUtil.toString(value); break; } } catch (BirtException e) { log.log(Level.SEVERE, e.getLocalizedMessage(), e); this.value = null; } }
Example 10
Source File: ReportRunner.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * @param p * the scalar parameter * @param expr * the default value expression */ protected Object stringToObject( int type, String value ) throws BirtException { if ( value == null ) { return null; } switch ( type ) { case IScalarParameterDefn.TYPE_BOOLEAN : return DataTypeUtil.toBoolean( value ); case IScalarParameterDefn.TYPE_DATE : return DataTypeUtil.toSqlDate( value ); case IScalarParameterDefn.TYPE_TIME : return DataTypeUtil.toSqlTime( value ); case IScalarParameterDefn.TYPE_DATE_TIME : return DataTypeUtil.toDate( value ); case IScalarParameterDefn.TYPE_DECIMAL : return DataTypeUtil.toBigDecimal( value ); case IScalarParameterDefn.TYPE_FLOAT : return DataTypeUtil.toDouble( value ); case IScalarParameterDefn.TYPE_STRING : return DataTypeUtil.toString( value ); case IScalarParameterDefn.TYPE_INTEGER : return DataTypeUtil.toInteger( value ); } return null; }
Example 11
Source File: BooleanCalculator.java From birt with Eclipse Public License 1.0 | 5 votes |
public Object getTypedObject( Object obj ) throws DataException { try { return DataTypeUtil.toBoolean( obj ); } catch ( BirtException e ) { throw DataException.wrap( e ); } }
Example 12
Source File: TotalConcatenate.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Decide whether should show all values whatever some strings are the * same * * @param source * @throws BirtException */ private void setShowAllValues( Object source ) throws BirtException { boolean showAllValues; if ( source == null || DataTypeUtil.toString( source ).trim( ).length( ) == 0 ) { showAllValues = false; } else if ( source instanceof String ) { try { showAllValues = DataTypeUtil.toBoolean( source ); } catch ( Exception ex ) { throw new DataException( Messages.getString( "aggregation.InvalidParameterValue" ), new Object[] {getParameterDefn( )[3].getDisplayName( ).replaceAll( "&", "" ), getDisplayName( ), source} ); } } else if ( !( source instanceof Boolean ) ) { throw new DataException( Messages.getString( "aggregation.InvalidParameterType" ) + getName( ) ); } else { showAllValues = DataTypeUtil.toBoolean( source ); } if ( showAllValues )// add each row's value to an ArrayList { values = new ArrayList<String>( ); } else // add each row's value to a LinkedHashSet { values = new LinkedHashSet<String>( ); } }
Example 13
Source File: ReportLauncher.java From birt with Eclipse Public License 1.0 | 4 votes |
public static Object convert( Object value, String dataType ) throws BirtException { if (value == null) { return value; } if ( DesignChoiceConstants.PARAM_TYPE_BOOLEAN.equals( dataType ) ) { return DataTypeUtil.toBoolean( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_DATETIME.equals( dataType ) ) { return DataTypeUtil.toDate( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_DATE.equals( dataType ) ) { return DataTypeUtil.toSqlDate( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_TIME.equals( dataType ) ) { return DataTypeUtil.toSqlTime( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_DECIMAL.equals( dataType ) ) { return DataTypeUtil.toBigDecimal( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_FLOAT.equals( dataType ) ) { return DataTypeUtil.toDouble( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_STRING.equals( dataType ) ) { return DataTypeUtil.toString( value ); } else if ( DesignChoiceConstants.PARAM_TYPE_INTEGER.equals( dataType ) ) { return DataTypeUtil.toInteger( value ); } return value; }
Example 14
Source File: ResultIterator.java From birt with Eclipse Public License 1.0 | 4 votes |
public Boolean getBoolean( String name ) throws BirtException { return DataTypeUtil.toBoolean( getValue( name ) ); }
Example 15
Source File: ParameterDialog.java From birt with Eclipse Public License 1.0 | 4 votes |
private Object validateValue( String value, String type ) throws BirtException { String tempdefaultValue = value; String exprType = ExpressionType.CONSTANT; if ( type != null ) exprType = type; if ( !( ( DesignChoiceConstants.PARAM_TYPE_STRING.endsWith( getSelectedDataType( ) ) ) || ( DesignChoiceConstants.PARAM_TYPE_BOOLEAN.endsWith( getSelectedDataType( ) ) ) ) ) { if ( ExpressionType.CONSTANT.equals( exprType ) ) { if ( DesignChoiceConstants.PARAM_TYPE_DATETIME.equals( getSelectedDataType( ) ) ) { tempdefaultValue = ParameterUtil.convertToStandardFormat( DataTypeUtil.toDate( tempdefaultValue ) ); } else if ( DesignChoiceConstants.PARAM_TYPE_DATE.equals( getSelectedDataType( ) ) ) { tempdefaultValue = ParameterUtil.convertToStandardFormat( DataTypeUtil.toSqlDate( tempdefaultValue ) ); } else if ( DesignChoiceConstants.PARAM_TYPE_TIME.equals( getSelectedDataType( ) ) ) { tempdefaultValue = ParameterUtil.convertToStandardFormat( DataTypeUtil.toSqlTime( tempdefaultValue ) ); } return ParameterValidationUtil.validate( getSelectedDataType( ), ParameterUtil.STANDARD_DATE_TIME_PATTERN, tempdefaultValue, ULocale.getDefault( ) ); } else return tempdefaultValue; } if ( DesignChoiceConstants.PARAM_TYPE_BOOLEAN.equals( getSelectedDataType( ) ) ) { if ( tempdefaultValue != null && tempdefaultValue.equals( CHOICE_NO_DEFAULT ) ) { return DataTypeUtil.toBoolean( null ); } if ( ExpressionType.CONSTANT.equals( exprType ) ) return DataTypeUtil.toBoolean( tempdefaultValue ); else return tempdefaultValue; } else return tempdefaultValue; }
Example 16
Source File: CacheResultIterator.java From birt with Eclipse Public License 1.0 | 4 votes |
public Boolean getBoolean( String name ) throws BirtException { return DataTypeUtil.toBoolean( getValue( name ) ); }
Example 17
Source File: ResultIterator.java From birt with Eclipse Public License 1.0 | 4 votes |
public Boolean getBoolean( String name ) throws BirtException { return DataTypeUtil.toBoolean( getValue( name ) ); }
Example 18
Source File: PreparedDummyQuery.java From birt with Eclipse Public License 1.0 | 4 votes |
public Boolean getBoolean( String name ) throws BirtException { return DataTypeUtil.toBoolean( this.getValue( name ) ); }