当前位置: 首页>>代码示例>>Java>>正文


Java Statement.execute方法代码示例

本文整理汇总了Java中java.beans.Statement.execute方法的典型用法代码示例。如果您正苦于以下问题:Java Statement.execute方法的具体用法?Java Statement.execute怎么用?Java Statement.execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.beans.Statement的用法示例。


在下文中一共展示了Statement.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setMethodValue

import java.beans.Statement; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <E> void setMethodValue(E obj, Method method, Object... args) {
	try {
		method.setAccessible(true);

		method.invoke(obj, args);

	} catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
		// e.printStackTrace();
		try {
			if (obj != null) {
				Statement stmt = new Statement(obj, method.getName(), args);
				stmt.execute();
			}

		} catch (Exception e1) {
			// e1.printStackTrace();
		}
	}
}
 
开发者ID:osonus,项目名称:oson,代码行数:21,代码来源:ObjectUtil.java

示例2: itemStateChanged

import java.beans.Statement; //导入方法依赖的package包/类
@Override
public void itemStateChanged(ItemEvent evt) {
    Statement statement = (evt.getStateChange() == ItemEvent.DESELECTED) ? falseStatement
            : trueStatement;

    try {
        statement.execute();
    } catch (Exception ex) {
        LOG.log(Level.FINE,
                "Couldn't execute boolean method via Statement "
                        + statement, ex);
    }
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:14,代码来源:BoundAction.java

示例3: itemStateChanged

import java.beans.Statement; //导入方法依赖的package包/类
public void itemStateChanged(ItemEvent evt) {
    Statement statement = (evt.getStateChange() == ItemEvent.DESELECTED) ? falseStatement
            : trueStatement;

    try {
        statement.execute();
    } catch (Exception ex) {
        LOG.log(Level.FINE,
                "Couldn't execute boolean method via Statement "
                        + statement, ex);
    }
}
 
开发者ID:sing-group,项目名称:aibench-project,代码行数:13,代码来源:BoundAction.java

示例4: testSetter

import java.beans.Statement; //导入方法依赖的package包/类
/**
 * The test checks the method execute() for setter
 */
public void testSetter() throws Exception {
    Bean bean = new Bean();
    Statement s = new Statement(bean, "setText", new Object[] { "hello" });
    s.execute();
    assertEquals("hello", bean.getText());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:10,代码来源:StatementTest.java

示例5: testExecute_ProtectedMethodWithPackage

import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_ProtectedMethodWithPackage() throws Exception {
    DefaultPersistenceDelegate dpd = new DefaultPersistenceDelegate();
    Object[] arguments = new Object[] { "test", "test" };
    Statement t = new Statement(dpd, "mutatesTo", arguments);
    try {
        t.execute();
        fail("Should throw NoSuchMethodException!");
    } catch (NoSuchMethodException e) {
        // expected
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:StatementTest.java

示例6: testArraySetter

import java.beans.Statement; //导入方法依赖的package包/类
/**
 * The test checks the method execute() for array setter
 */
public void testArraySetter() throws Exception {
    int[] a = { 1, 2, 3 };
    Statement s = new Statement(a, "set", new Object[] { new Integer(1),
            new Integer(7) });
    s.execute();
    assertEquals(7, a[1]);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:StatementTest.java

示例7: testStatic

import java.beans.Statement; //导入方法依赖的package包/类
/**
 * The test checks the method execute() for static method
 */
public void testStatic() throws Exception {
    int currentId = getTestId();
    Statement s = new Statement(StatementTest.class, "nextTestId",
            new Object[] {});
    s.execute();
    assertEquals(++currentId, getTestId());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:StatementTest.java

示例8: testExecute_ArrayInvalidName

import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_ArrayInvalidName() throws Exception {
    Object[] array = new Object[] { "test" };
    Statement t = new Statement(array, "gets", new Object[] {
            new Integer(0), new Object() });
    try {
        t.execute();
        fail("Should throw NoSuchMethodException!");
    } catch (NoSuchMethodException ex) {
        // expected
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:StatementTest.java

示例9: testExceptionThrownOnStaticMethodCall

import java.beans.Statement; //导入方法依赖的package包/类
/**
 * The test checks the method execute() if exception is thrown on static
 * method call
 */
public void testExceptionThrownOnStaticMethodCall() throws Exception {
    Statement s = new Statement(StatementTest.class, "methodWithException",
            new Object[] {});

    try {
        s.execute();
        fail("Exception must be thrown with methodWithException call");
    } catch (SampleException se) {
        // SampleException is thrown as expected
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:StatementTest.java

示例10: testExecute_ApplicableViaTypeConversion

import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_ApplicableViaTypeConversion() throws Exception {
    MockObject mo = new MockObject(false);
    // mo.methodB('c');
    Object[] arguments = new Object[] { new Character((char) 1) };
    Statement t = new Statement(mo, "methodB", arguments);
    try {
        t.execute();
        fail("Should throw NoSuchMethodException!");
    } catch (NoSuchMethodException e) {
        // expected
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:13,代码来源:StatementTest.java

示例11: testExecute_ExceptionalMethod

import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_ExceptionalMethod() throws Exception {
    MockObject mo = new MockObject(false);
    Statement t = new Statement(mo, "method", new Object[] { null, null });
    try {
        t.execute();
        fail("Should throw NullPointerException!");
    } catch (NullPointerException ex) {
        // expected
    }
    MockObject.assertCalled("method4", new Object[] { null, null });
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:StatementTest.java

示例12: testExecute_NonExistingMethod

import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_NonExistingMethod() throws Exception {
    MockObject mo = new MockObject(false);
    Statement t = new Statement(mo, "method_not_existing", new Object[] {
            null, null });
    try {
        t.execute();
        fail("Should throw NoSuchMethodException!");
    } catch (NoSuchMethodException ex) {
        // expected
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:StatementTest.java

示例13: testExecute_NullTarget

import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_NullTarget() throws Exception {
    Statement t = new Statement(null, "method_not_existing", new Object[] {
            null, null });
    try {
        t.execute();
        fail("Should throw NullPointerException!");
    } catch (NullPointerException ex) {
        // expected
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:StatementTest.java

示例14: testExecute_InvalidArguments

import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_InvalidArguments() throws Exception {
    MockObject mo = new MockObject(false);
    Statement t = new Statement(mo, "method", new Object[] { new Object(),
            new Object(), new Object() });
    try {
        t.execute();
        fail("Should throw NoSuchMethodException!");
    } catch (NoSuchMethodException ex) {
        // expected
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:StatementTest.java

示例15: testExecute_NormalConstructorNull

import java.beans.Statement; //导入方法依赖的package包/类
public void testExecute_NormalConstructorNull() throws Exception {
    Object[] arguments = new Object[] { null, null };
    Statement t = new Statement(MockObject.class, "new", arguments);

    try {
        t.execute();
        fail("Should throw NullPointerException!");
    } catch (NullPointerException ex) {
        // expected
    }
    MockObject.assertCalled("new4", arguments);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:13,代码来源:StatementTest.java


注:本文中的java.beans.Statement.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。