public int addAccessibleMethod(Method method) { if (accessibleMethods == null) { accessibleMethods = new ArrayList<Method>(); } int index = accessibleMethods.size(); accessibleMethods.add(method); return index; }
public int addAccessibleField(Field field) { if (accessibleFields == null) { accessibleFields = new ArrayList<Field>(); } int index = accessibleFields.size(); accessibleFields.add(field); return index; }
public Object invokeAccessibleMethod(Object target, Object[] args, int methodIndex) { try { Method method = accessibleMethods.get(methodIndex); return method.invoke(target, args); } catch (Exception e) { throw new ExecuteException( "Rule.invokeAccessibleMethod : unexpected error invoking non-public method in rule " + getName(), e); } }
public Object getAccessibleField(Object owner, int fieldIndex) throws ExecuteException { try { Field field = accessibleFields.get(fieldIndex); return field.get(owner); } catch (Exception e) { throw new ExecuteException( "Rule.getAccessibleField : unexpected error getting non-public field in rule " + getName(), e); } }
public void setAccessibleField(Object owner, Object value, int fieldIndex) throws ExecuteException { try { Field field = accessibleFields.get(fieldIndex); field.set(owner, value); } catch (Exception e) { throw new ExecuteException( "Rule.setAccessibleField : unexpected error setting non-public field in rule " + getName(), e); } }