Package java.beans

Examples of java.beans.Expression


                        @SuppressWarnings("unchecked")
                        @Override
                        protected void initialize(Class type,
                                Object oldInstance, Object newInstance,
                                Encoder out) {
                            out.writeExpression(new Expression(object,
                                    oldInstance, "go", new Object[] {}));
                        }
                    });
            AType a = new AType();
View Full Code Here


   * Java 1.5 workaround. From http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5015403
   */
  public static class EnumDelegate extends DefaultPersistenceDelegate {
    @Override
    protected Expression instantiate(Object oldInstance, Encoder out) {
      return new Expression(Enum.class, "valueOf", new Object[] {oldInstance.getClass(),
          ((Enum<?>) oldInstance).name()});
    }
View Full Code Here

  public static class MapDelegate extends DefaultPersistenceDelegate {
    @Override
    protected Expression instantiate(Object oldInstance, Encoder out) {
      Map oldMap = (Map) oldInstance;
      HashMap newMap = new HashMap(oldMap);
      return new Expression(newMap, HashMap.class, "new", new Object[] {});
    }
View Full Code Here

  public static class SetDelegate extends DefaultPersistenceDelegate {
    @Override
    protected Expression instantiate(Object oldInstance, Encoder out) {
      Set oldSet = (Set) oldInstance;
      HashSet newSet = new HashSet(oldSet);
      return new Expression(newSet, HashSet.class, "new", new Object[] {});
    }
View Full Code Here

  public static class ListDelegate extends DefaultPersistenceDelegate {
    @Override
    protected Expression instantiate(Object oldInstance, Encoder out) {
      List oldList = (List) oldInstance;
      ArrayList newList = new ArrayList(oldList);
      return new Expression(newList, ArrayList.class, "new", new Object[] {});
    }
View Full Code Here

  }

  public static class CollectionPersistenceDelegate extends DefaultPersistenceDelegate {
    @Override
    protected Expression instantiate(Object oldInstance, Encoder out) {
      return new Expression(oldInstance, oldInstance.getClass(), "new", null);
    }
View Full Code Here

    /**
     * The test checks the correct constructor is initialized
     */
    public void testConstructor() throws Exception {
        Expression expr = new Expression(SampleBean.class, "new",
                new Object[] { "hello" });
        Object result = expr.getValue();
        if (result != null && result instanceof SampleBean) {
            SampleBean bean = (SampleBean) result;
            assertEquals("hello", bean.getText());
        } else {
            fail("Cannot instantiate an instance of Bean class.");
View Full Code Here

    /**
     * The test checks the correct static method is initialized
     */
    public void testStatic() throws Exception {
        SampleBean theBean = new SampleBean();
        Expression expr = new Expression(SampleBean.class, "create",
                new Object[] { "hello", theBean });

        Object result = expr.getValue();
        if (result != null && result instanceof SampleBean) {
            SampleBean bean = (SampleBean) result;
            assertEquals("hello", bean.getText());
            assertEquals(theBean, bean.getObject());
        } else {
View Full Code Here

    /**
     * The test checks the correct getter is initialized
     */
    public void testGetter() throws Exception {
        Expression expr = new Expression(new SampleBean("hello"), "getText",
                new Object[] {});

        Object result = expr.getValue();
        if (result != null && result instanceof String) {
            assertEquals("hello", result);
        } else {
            fail("Result of SampleBean.getText() call is not "
                    + "of String type.");
View Full Code Here

    /**
     * The test checks the correct array getter is initialized
     */
    public void testArrayGetter() throws Exception {
        int[] a = { 1, 2, 3 };
        Expression expr = new Expression(a, "get",
                new Object[] { new Integer(1) });

        Object result = expr.getValue();
        if (result != null && result instanceof Integer) {
            assertEquals(new Integer(2), result);
        } else {
            fail("Result of array getter is not of Integer type.");
        }
View Full Code Here

TOP

Related Classes of java.beans.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.