protected Object getDefaultObjectValue(LightweightTypeReference type) { if(!type.isPrimitive()) return null; else { JvmPrimitiveType primitive = (JvmPrimitiveType) type.getType(); switch (services.getPrimitives().primitiveKind(primitive)) { case Byte : return Byte.valueOf((byte)0); case Short : return Short.valueOf((short)0); case Char : return Character.valueOf((char)0); case Int : return Integer.valueOf(0); case Long : return Long.valueOf(0l); case Float : return Float.valueOf(0f); case Double : return Double.valueOf("0."); case Boolean : return Boolean.FALSE; case Void : return null; default : throw new IllegalArgumentException("Not a primitive : "+primitive); } } }
initialValue = internalEvaluate(variableDecl.getRight(), context, indicator); } else { if (services.getPrimitives().isPrimitive(variableDecl.getType())) { Primitive primitiveKind = services.getPrimitives().primitiveKind((JvmPrimitiveType) variableDecl.getType().getType()); switch(primitiveKind) { case Boolean:
return this._typeReferenceBuilder.typeRef(Void.TYPE); if (this.services.getPrimitives().isPrimitive(type)) { return this._typeReferenceBuilder.typeRef(id);
protected Object _doEvaluate(XCastedExpression castedExpression, IEvaluationContext context, CancelIndicator indicator) { Object result = internalEvaluate(castedExpression.getTarget(), context, indicator); StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, castedExpression); LightweightTypeReference targetType = owner.toLightweightTypeReference(castedExpression.getType()); result = wrapOrUnwrapArray(result, targetType); result = coerceArgumentType(result, castedExpression.getType()); JvmType castType = castedExpression.getType().getType(); if (castType instanceof JvmPrimitiveType) { if (result == null) { throwNullPointerException(castedExpression, "Cannot cast null to primitive " + castType.getIdentifier()); } return castToPrimitiveType(result, services.getPrimitives().primitiveKind((JvmPrimitiveType) castType)); } else { String typeName = castType.getQualifiedName(); Class<?> expectedType = null; try { expectedType = getJavaType(castType); } catch (ClassNotFoundException e) { throw new EvaluationException(new NoClassDefFoundError(typeName)); } try { expectedType.cast(result); } catch (ClassCastException e) { throw new EvaluationException(new ClassCastException(typeName)); } return result; } }