public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) { return factory.isResolveable(nameCache) || (thisValue != null && getFieldOrAccessor(thisValue.getClass(), nameCache) != null); }
public static Member getFieldOrAccessor(Class clazz, String property) { for (Field f : clazz.getFields()) { if (property.equals(f.getName())) { if ((f.getModifiers() & PUBLIC) != 0) return f; break; } } return getGetter(clazz, property); }
public ParmValuePair(String parameter, ExecutableStatement statement, Class ingressType, ParserContext pCtx) { if (parameter != null && parameter.length() != 0) { this.setExpression = MVEL.compileSetExpression(parameter, ingressType != null ? getReturnType(ingressType, parameter, pCtx) : Object.class , pCtx); } this.statement = statement; }
Member member = getFieldOrWriteAccessor(ctx.getClass(), tk, value == null ? null : ingressType); fld.set(ctx, PropertyTools.getPrimitiveInitialValue(fld.getType())); addAccessorNode(new FieldAccessor(fld)); meth.invoke(ctx, PropertyTools.getPrimitiveInitialValue(meth.getParameterTypes()[0]));
public static boolean hasSetter(Field field) { Method meth = getSetter(field.getDeclaringClass(), field.getName()); return meth != null && meth.getParameterTypes().length == 1 && field.getType().isAssignableFrom(meth.getParameterTypes()[0]); }
public static boolean isEmpty(Object o) { if (o != null) { if (o instanceof Object[]) { return ((Object[]) o).length == 0 || (((Object[]) o).length == 1 && isEmpty(((Object[]) o)[0])); } else { return ("".equals(valueOf(o))) || "null".equals(valueOf(o)) || (o instanceof Collection && ((Collection) o).size() == 0) || (o instanceof Map && ((Map) o).size() == 0); } } return true; }
env.put("$OS_NAME", getProperty("os.name")); env.put("$OS_VERSION", getProperty("os.version")); env.put("$JAVA_VERSION", PropertyTools.getJavaVersion()); env.put("$CWD", new File(".").getAbsolutePath()); env.put("$COMMAND_PASSTRU", "false"); System.out.println("No config file found. Loading default config."); if (!contains(getProperty("os.name").toLowerCase(), "windows")) { env.put("$PATH", "/bin:/usr/bin:/sbin:/usr/sbin");
if (member == null) { addWriteCache(curr.getClass(), tk != null ? tk.hashCode() : -1, (member = value != null ? getFieldOrWriteAccessor(curr.getClass(), tk, value.getClass()) : getFieldOrWriteAccessor(curr.getClass(), tk)));
System.out.println("No config file found. Loading default config."); if (!contains(getProperty("os.name").toLowerCase(), "windows")) { env.put("$PATH", "/bin:/usr/bin:/sbin:/usr/sbin");
public Object setValue(Object ctx, Object elCtx, VariableResolverFactory variableFactory, Object value) { // this local field is required to make sure exception block works with the same coercionRequired value // and it is not changed by another thread while setter is invoked boolean attemptedCoercion = coercionRequired; try { if (coercionRequired) { return method.invoke(ctx, convert(value, targetType)); } else { return method.invoke(ctx, value == null && primitive ? PropertyTools.getPrimitiveInitialValue(targetType) : value); } } catch (IllegalArgumentException e) { if (ctx != null && method.getDeclaringClass() != ctx.getClass()) { Method o = getBestCandidate(EMPTY, method.getName(), ctx.getClass(), ctx.getClass().getMethods(), true); if (o != null) { return executeOverrideTarget(o, ctx, value); } } if (!attemptedCoercion) { coercionRequired = true; return setValue(ctx, elCtx, variableFactory, value); } throw new RuntimeException("unable to bind property", e); } catch (Exception e) { throw new RuntimeException("error calling method: " + method.getDeclaringClass().getName() + "." + method.getName(), e); } }
Member member = getFieldOrWriteAccessor(ctx.getClass(), tk, value == null ? null : ingressType); fld.set(ctx, PropertyTools.getPrimitiveInitialValue(fld.getType())); addAccessorNode(new FieldAccessor(fld)); meth.invoke(ctx, PropertyTools.getPrimitiveInitialValue(meth.getParameterTypes()[0]));
public static boolean hasSetter(Field field) { Method meth = getSetter(field.getDeclaringClass(), field.getName()); return meth != null && meth.getParameterTypes().length == 1 && field.getType().isAssignableFrom(meth.getParameterTypes()[0]); }
public static boolean isEmpty(Object o) { if (o != null) { if (o instanceof Object[]) { return ((Object[]) o).length == 0 || (((Object[]) o).length == 1 && isEmpty(((Object[]) o)[0])); } else { return ("".equals(valueOf(o))) || "null".equals(valueOf(o)) || (o instanceof Collection && ((Collection) o).size() == 0) || (o instanceof Map && ((Map) o).size() == 0); } } return true; }
env.put("$OS_NAME", getProperty("os.name")); env.put("$OS_VERSION", getProperty("os.version")); env.put("$JAVA_VERSION", PropertyTools.getJavaVersion()); env.put("$CWD", new File(".").getAbsolutePath()); env.put("$COMMAND_PASSTRU", "false"); System.out.println("No config file found. Loading default config."); if (!contains(getProperty("os.name").toLowerCase(), "windows")) { env.put("$PATH", "/bin:/usr/bin:/sbin:/usr/sbin");
if (member == null) { addWriteCache(curr.getClass(), tk.hashCode(), (member = value != null ? getFieldOrWriteAccessor(curr.getClass(), tk, value.getClass()) : getFieldOrWriteAccessor(curr.getClass(), tk)));
if (PropertyTools.contains(e.getMessage(), "wrong name")) {
public Object setValue(Object ctx, Object elCtx, VariableResolverFactory variableFactory, Object value) { // this local field is required to make sure exception block works with the same coercionRequired value // and it is not changed by another thread while setter is invoked boolean attemptedCoercion = coercionRequired; try { if (coercionRequired) { return method.invoke(ctx, convert(value, targetType)); } else { return method.invoke(ctx, value == null && primitive ? PropertyTools.getPrimitiveInitialValue(targetType) : value); } } catch (IllegalArgumentException e) { if (ctx != null && method.getDeclaringClass() != ctx.getClass()) { Method o = getBestCandidate(EMPTY, method.getName(), ctx.getClass(), ctx.getClass().getMethods(), true); if (o != null) { return executeOverrideTarget(o, ctx, value); } } if (!attemptedCoercion) { coercionRequired = true; return setValue(ctx, elCtx, variableFactory, value); } throw new RuntimeException("unable to bind property", e); } catch (Exception e) { throw new RuntimeException("error calling method: " + method.getDeclaringClass().getName() + "." + method.getName(), e); } }
public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) { return factory.isResolveable(nameCache) || (thisValue != null && getFieldOrAccessor(thisValue.getClass(), nameCache) != null); }
Member member = getFieldOrWriteAccessor(ctx.getClass(), tk, value == null ? null : ingressType); mv.visitVarInsn(ALOAD, 4); if (value == null) value = PropertyTools.getPrimitiveInitialValue(fld.getType()); if (targetType.isPrimitive()) { if (value == null) value = PropertyTools.getPrimitiveInitialValue(targetType);
public static Member getFieldOrWriteAccessor(Class clazz, String property) { Field field; try { if ((field = clazz.getField(property)) != null && isPublic(field.getModifiers())) { return field; } } catch (NullPointerException e) { return null; } catch (NoSuchFieldException e) { // do nothing. } return getSetter(clazz, property); }