Search in sources :

Example 26 with WholeIllegalArgumentException

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

the class MathInterpreterVisitor method visit.

@Override
public void visit(ExclusiveOr entity) {
    boolean value = false;
    for (int i = 0, size = entity.size(); i < size; i++) {
        IEntity result = evaluate(entity.get(i));
        DataKinds dataKinds = DataTypeUtils.getUnboxedDataKind(result);
        if (dataKinds.isNotAData())
            throw new WholeIllegalArgumentException(WholeMessages.no_data).withSourceEntity(entity).withBindings(getBindings());
        else if (!dataKinds.isBoolean())
            throw new WholeIllegalArgumentException(WholeMessages.illegal_data_conversion).withSourceEntity(entity).withBindings(getBindings());
        else
            value ^= result.wBooleanValue();
    }
    setResult(createBooleanLiteral(value));
}
Also used : IEntity(org.whole.lang.model.IEntity) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException) DataKinds(org.whole.lang.reflect.DataKinds)

Example 27 with WholeIllegalArgumentException

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

the class MathInterpreterVisitor method visit.

@Override
public void visit(Or entity) {
    boolean value = false;
    for (int i = 0, size = entity.size(); i < size; i++) {
        IEntity result = evaluate(entity.get(i));
        DataKinds dataKinds = DataTypeUtils.getUnboxedDataKind(result);
        if (dataKinds.isNotAData())
            throw new WholeIllegalArgumentException(WholeMessages.no_data).withSourceEntity(entity).withBindings(getBindings());
        else if (!dataKinds.isBoolean())
            throw new WholeIllegalArgumentException(WholeMessages.illegal_data_conversion).withSourceEntity(entity).withBindings(getBindings());
        else if (value |= result.wBooleanValue())
            break;
    }
    setResult(createBooleanLiteral(value));
}
Also used : IEntity(org.whole.lang.model.IEntity) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException) DataKinds(org.whole.lang.reflect.DataKinds)

Example 28 with WholeIllegalArgumentException

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

the class MathInterpreterVisitor method visit.

@Override
public void visit(And entity) {
    boolean value = true;
    for (int i = 0, size = entity.size(); i < size; i++) {
        IEntity result = evaluate(entity.get(i));
        DataKinds dataKinds = DataTypeUtils.getUnboxedDataKind(result);
        if (dataKinds.isNotAData())
            throw new WholeIllegalArgumentException(WholeMessages.no_data).withSourceEntity(entity).withBindings(getBindings());
        else if (!dataKinds.isBoolean())
            throw new WholeIllegalArgumentException(WholeMessages.illegal_data_conversion).withSourceEntity(entity).withBindings(getBindings());
        else if (!(value &= result.wBooleanValue()))
            break;
    }
    setResult(createBooleanLiteral(value));
}
Also used : IEntity(org.whole.lang.model.IEntity) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException) DataKinds(org.whole.lang.reflect.DataKinds)

Example 29 with WholeIllegalArgumentException

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

the class AbstractISO8601DataTypeParser method parseObject.

public Object parseObject(EntityDescriptor<?> ed, String value) {
    DateTimeParser parser = getFormatter().getParser();
    DateTimeParserBucket bucket = new DateTimeParserBucket(0, ISOChronology.getInstance(), null);
    // use a custom UTC to check if offset part is parsed
    if (bucket.getZone() == null)
        bucket.setZone(UTC);
    if (parser.parseInto(bucket, value, 0) < 0)
        throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
    DateTimeZone zone = bucket.getZone();
    if (zone == null)
        return parseWithTimeZone(bucket);
    else
        return parseWithoutTimeZone(bucket);
}
Also used : DateTimeParser(org.joda.time.format.DateTimeParser) DateTimeParserBucket(org.joda.time.format.DateTimeParserBucket) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException) DateTimeZone(org.joda.time.DateTimeZone) FixedDateTimeZone(org.joda.time.tz.FixedDateTimeZone)

Example 30 with WholeIllegalArgumentException

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

the class TestsDataTypePresentationParser method parseEnumValue.

public EnumValue parseEnumValue(EntityDescriptor<?> ed, String value) {
    if (TestsEntityDescriptorEnum.CommentKind_ord == ed.getOrdinal()) {
        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;
    } else
        return super.parseEnumValue(ed, value);
}
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