Search in sources :

Example 21 with WholeIllegalArgumentException

use of org.whole.lang.exceptions.WholeIllegalArgumentException in project whole by wholeplatform.

the class MathUtils method subtraction.

public static IEntity subtraction(IEntity result1, IEntity result2) {
    DataKinds dataKind1 = DataTypeUtils.getUnboxedDataKind(result1);
    DataKinds dataKind2 = DataTypeUtils.getUnboxedDataKind(result2);
    IEntity result;
    if (dataKind1.isNotAData() || dataKind2.isNotAData())
        throw new WholeIllegalArgumentException(WholeMessages.no_data);
    else if (dataKind1.isDouble() || dataKind2.isDouble())
        result = BindingManagerFactory.instance.createValue(DataTypeUtils.toDouble(result1) - DataTypeUtils.toDouble(result2));
    else if (dataKind1.isFloat() || dataKind2.isFloat())
        result = BindingManagerFactory.instance.createValue(DataTypeUtils.toFloat(result1) - DataTypeUtils.toFloat(result2));
    else if (dataKind1.isLong() || dataKind2.isLong())
        result = BindingManagerFactory.instance.createValue(DataTypeUtils.toLong(result1) - DataTypeUtils.toLong(result2));
    else
        result = BindingManagerFactory.instance.createValue(DataTypeUtils.toInt(result1) - DataTypeUtils.toInt(result2));
    return result;
}
Also used : IEntity(org.whole.lang.model.IEntity) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException) DataKinds(org.whole.lang.reflect.DataKinds)

Example 22 with WholeIllegalArgumentException

use of org.whole.lang.exceptions.WholeIllegalArgumentException in project whole by wholeplatform.

the class MathUtils method multiplication.

public static IEntity multiplication(IEntity result1, IEntity result2) {
    DataKinds dataKind1 = DataTypeUtils.getUnboxedDataKind(result1);
    DataKinds dataKind2 = DataTypeUtils.getUnboxedDataKind(result2);
    IEntity result;
    if (dataKind1.isNotAData() || dataKind2.isNotAData())
        throw new WholeIllegalArgumentException(WholeMessages.no_data);
    else if (dataKind1.isDouble() || dataKind2.isDouble())
        result = BindingManagerFactory.instance.createValue(DataTypeUtils.toDouble(result1) * DataTypeUtils.toDouble(result2));
    else if (dataKind1.isFloat() || dataKind2.isFloat())
        result = BindingManagerFactory.instance.createValue(DataTypeUtils.toFloat(result1) * DataTypeUtils.toFloat(result2));
    else if (dataKind1.isLong() || dataKind2.isLong())
        result = BindingManagerFactory.instance.createValue(DataTypeUtils.toLong(result1) * DataTypeUtils.toLong(result2));
    else
        result = BindingManagerFactory.instance.createValue(DataTypeUtils.toInt(result1) * DataTypeUtils.toInt(result2));
    return result;
}
Also used : IEntity(org.whole.lang.model.IEntity) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException) DataKinds(org.whole.lang.reflect.DataKinds)

Example 23 with WholeIllegalArgumentException

use of org.whole.lang.exceptions.WholeIllegalArgumentException in project whole by wholeplatform.

the class CommonsDataTypePresentationParser method parseEntityDescriptor.

public static EntityDescriptor<? extends IEntity> parseEntityDescriptor(String value) {
    int index = value.indexOf('#');
    if (index > 0) {
        String languageUri = value.substring(0, index);
        ILanguageKit lk = /*= null;
			if (ReflectionFactory.hasLanguageKit(languageUri)) {
    			for (ILanguageKit lk2 : ReflectionFactory.getLanguageKits(true))
    				if (lk2.getName().equalsIgnoreCase(languageUri)) {
    					lk = lk2; 
    					break;
    				}
    		}
    		if (lk == null)
    			lk*/
        ReflectionFactory.getLanguageKit(languageUri);
        EntityDescriptor<?> ed = lk.getEntityDescriptorEnum().valueOf(value.substring(index + 1));
        if (ed != null)
            return ed;
    }
    throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
}
Also used : WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException) ILanguageKit(org.whole.lang.reflect.ILanguageKit)

Example 24 with WholeIllegalArgumentException

use of org.whole.lang.exceptions.WholeIllegalArgumentException in project whole by wholeplatform.

the class DefaultDataTypePresentationParser method parseEnumValue.

public EnumValue parseEnumValue(EntityDescriptor<?> ed, String value) {
    EnumType<?> dataEnumType = ed.getDataEnumType();
    if (dataEnumType == null)
        throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
    EnumValue result = dataEnumType.valueOf(value);
    if (result != null)
        return result;
    for (Iterator<? extends EnumValue> i = dataEnumType.iterator(); i.hasNext(); ) {
        EnumValue enumValue = i.next();
        if (enumValue.getName().equalsIgnoreCase(value))
            return enumValue;
    }
    throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
}
Also used : EnumValue(org.whole.lang.model.EnumValue) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException)

Example 25 with WholeIllegalArgumentException

use of org.whole.lang.exceptions.WholeIllegalArgumentException in project whole by wholeplatform.

the class DefaultDataTypePersistenceParser method parseEnumValue.

public EnumValue parseEnumValue(EntityDescriptor<?> ed, String value) {
    EnumType<?> dataEnumType = ed.getDataEnumType();
    if (dataEnumType == null)
        throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
    EnumValue result = dataEnumType.valueOf(value);
    if (result == null)
        throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
    return result;
}
Also used : EnumValue(org.whole.lang.model.EnumValue) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException)

Aggregations

WholeIllegalArgumentException (org.whole.lang.exceptions.WholeIllegalArgumentException)32 DataKinds (org.whole.lang.reflect.DataKinds)16 IEntity (org.whole.lang.model.IEntity)15 EnumValue (org.whole.lang.model.EnumValue)3 IBindingManager (org.whole.lang.bindings.IBindingManager)2 IWholeRuntimeException (org.whole.lang.exceptions.IWholeRuntimeException)2 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)2 ILanguageKit (org.whole.lang.reflect.ILanguageKit)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 DateTimeZone (org.joda.time.DateTimeZone)1 DateTimeParser (org.joda.time.format.DateTimeParser)1 DateTimeParserBucket (org.joda.time.format.DateTimeParserBucket)1 FixedDateTimeZone (org.joda.time.tz.FixedDateTimeZone)1 ITransactionScope (org.whole.lang.bindings.ITransactionScope)1 URLPersistenceProvider (org.whole.lang.codebase.URLPersistenceProvider)1 IEntityFactory (org.whole.lang.factories.IEntityFactory)1 IEntityRegistryProvider (org.whole.lang.factories.IEntityRegistryProvider)1 CompiledPattern (org.whole.lang.grammars.model.CompiledPattern)1 Pattern (org.whole.lang.grammars.model.Pattern)1