Examples of DynaBean


Examples of org.apache.commons.beanutils.DynaBean

        assertEquals(getAdjustedModel(),
                     readModelFromDatabase("roundtriptest"));

        List     beans = getRows("roundtrip2");
        DynaBean bean  = (DynaBean)beans.get(0);

        // Some databases (e.g. DB2) pad the string for some reason, so we manually trim it
        if (bean.get("fk") instanceof String)
        {
            bean.set("fk", ((String)bean.get("fk")).trim());
        }
        assertEquals((Object)"1", bean, "fk");
    }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

        assertEquals(getAdjustedModel(),
                     readModelFromDatabase("roundtriptest"));

        List     beans = getRows("roundtrip2");
        DynaBean bean  = (DynaBean)beans.get(0);

        // Some databases (e.g. DB2) pad the string for some reason, so we manually trim it
        if (bean.get("fk") instanceof String)
        {
            bean.set("fk", ((String)bean.get("fk")).trim());
        }
        assertEquals((Object)"1", bean, "fk");
    }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

     * @param columnValues The values for the columns in order of definition
     */
    protected void insertRow(String tableName, Object[] columnValues)
    {
        Table    table = getModel().findTable(tableName);
        DynaBean bean  = getModel().createDynaBeanFor(table);

        for (int idx = 0; (idx < table.getColumnCount()) && (idx < columnValues.length); idx++)
        {
            Column column = table.getColumn(idx);

            bean.set(column.getName(), columnValues[idx]);
        }
        getPlatform().insert(getModel(), bean);
    }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

     * @param bean     The bean
     * @param attrName The attribute name
     */
    protected void assertEquals(Object expected, Object bean, String attrName)
    {
        DynaBean dynaBean = (DynaBean)bean;
        Object   value    = dynaBean.get(attrName);

        if ((value instanceof byte[]) && !(expected instanceof byte[]) && (dynaBean instanceof SqlDynaBean))
        {
            SqlDynaClass dynaClass = (SqlDynaClass)((SqlDynaBean)dynaBean).getDynaClass();
            Column       column    = ((SqlDynaProperty)dynaClass.getDynaProperty(attrName)).getColumn();
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

    if ((! (o1 instanceof DynaBean)) || (! (o2 instanceof DynaBean)))
    {
      throw new IllegalArgumentException("Objects are not dynabeans");
    }

    DynaBean db1 = (DynaBean) o1;
    DynaBean db2 = (DynaBean) o2;
    Object oneVal = db1.get(valueName);
    Object twoVal = db2.get(valueName);

    if ((oneVal == null) && (twoVal == null))
    {
      returnValue = 0;
    }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

        }

        DynaClass bdattr = new BasicDynaClass(re.getName() + "_attributes", Class
                .forName("de.iritgo.aktera.clients.MapExposingBasicDynaBean"), dattr);

        DynaBean oneAttrBean = bdattr.newInstance();

        for (Iterator io = attributes.keySet().iterator(); io.hasNext();)
        {
          oneAttribName = (String) io.next();
          oneAttribValue = attributes.get(oneAttribName);

          if (oneAttribValue instanceof ResponseElement)
          {
            oneAttrBean.set(oneAttribName, new ResponseElementDynaBean((ResponseElement) oneAttribValue));
          }
          else
          {
            oneAttrBean.set(oneAttribName, oneAttribValue);
          }
        }

        set("attributes", oneAttrBean);
      }
      else
      {
        DynaClass bdattr = new BasicDynaClass(re.getName() + "_attributes", Class
                .forName("de.iritgo.aktera.clients.MapExposingBasicDynaBean"), new DynaProperty[0]);
        BasicDynaBean oneAttrBean = (BasicDynaBean) bdattr.newInstance();

        set("attributes", oneAttrBean);
      }

      if (re instanceof Input)
      {
        set("type", "input");

        Input i = (Input) re;

        set("defaultValue", i.getDefaultValue());

        Map valids = i.getValidValues();

        if (valids.size() > 0)
        {
          BeanComparator bc = new BeanComparator("value");
          TreeSet options = new TreeSet(bc);
          DynaProperty[] dpopts = new DynaProperty[2];

          dpopts[0] = new DynaProperty("value", Class.forName("java.lang.String"));
          dpopts[1] = new DynaProperty("label", Class.forName("java.lang.String"));

          DynaClass bdopt = new BasicDynaClass("validValues", Class
                  .forName("de.iritgo.aktera.clients.MapExposingBasicDynaBean"), dpopts);
          Object oneOpt = null;
          Object oneLabelObj = null;

          for (Iterator io = valids.keySet().iterator(); io.hasNext();)
          {
            oneOpt = io.next();

            DynaBean oneOptBean = bdopt.newInstance();

            oneOptBean.set("value", oneOpt.toString());
            oneLabelObj = valids.get(oneOpt.toString());

            if (oneLabelObj == null)
            {
              oneLabelObj = "(No Label)";
            }

            oneOptBean.set("label", oneLabelObj.toString());
            options.add(oneOptBean);
          }

          set("validValues", options);
        }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

        int rowIndex = 0;
        for (Iterator rows = rsdc.iterator(); rows.hasNext() && rowIndex < numberPerPage; rowIndex++)
        {
            try
            {
                DynaBean oldRow = (DynaBean) rows.next();
                DynaBean newRow = bdc.newInstance();

                DynaProperty[] properties = oldRow.getDynaClass().getDynaProperties();
                for (int i = 0, length = properties.length; i < length; i++)
                {
                    String propertyName = properties[i].getName();
                    Object value = oldRow.get(propertyName);
                    newRow.set(propertyName, value);
                }

                list.add(newRow);
            }
            catch (Exception e)
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

        super(testName);
    }

    public void testDynaBeans() throws Exception {
        DynaClass dynaClass = createDynaClass();
        DynaBean dynaBean = dynaClass.newInstance();
        dynaBean.set( "stringProperty", "foo" );
        dynaBean.set( "intProperty", new Integer(24) );
               
        context.setVariable("dbean", dynaBean);

        assertExpression("${dbean.stringProperty}", "foo");
        assertExpression("${dbean.intProperty}", new Integer(24));
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

        assertTrue("isRaptor descriptor not found", matchedIsRaptor);
        assertTrue("Period descriptor not found", matchedPeriod);
    }
   
    public void testWriteDynaBean() throws Exception {
        DynaBean dynasaur = createDynasaurClass().newInstance();
        dynasaur.set("Species", "Allosaurus");
        dynasaur.set("isRaptor", Boolean.TRUE);
        dynasaur.set("Period", "Jurassic");
       
        StringWriter out = new StringWriter();
        out.write("<?xml version='1.0'?>");
        BeanWriter writer = new BeanWriter(out);
    writer.getBindingConfiguration().setMapIDs(false);
View Full Code Here

Examples of org.apache.commons.beanutils.DynaBean

public class DynaBeanPropertyAccessor implements PropertyAccessor {

    public Object getProperty(Map context, Object target, Object name) throws OgnlException {
       
        if (target instanceof DynaBean && name != null) {
            DynaBean bean = (DynaBean)target;
            DynaClass cls = bean.getDynaClass();
            String key = name.toString();
            if (cls.getDynaProperty(key) != null) {
                return bean.get(key);
            }
        }
        return null;
    }   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.