@Override public Object evaluate() { return _expr.evaluate(); }
public Object getValue() { return _expr.evaluate(); }
public void initialize( Object newObject ) { if( _values != null ) { Collection collection = (Collection)newObject; for( int i = 0; i < _values.size(); i++ ) { IExpression expression = _values.get( i ); Object val = expression.evaluate(); collection.add( val ); } } }
public void initialize( Object newObject ) { if( _keys != null ) { Map map = (Map)newObject; for( int i = 0; i < _keys.size(); i++ ) { IExpression keyExpr = _keys.get( i ); Object key = keyExpr.evaluate(); IExpression valueExpr = _values.get( i ); Object value = valueExpr.evaluate(); map.put( key, value ); } } }
public void initialize( Object newObject ) { if( _values != null ) { Collection collection = (Collection)newObject; for( int i = 0; i < _values.size(); i++ ) { IExpression expression = _values.get( i ); Object val = expression.evaluate(); collection.add( val ); } } }
public void initialize( Object newObject ) { if( _keys != null ) { Map map = (Map)newObject; for( int i = 0; i < _keys.size(); i++ ) { IExpression keyExpr = _keys.get( i ); Object key = keyExpr.evaluate(); IExpression valueExpr = _values.get( i ); Object value = valueExpr.evaluate(); map.put( key, value ); } } }
@Override public Object evaluate() { return _program != null ? _program.evaluate( null ) : _expr.evaluate(); } }
@Override public Object evaluate() { return _program != null ? _program.evaluate( null ) : _expr.evaluate(); } }
private Object evaluate( IExpression expr ) { return CompileTimeExpressionParser.convertValueToInfoFriendlyValue( expr.evaluate(), _container ); }
private Object determineStringParamVal(String paramName, Map<String, String> userParams, int i) { boolean hasUserParam = userParams.containsKey(paramName); if (hasUserParam) { String userValue = userParams.remove(paramName); if (userValue == null) { throw new IllegalArgumentException("\"" + paramName + "\" is expected to be followed by a value"); } return userValue; } else { IExpression defaultValue = ((IOptionalParamCapable)_methodInfo).getDefaultValueExpressions()[i]; if (defaultValue == null) { throw new IllegalArgumentException("requires parameter \"" + paramName + "\""); } return defaultValue.evaluate(); } }
private Object determineIntParamVal(String paramName, Map<String, String> userParams, int i) { boolean hasUserParam = userParams.containsKey(paramName); if (hasUserParam) { String userValue = userParams.remove(paramName); if (userValue == null) { throw new IllegalArgumentException("\"" + paramName + "\" is expected to be followed by a value"); } try { return new Integer(userValue); } catch (NumberFormatException e) { throw new IllegalArgumentException("\"" + paramName + "\" value is expected to be an int, was \"" + userValue + "\""); } } else { IExpression defaultValue = ((IOptionalParamCapable)_methodInfo).getDefaultValueExpressions()[i]; if (defaultValue == null) { throw new IllegalArgumentException("requires parameter \"" + paramName + "\""); } return defaultValue.evaluate(); } } }
public Object evaluate() { if( !isCompileTimeConstant() ) { return super.evaluate(); } // Convert to an array for compile-time constant e.g., {a,b,c} is legal array expr for Annotation args Class<?> arrayClass = getArrayClass( getType() ); List<IExpression> values = getValues(); Object instance = Array.newInstance( arrayClass.getComponentType(), values.size() ); for( int i = 0; i < Array.getLength( instance ); i++ ) { IExpression expr = values.get( i ); Array.set( instance, i, expr.evaluate() ); } return instance; }
@Override public Object evalRhsExpr( IExpression rhs, Object[] ctxArgs ) { while( rhs instanceof TypeAsExpression ) { rhs = ((TypeAsExpression)rhs).getLHS(); } if( rhs instanceof EvalExpression ) { return EvalExpressionTransformer.compileAndRunEvalSource( ((StringLiteral)((EvalExpression)rhs).getExpression()).getValue(), ctxArgs[0], (Object[])ctxArgs[1], (IType[])ctxArgs[2], (IType)ctxArgs[3], (EvalExpression)rhs ); } else if( rhs instanceof ILiteralExpression ) { return rhs.evaluate(); } else { throw new IllegalStateException( "Cannot evalute RHS in query of type " + rhs.getClass() + " with content " + rhs.toString() ); } }
private Object getValueFromDeclaredDefaultValueAtDeclSite( IGosuClassInternal type, String field ) { List<? extends IConstructorInfo> ctors = type.getTypeInfo().getConstructors( type ); for( IConstructorInfo ctor: ctors ) { if( ctor instanceof IGosuConstructorInfo ) { String[] paramNames = ((IGosuConstructorInfo)ctor).getParameterNames(); for( int i = 0; i < paramNames.length; i++ ) { String paramName = paramNames[i]; if( paramName != null && paramName.equals( field ) ) { return ((IGosuConstructorInfo)ctor).getDefaultValueExpressions()[i].evaluate(); } } } } return NOT_FOUND; }
public Object evaluate() { if( !isCompileTimeConstant() ) { return super.evaluate(); } // Convert to an array for compile-time constant e.g., {a,b,c} is legal array expr for Annotation args Class<?> arrayClass = getArrayClass( getType() ); List<IExpression> values = getValues(); Object instance = Array.newInstance( arrayClass.getComponentType(), values.size() ); for( int i = 0; i < Array.getLength( instance ); i++ ) { IExpression expr = values.get( i ); Object value = expr.evaluate(); if( value instanceof BigDecimal || value instanceof BigInteger ) { value = value.toString(); } Array.set( instance, i, value ); } return instance; }
@Override public Object getAnnotationDefault() { IExpression annotationDefault = getDfs().getDefaultValueExpression(); if( annotationDefault != null ) { return CompileTimeExpressionParser.convertValueToInfoFriendlyValue( annotationDefault.evaluate(), getOwnersType().getTypeInfo() ); } return null; }
public boolean isConditionLiteralTrue() { return getExpression() instanceof Literal && getExpression().isCompileTimeConstant() && CommonServices.getCoercionManager().makePrimitiveBooleanFrom( getExpression().evaluate() ); }
public boolean isConditionLiteralTrue() { return getExpression() instanceof Literal && getExpression().isCompileTimeConstant() && CommonServices.getCoercionManager().makePrimitiveBooleanFrom( getExpression().evaluate() ); }
@Override public Object getInstance() { ITypeInfo autocreateTypeInfo = GosuTypes.AUTOCREATE().getTypeInfo(); if ( _concreteType != null && JavaTypes.LIST().isAssignableFrom( _concreteType ) ) { for ( IConstructorInfo constructor : autocreateTypeInfo.getConstructors()) { IParameterInfo[] constructorParams = constructor.getParameters(); if (constructorParams.length > 0 && constructorParams[0].getFeatureType() instanceof IBlockType ) { try { IGosuParser parser = GosuParserFactory.createParser( "\\ -> new java.util.ArrayList()" ); IExpression expr = parser.parseExp( new TypelessScriptPartId( "Xml Schema autocreate block" ) ); Object block = expr.evaluate(); return constructor.getConstructor().newInstance(block); } catch (Exception e) { throw new RuntimeException(e); } } } } return autocreateTypeInfo.getConstructor().getConstructor().newInstance(); }