Ejemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void setValue(Bindings bindings, org.camunda.bpm.engine.impl.javax.el.ELContext context, Object value) throws org.camunda.bpm.engine.impl.javax.el.ELException
        public override void setValue(Bindings bindings, ELContext context, object value)
        {
            if (!lvalue)
            {
                throw new ELException(LocalMessages.get("error.value.set.rvalue", getStructuralId(bindings)));
            }
            object @base = prefix.eval(bindings, context);

            if (@base == null)
            {
                throw new PropertyNotFoundException(LocalMessages.get("error.property.base.null", prefix));
            }
            object property = getProperty(bindings, context);

            if (property == null && strict)
            {
                throw new PropertyNotFoundException(LocalMessages.get("error.property.property.notfound", "null", @base));
            }
            context.PropertyResolved = false;
            context.ELResolver.setValue(context, @base, property, value);
            if (!context.PropertyResolved)
            {
                throw new PropertyNotFoundException(LocalMessages.get("error.property.property.notfound", property, @base));
            }
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean isReadOnly(Bindings bindings, org.camunda.bpm.engine.impl.javax.el.ELContext context) throws org.camunda.bpm.engine.impl.javax.el.ELException
        public override bool isReadOnly(Bindings bindings, ELContext context)
        {
            if (!lvalue)
            {
                return(true);
            }
            object @base = prefix.eval(bindings, context);

            if (@base == null)
            {
                throw new PropertyNotFoundException(LocalMessages.get("error.property.base.null", prefix));
            }
            object property = getProperty(bindings, context);

            if (property == null && strict)
            {
                throw new PropertyNotFoundException(LocalMessages.get("error.property.property.notfound", "null", @base));
            }
            context.PropertyResolved = false;
            bool result = context.ELResolver.isReadOnly(context, @base, property);

            if (!context.PropertyResolved)
            {
                throw new PropertyNotFoundException(LocalMessages.get("error.property.property.notfound", property, @base));
            }
            return(result);
        }
Ejemplo n.º 3
0
 protected internal virtual float?coerceToFloat(object value)
 {
     if (value == null || "".Equals(value))
     {
         return(Convert.ToSingle(0));
     }
     if (value is float?)
     {
         return((float?)value);
     }
     if (value is Number)
     {
         return(Convert.ToSingle(((Number)value).floatValue()));
     }
     if (value is string)
     {
         try
         {
             return(Convert.ToSingle((string)value));
         }
         catch (System.FormatException)
         {
             throw new ELException(LocalMessages.get("error.coerce.value", value, typeof(Float)));
         }
     }
     if (value is char?)
     {
         return(Convert.ToSingle((short)((char?)value).Value));
     }
     throw new ELException(LocalMessages.get("error.coerce.type", value.GetType(), typeof(Float)));
 }
Ejemplo n.º 4
0
        public override object invoke(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes, object[] paramValues)
        {
            object @base = property.Prefix.eval(bindings, context);

            if (@base == null)
            {
                throw new PropertyNotFoundException(LocalMessages.get("error.property.base.null", property.Prefix));
            }
            object method = property.getProperty(bindings, context);

            if (method == null)
            {
                throw new PropertyNotFoundException(LocalMessages.get("error.property.method.notfound", "null", @base));
            }
            string name = bindings.convert(method, typeof(string));

            paramValues = @params.eval(bindings, context);

            context.PropertyResolved = false;
            object result = context.ELResolver.invoke(context, @base, name, paramTypes, paramValues);

            if (!context.PropertyResolved)
            {
                throw new MethodNotFoundException(LocalMessages.get("error.property.method.notfound", name, @base.GetType()));
            }
            //		if (returnType != null && !returnType.isInstance(result)) { // should we check returnType for method invocations?
            //			throw new MethodNotFoundException(LocalMessages.get("error.property.method.notfound", name, base.getClass()));
            //		}
            return(result);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Create a bindings. </summary>
 /// <param name="fnMapper"> the function mapper to use </param>
 /// <param name="varMapper"> the variable mapper to use </param>
 /// <param name="converter"> custom type converter </param>
 /// <returns> tree bindings </returns>
 public virtual Bindings bind(FunctionMapper fnMapper, VariableMapper varMapper, TypeConverter converter)
 {
     System.Reflection.MethodInfo[] methods = null;
     if (functions.Count > 0)
     {
         if (fnMapper == null)
         {
             throw new ELException(LocalMessages.get("error.function.nomapper"));
         }
         methods = new System.Reflection.MethodInfo[functions.Count];
         foreach (FunctionNode node in functions)
         {
             string image = node.Name;
             System.Reflection.MethodInfo method = null;
             int colon = image.IndexOf(':');
             if (colon < 0)
             {
                 method = fnMapper.resolveFunction("", image);
             }
             else
             {
                 method = fnMapper.resolveFunction(image.Substring(0, colon), image.Substring(colon + 1));
             }
             if (method == null)
             {
                 throw new ELException(LocalMessages.get("error.function.notfound", image));
             }
             if (node.VarArgs && method.VarArgs)
             {
                 if (method.ParameterTypes.length > node.ParamCount + 1)
                 {
                     throw new ELException(LocalMessages.get("error.function.params", image));
                 }
             }
             else
             {
                 if (method.ParameterTypes.length != node.ParamCount)
                 {
                     throw new ELException(LocalMessages.get("error.function.params", image));
                 }
             }
             methods[node.Index] = method;
         }
     }
     ValueExpression[] expressions = null;
     if (identifiers.Count > 0)
     {
         expressions = new ValueExpression[identifiers.Count];
         foreach (IdentifierNode node in identifiers)
         {
             ValueExpression expression = null;
             if (varMapper != null)
             {
                 expression = varMapper.resolveVariable(node.Name);
             }
             expressions[node.Index] = expression;
         }
     }
     return(new Bindings(methods, expressions, converter));
 }
Ejemplo n.º 6
0
 protected internal virtual sbyte?coerceToByte(object value)
 {
     if (value == null || "".Equals(value))
     {
         return(Convert.ToSByte((sbyte)0));
     }
     if (value is sbyte?)
     {
         return((sbyte?)value);
     }
     if (value is Number)
     {
         return(Convert.ToSByte(((Number)value).byteValue()));
     }
     if (value is string)
     {
         try
         {
             return(Convert.ToSByte((string)value));
         }
         catch (System.FormatException)
         {
             throw new ELException(LocalMessages.get("error.coerce.value", value, typeof(Byte)));
         }
     }
     if (value is char?)
     {
         return(Convert.ToSByte(Convert.ToInt16((short)((char?)value).Value).byteValue()));
     }
     throw new ELException(LocalMessages.get("error.coerce.type", value.GetType(), typeof(Byte)));
 }
Ejemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") protected Object coerceToType(Object value, Class type)
        protected internal virtual object coerceToType(object value, Type type)
        {
            if (type == typeof(string))
            {
                return(coerceToString(value));
            }
            if (type == typeof(Long) || type == typeof(long))
            {
                return(coerceToLong(value));
            }
            if (type == typeof(Double) || type == typeof(double))
            {
                return(coerceToDouble(value));
            }
            if (type == typeof(Boolean) || type == typeof(bool))
            {
                return(coerceToBoolean(value));
            }
            if (type == typeof(Integer) || type == typeof(int))
            {
                return(coerceToInteger(value));
            }
            if (type == typeof(Float) || type == typeof(float))
            {
                return(coerceToFloat(value));
            }
            if (type == typeof(Short) || type == typeof(short))
            {
                return(coerceToShort(value));
            }
            if (type == typeof(Byte) || type == typeof(sbyte))
            {
                return(coerceToByte(value));
            }
            if (type == typeof(Character) || type == typeof(char))
            {
                return(coerceToCharacter(value));
            }
            if (type == typeof(decimal))
            {
                return(coerceToBigDecimal(value));
            }
            if (type == typeof(BigInteger))
            {
                return(coerceToBigInteger(value));
            }
            if (type.BaseType == typeof(Enum))
            {
                return(coerceToEnum(value, (Type)type));
            }
            if (value == null || value.GetType() == type || type.IsInstanceOfType(value))
            {
                return(value);
            }
            if (value is string)
            {
                return(coerceStringToType((string)value, type));
            }
            throw new ELException(LocalMessages.get("error.coerce.type", value.GetType(), type));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Create a new method expression.
        /// The expression must be an lvalue expression or literal text.
        /// The expected return type may be <code>null</code>, meaning "don't care".
        /// If it is an lvalue expression, the parameter types must not be <code>null</code>.
        /// If it is literal text, the expected return type must not be <code>void</code>. </summary>
        /// <param name="store"> used to get the parse tree from. </param>
        /// <param name="functions"> the function mapper used to bind functions </param>
        /// <param name="variables"> the variable mapper used to bind variables </param>
        /// <param name="expr"> the expression string </param>
        /// <param name="returnType"> the expected return type (may be <code>null</code>) </param>
        /// <param name="paramTypes"> the expected parameter types (must not be <code>null</code> for lvalues) </param>
        public TreeMethodExpression(TreeStore store, FunctionMapper functions, VariableMapper variables, TypeConverter converter, string expr, Type returnType, Type[] paramTypes) : base()
        {
            Tree tree = store.get(expr);

            this.builder  = store.Builder;
            this.bindings = tree.bind(functions, variables, converter);
            this.expr     = expr;
            this.type     = returnType;
            this.types    = paramTypes;
            this.node     = tree.Root;
            this.deferred = tree.Deferred;

            if (node.LiteralText)
            {
                if (returnType == typeof(void))
                {
                    throw new ELException(LocalMessages.get("error.method.literal.void", expr));
                }
            }
            else if (!node.MethodInvocation)
            {
                if (!node.LeftValue)
                {
                    throw new ELException(LocalMessages.get("error.method.invalid", expr));
                }
                if (paramTypes == null)
                {
                    throw new ELException(LocalMessages.get("error.method.notypes"));
                }
            }
        }
Ejemplo n.º 9
0
 protected internal virtual decimal coerceToBigDecimal(object value)
 {
     if (value == null || "".Equals(value))
     {
         return(decimal.valueOf(0l));
     }
     if (value is decimal)
     {
         return((decimal)value);
     }
     if (value is BigInteger)
     {
         return(new decimal((BigInteger)value));
     }
     if (value is Number)
     {
         return(new decimal(((Number)value).doubleValue()));
     }
     if (value is string)
     {
         try
         {
             return(new decimal((string)value));
         }
         catch (System.FormatException)
         {
             throw new ELException(LocalMessages.get("error.coerce.value", value, typeof(decimal)));
         }
     }
     if (value is char?)
     {
         return(new decimal((short)((char?)value).Value));
     }
     throw new ELException(LocalMessages.get("error.coerce.type", value.GetType(), typeof(decimal)));
 }
Ejemplo n.º 10
0
        public override object invoke(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes, object[] paramValues)
        {
            object @base = prefix.eval(bindings, context);

            if (@base == null)
            {
                throw new PropertyNotFoundException(LocalMessages.get("error.property.base.null", prefix));
            }
            object property = getProperty(bindings, context);

            if (property == null && strict)
            {
                throw new PropertyNotFoundException(LocalMessages.get("error.property.method.notfound", "null", @base));
            }
            string name = bindings.convert(property, typeof(string));

            System.Reflection.MethodInfo method = findMethod(name, @base.GetType(), returnType, paramTypes);
            try
            {
                return(method.invoke(@base, paramValues));
            }
            catch (IllegalAccessException)
            {
                throw new ELException(LocalMessages.get("error.property.method.access", name, @base.GetType()));
            }
            catch (System.ArgumentException e)
            {
                throw new ELException(LocalMessages.get("error.property.method.invocation", name, @base.GetType()), e);
            }
            catch (InvocationTargetException e)
            {
                throw new ELException(LocalMessages.get("error.property.method.invocation", name, @base.GetType()), e.InnerException);
            }
        }
Ejemplo n.º 11
0
 protected internal virtual long?coerceToLong(object value)
 {
     if (value == null || "".Equals(value))
     {
         return(Convert.ToInt64(0l));
     }
     if (value is long?)
     {
         return((long?)value);
     }
     if (value is Number)
     {
         return(Convert.ToInt64(((Number)value).longValue()));
     }
     if (value is string)
     {
         try
         {
             return(Convert.ToInt64((string)value));
         }
         catch (System.FormatException)
         {
             throw new ELException(LocalMessages.get("error.coerce.value", value, typeof(Long)));
         }
     }
     if (value is char?)
     {
         return(Convert.ToInt64((short)((char?)value).Value));
     }
     throw new ELException(LocalMessages.get("error.coerce.type", value.GetType(), typeof(Long)));
 }
Ejemplo n.º 12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") private static final boolean gt0(TypeConverter converter, Object o1, Object o2)
        private static bool gt0(TypeConverter converter, object o1, object o2)
        {
            Type t1 = o1.GetType();
            Type t2 = o2.GetType();

            if (t1.IsAssignableFrom(typeof(decimal)) || t2.IsAssignableFrom(typeof(decimal)))
            {
                return(converter.convert(o1, typeof(decimal)).compareTo(converter.convert(o2, typeof(decimal))) > 0);
            }
            if (SIMPLE_FLOAT_TYPES.Contains(t1) || SIMPLE_FLOAT_TYPES.Contains(t2))
            {
                return(converter.convert(o1, typeof(Double)) > converter.convert(o2, typeof(Double)));
            }
            if (t1.IsAssignableFrom(typeof(BigInteger)) || t2.IsAssignableFrom(typeof(BigInteger)))
            {
                return(converter.convert(o1, typeof(BigInteger)).compareTo(converter.convert(o2, typeof(BigInteger))) > 0);
            }
            if (SIMPLE_INTEGER_TYPES.Contains(t1) || SIMPLE_INTEGER_TYPES.Contains(t2))
            {
                return(converter.convert(o1, typeof(Long)) > converter.convert(o2, typeof(Long)));
            }
            if (t1 == typeof(string) || t2 == typeof(string))
            {
                return(converter.convert(o1, typeof(string)).compareTo(converter.convert(o2, typeof(string))) > 0);
            }
            if (o1 is IComparable)
            {
                return(((IComparable)o1).CompareTo(o2) > 0);
            }
            if (o2 is IComparable)
            {
                return(((IComparable)o2).CompareTo(o1) < 0);
            }
            throw new ELException(LocalMessages.get("error.compare.types", o1.GetType(), o2.GetType()));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Wrap an object into a value expression. </summary>
        /// <param name="converter"> type converter </param>
        /// <param name="object"> the object to wrap </param>
        /// <param name="type"> the expected type this object will be coerced in <seealso cref="getValue(ELContext)"/>. </param>
        public ObjectValueExpression(TypeConverter converter, object @object, Type type) : base()
        {
            this.converter = converter;
            this.@object   = @object;
            this.type      = type;

            if (type == null)
            {
                throw new System.NullReferenceException(LocalMessages.get("error.value.notype"));
            }
        }
Ejemplo n.º 14
0
 public static Number neg(TypeConverter converter, object value)
 {
     if (value == null)
     {
         return(LONG_ZERO);
     }
     if (value is decimal)
     {
         return(-((decimal)value));
     }
     if (value is BigInteger)
     {
         return(-((BigInteger)value));
     }
     if (value is double?)
     {
         return(Convert.ToDouble(-((double?)value).Value));
     }
     if (value is float?)
     {
         return(Convert.ToSingle(-((float?)value).Value));
     }
     if (value is string)
     {
         if (isDotEe((string)value))
         {
             return(Convert.ToDouble(-converter.convert(value, typeof(Double)).doubleValue()));
         }
         return(Convert.ToInt64(-converter.convert(value, typeof(Long)).longValue()));
     }
     if (value is long?)
     {
         return(Convert.ToInt64(-((long?)value).Value));
     }
     if (value is int?)
     {
         return(Convert.ToInt32(-((int?)value).Value));
     }
     if (value is short?)
     {
         return(Convert.ToInt16((short)-((short?)value).Value));
     }
     if (value is sbyte?)
     {
         return(Convert.ToSByte((sbyte)-((sbyte?)value).Value));
     }
     throw new ELException(LocalMessages.get("error.negate", value.GetType()));
 }
Ejemplo n.º 15
0
 public override object eval(Bindings bindings, ELContext context)
 {
     System.Reflection.MethodInfo method = bindings.getFunction(index);
     try
     {
         return(invoke(bindings, context, null, method));
     }
     catch (IllegalAccessException e)
     {
         throw new ELException(LocalMessages.get("error.function.access", name), e);
     }
     catch (InvocationTargetException e)
     {
         throw new ELException(LocalMessages.get("error.function.invocation", name), e.InnerException);
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Create a new value expression. </summary>
        /// <param name="store"> used to get the parse tree from. </param>
        /// <param name="functions"> the function mapper used to bind functions </param>
        /// <param name="variables"> the variable mapper used to bind variables </param>
        /// <param name="expr"> the expression string </param>
        /// <param name="type"> the expected type (may be <code>null</code>) </param>
        public TreeValueExpression(TreeStore store, FunctionMapper functions, VariableMapper variables, TypeConverter converter, string expr, Type type) : base()
        {
            Tree tree = store.get(expr);

            this.builder  = store.Builder;
            this.bindings = tree.bind(functions, variables, converter);
            this.expr     = expr;
            this.type     = type;
            this.node     = tree.Root;
            this.deferred = tree.Deferred;

            if (type == null)
            {
                throw new System.NullReferenceException(LocalMessages.get("error.value.notype"));
            }
        }
Ejemplo n.º 17
0
 protected internal virtual bool?coerceToBoolean(object value)
 {
     if (value == null || "".Equals(value))
     {
         return(false);
     }
     if (value is bool?)
     {
         return((bool?)value);
     }
     if (value is string)
     {
         return(Convert.ToBoolean((string)value));
     }
     throw new ELException(LocalMessages.get("error.coerce.type", value.GetType(), typeof(Boolean)));
 }
Ejemplo n.º 18
0
        public override void setValue(Bindings bindings, ELContext context, object value)
        {
            ValueExpression expression = bindings.getVariable(index);

            if (expression != null)
            {
                expression.setValue(context, value);
                return;
            }
            context.PropertyResolved = false;
            context.ELResolver.setValue(context, null, name, value);
            if (!context.PropertyResolved)
            {
                throw new PropertyNotFoundException(LocalMessages.get("error.identifier.property.notfound", name));
            }
        }
Ejemplo n.º 19
0
 protected internal virtual System.Reflection.MethodInfo findMethod(string name, Type clazz, Type returnType, Type[] paramTypes)
 {
     System.Reflection.MethodInfo method = null;
     try
     {
         method = clazz.GetMethod(name, paramTypes);
     }
     catch (NoSuchMethodException)
     {
         throw new MethodNotFoundException(LocalMessages.get("error.property.method.notfound", name, clazz));
     }
     if (returnType != null && !returnType.IsAssignableFrom(method.ReturnType))
     {
         throw new MethodNotFoundException(LocalMessages.get("error.property.method.notfound", name, clazz));
     }
     return(method);
 }
Ejemplo n.º 20
0
        public override object eval(Bindings bindings, ELContext context)
        {
            ValueExpression expression = bindings.getVariable(index);

            if (expression != null)
            {
                return(expression.getValue(context));
            }
            context.PropertyResolved = false;
            object result = context.ELResolver.getValue(context, null, name);

            if (!context.PropertyResolved)
            {
                throw new PropertyNotFoundException(LocalMessages.get("error.identifier.property.notfound", name));
            }
            return(result);
        }
Ejemplo n.º 21
0
        public override MethodInfo getMethodInfo(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes)
        {
            object @base = prefix.eval(bindings, context);

            if (@base == null)
            {
                throw new PropertyNotFoundException(LocalMessages.get("error.property.base.null", prefix));
            }
            object property = getProperty(bindings, context);

            if (property == null && strict)
            {
                throw new PropertyNotFoundException(LocalMessages.get("error.property.method.notfound", "null", @base));
            }
            string name = bindings.convert(property, typeof(string));

            System.Reflection.MethodInfo method = findMethod(name, @base.GetType(), returnType, paramTypes);
            return(new MethodInfo(method.Name, method.ReturnType, paramTypes));
        }
Ejemplo n.º 22
0
 public override object invoke(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes, object[] @params)
 {
     System.Reflection.MethodInfo method = getMethod(bindings, context, returnType, paramTypes);
     try
     {
         return(method.invoke(null, @params));
     }
     catch (IllegalAccessException)
     {
         throw new ELException(LocalMessages.get("error.identifier.method.access", name));
     }
     catch (System.ArgumentException e)
     {
         throw new ELException(LocalMessages.get("error.identifier.method.invocation", name, e));
     }
     catch (InvocationTargetException e)
     {
         throw new ELException(LocalMessages.get("error.identifier.method.invocation", name, e.InnerException));
     }
 }
Ejemplo n.º 23
0
 protected internal virtual char?coerceToCharacter(object value)
 {
     if (value == null || "".Equals(value))
     {
         return(Convert.ToChar((char)0));
     }
     if (value is char?)
     {
         return((char?)value);
     }
     if (value is Number)
     {
         return(Convert.ToChar((char)((Number)value).shortValue()));
     }
     if (value is string)
     {
         return(Convert.ToChar(((string)value)[0]));
     }
     throw new ELException(LocalMessages.get("error.coerce.type", value.GetType(), typeof(Character)));
 }
Ejemplo n.º 24
0
        protected internal virtual object coerceStringToType(string value, Type type)
        {
            PropertyEditor editor = PropertyEditorManager.findEditor(type);

            if (editor == null)
            {
                if ("".Equals(value))
                {
                    return(null);
                }
                throw new ELException(LocalMessages.get("error.coerce.type", typeof(string), type));
            }
            else
            {
                if ("".Equals(value))
                {
                    try
                    {
                        editor.AsText = value;
                    }
                    catch (System.ArgumentException)
                    {
                        return(null);
                    }
                }
                else
                {
                    try
                    {
                        editor.AsText = value;
                    }
                    catch (System.ArgumentException)
                    {
                        throw new ELException(LocalMessages.get("error.coerce.value", value, type));
                    }
                }
                return(editor.Value);
            }
        }
Ejemplo n.º 25
0
        protected internal virtual System.Reflection.MethodInfo getMethod(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes)
        {
            object value = eval(bindings, context);

            if (value == null)
            {
                throw new MethodNotFoundException(LocalMessages.get("error.identifier.method.notfound", name));
            }
            if (value is System.Reflection.MethodInfo)
            {
                System.Reflection.MethodInfo method = (System.Reflection.MethodInfo)value;
                if (returnType != null && !returnType.IsAssignableFrom(method.ReturnType))
                {
                    throw new MethodNotFoundException(LocalMessages.get("error.identifier.method.notfound", name));
                }
                if (!Arrays.Equals(method.ParameterTypes, paramTypes))
                {
                    throw new MethodNotFoundException(LocalMessages.get("error.identifier.method.notfound", name));
                }
                return(method);
            }
            throw new MethodNotFoundException(LocalMessages.get("error.identifier.method.notamethod", name, value.GetType()));
        }
Ejemplo n.º 26
0
        public override object eval(Bindings bindings, ELContext context)
        {
            object @base = prefix.eval(bindings, context);

            if (@base == null)
            {
                return(null);
            }
            object property = getProperty(bindings, context);

            if (property == null && strict)
            {
                return(null);
            }
            context.PropertyResolved = false;
            object result = context.ELResolver.getValue(context, @base, property);

            if (!context.PropertyResolved)
            {
                throw new PropertyNotFoundException(LocalMessages.get("error.property.property.notfound", property, @base));
            }
            return(result);
        }
Ejemplo n.º 27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") protected <T extends Enum<T>> T coerceToEnum(Object value, Class<T> type)
        protected internal virtual T coerceToEnum <T>(object value, Type type) where T : Enum <T>
        {
            type = typeof(T);
            if (value == null || "".Equals(value))
            {
                return(null);
            }
            if (type.IsInstanceOfType(value))
            {
                return((T)value);
            }
            if (value is string)
            {
                try
                {
                    return(Enum.valueOf(type, (string)value));
                }
                catch (System.ArgumentException)
                {
                    throw new ELException(LocalMessages.get("error.coerce.value", value, type));
                }
            }
            throw new ELException(LocalMessages.get("error.coerce.type", value.GetType(), type));
        }
Ejemplo n.º 28
0
 public override void setValue(Bindings bindings, ELContext context, object value)
 {
     throw new ELException(LocalMessages.get("error.value.set.rvalue", getStructuralId(bindings)));
 }
Ejemplo n.º 29
0
 public sealed override object invoke(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes, object[] paramValues)
 {
     throw new ELException(LocalMessages.get("error.method.invalid", getStructuralId(bindings)));
 }
Ejemplo n.º 30
0
 public TreeBuilderException(string expression, int position, string encountered, string expected, string message) : base(LocalMessages.get("error.build", expression, message))
 {
     this.expression  = expression;
     this.position    = position;
     this.encountered = encountered;
     this.expected    = expected;
 }