Java Code Examples for org.apache.commons.beanutils.MethodUtils#invokeMethod()

The following examples show how to use org.apache.commons.beanutils.MethodUtils#invokeMethod() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExecutionPeriodsForExecutionYear.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Object provide(Object source, Object currentValue) {

    ExecutionYear executionYear;
    try {
        executionYear = (ExecutionYear) MethodUtils.invokeMethod(source, "getExecutionYear", null);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    List<ExecutionSemester> periods = new ArrayList<ExecutionSemester>();
    if (executionYear != null) {
        periods.addAll(executionYear.getExecutionPeriodsSet());
    }

    return periods;
}
 
Example 2
Source File: NavNodeTest.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
private void verifyStringSetterMethod(String methodname)
    throws Exception {
    Object[] args = { "value" };
    MethodUtils.invokeMethod(node, "set" + methodname, args);
    String rc = (String) MethodUtils.invokeMethod(node, "get" + methodname,
            null);
    assertEquals("value", rc);
}
 
Example 3
Source File: NavNodeTest.java    From uyuni with GNU General Public License v2.0 5 votes vote down vote up
private void verifyBooleanSetterMethod(String methodname)
    throws Exception {
    Object[] args = { Boolean.TRUE };
    MethodUtils.invokeMethod(node, "set" + methodname, args);
    Boolean rc = (Boolean) MethodUtils.invokeMethod(node, "get" +
            methodname, null);
    assertTrue(rc.booleanValue());
}
 
Example 4
Source File: SetRootRule.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Process the end of this element.
 */
@Override
public void end() throws Exception {

    // Identify the objects to be used
    Object child = digester.peek(0);
    Object parent = digester.root;
    if (digester.log.isDebugEnabled()) {
        if (parent == null) {
            digester.log.debug("[SetRootRule]{" + digester.match +
                    "} Call [NULL ROOT]." +
                    methodName + "(" + child + ")");
        } else {
            digester.log.debug("[SetRootRule]{" + digester.match +
                    "} Call " + parent.getClass().getName() + "." +
                    methodName + "(" + child + ")");
        }
    }

    // Call the specified method
    Class<?> paramTypes[] = new Class<?>[1];
    if (paramType != null) {
        paramTypes[0] =
                digester.getClassLoader().loadClass(paramType);
    } else {
        paramTypes[0] = child.getClass();
    }
    
    if (useExactMatch) {
    
        MethodUtils.invokeExactMethod(parent, methodName,
            new Object[]{ child }, paramTypes);
            
    } else {
    
        MethodUtils.invokeMethod(parent, methodName,
            new Object[]{ child }, paramTypes);
    
    }
}
 
Example 5
Source File: SetNextRule.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Process the end of this element.
 */
@Override
public void end() throws Exception {

    // Identify the objects to be used
    Object child = digester.peek(0);
    Object parent = digester.peek(1);
    if (digester.log.isDebugEnabled()) {
        if (parent == null) {
            digester.log.debug("[SetNextRule]{" + digester.match +
                    "} Call [NULL PARENT]." +
                    methodName + "(" + child + ")");
        } else {
            digester.log.debug("[SetNextRule]{" + digester.match +
                    "} Call " + parent.getClass().getName() + "." +
                    methodName + "(" + child + ")");
        }
    }

    // Call the specified method
    Class<?> paramTypes[] = new Class<?>[1];
    if (paramType != null) {
        paramTypes[0] =
                digester.getClassLoader().loadClass(paramType);
    } else {
        paramTypes[0] = child.getClass();
    }
    
    if (useExactMatch) {
    
        MethodUtils.invokeExactMethod(parent, methodName,
            new Object[]{ child }, paramTypes);
            
    } else {
    
        MethodUtils.invokeMethod(parent, methodName,
            new Object[]{ child }, paramTypes);
    
    }
}
 
Example 6
Source File: NavNodeTest.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
private void verifyStringSetterMethod(String methodname)
    throws Exception {
    Object[] args = { "value" };
    MethodUtils.invokeMethod(node, "set" + methodname, args);
    String rc = (String) MethodUtils.invokeMethod(node, "get" + methodname,
            null);
    assertEquals("value", rc);
}
 
Example 7
Source File: NavNodeTest.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
private void verifyBooleanSetterMethod(String methodname)
    throws Exception {
    Object[] args = { Boolean.TRUE };
    MethodUtils.invokeMethod(node, "set" + methodname, args);
    Boolean rc = (Boolean) MethodUtils.invokeMethod(node, "get" +
            methodname, null);
    assertTrue(rc.booleanValue());
}
 
Example 8
Source File: SetTopRule.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Process the end of this element.
 */
@Override
public void end() throws Exception {

    // Identify the objects to be used
    Object child = digester.peek(0);
    Object parent = digester.peek(1);
    
    if (digester.log.isDebugEnabled()) {
        if (child == null) {
            digester.log.debug("[SetTopRule]{" + digester.match +
                    "} Call [NULL CHILD]." +
                    methodName + "(" + parent + ")");
        } else {
            digester.log.debug("[SetTopRule]{" + digester.match +
                    "} Call " + child.getClass().getName() + "." +
                    methodName + "(" + parent + ")");
        }
    }

    // Call the specified method
    Class<?> paramTypes[] = new Class<?>[1];
    if (paramType != null) {
        paramTypes[0] =
                digester.getClassLoader().loadClass(paramType);
    } else {
        paramTypes[0] = parent.getClass();
    }

    if (useExactMatch) {
    
        MethodUtils.invokeExactMethod(child, methodName,
            new Object[]{ parent }, paramTypes);
            
    } else {
    
        MethodUtils.invokeMethod(child, methodName,
            new Object[]{ parent }, paramTypes);
    
    }
}