Package org.apache.commons.beanutils

Examples of org.apache.commons.beanutils.BasicDynaClass


    public void testSimpleIntrospectionTest() throws Exception {
        DynaProperty[] dynaProperties = {
                new DynaProperty("one", Integer.class),
                new DynaProperty("two", String.class)};
        BasicDynaClass dynaClass = new BasicDynaClass("WibbleDynaBean", BasicDynaBean.class,
                dynaProperties);
        DynaBean dynaBean = dynaClass.newInstance();
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(dynaBean);
       
        ElementDescriptor dynaBeanDescriptor = xmlBeanInfo.getElementDescriptor();
        ElementDescriptor[] dynaPropertyDescriptors = dynaBeanDescriptor.getElementDescriptors();
View Full Code Here


                            true);
       
    }
   
    private DynaClass createDynasaurClass() throws Exception {
        DynaClass dynaClass = new BasicDynaClass
                ("Dynasaur", null,
                        new DynaProperty[]{
                            new DynaProperty("Species", String.class),
                            new DynaProperty("isRaptor", Boolean.TYPE),
                            new DynaProperty("Period", String.class),
View Full Code Here

            for (Iterator it = _columnsToProperties.values().iterator(); it.hasNext(); idx++)
            {
                props[idx] = new DynaProperty((String)it.next());
            }
            _dynaClass = new BasicDynaClass("result", BasicDynaBean.class, props);
        }
    }
View Full Code Here

      }

      dps[inputCount++] = dp;
    }

    BasicDynaClass bd;

    try
    {
      bd = new BasicDynaClass(modelName, Class.forName("org.apache.commons.beanutils.BasicDynaBean"), dps);

      BasicDynaBean newForm = (BasicDynaBean) bd.newInstance();

      // Now populate the newForm's properties
      for (Iterator i2 = inputs.iterator(); i2.hasNext();)
      {
        oneInput = (ResponseElementDynaBean) i2.next();
View Full Code Here

      }

      dps[inputCount++] = dp;
    }

    BasicDynaClass bd;

    try
    {
      bd = new BasicDynaClass(beanName, Class.forName("org.apache.commons.beanutils.BasicDynaBean"), dps);

      BasicDynaBean newForm = (BasicDynaBean) bd.newInstance();

      for (Iterator i2 = inputs.iterator(); i2.hasNext();)
      {
        oneInput = (ResponseElementDynaBean) i2.next();
        newForm.set((String) oneInput.get("name"), oneInput.get("defaultValue"));
View Full Code Here

        DynaProperty fieldProp = new DynaProperty(oneFieldName, Class.forName(typeClass));

        props[propCount++] = fieldProp;
      }

      return new BasicDynaClass(pe.getName(), Class
              .forName("de.iritgo.aktera.persist.defaultpersist.PersistentDynaBean"), props);
    }
    catch (Exception e)
    {
      System.err.println("Unable to get instance of dynaclass");
View Full Code Here

        DynaProperty paramsProp = new DynaProperty("parameters", params.getClass());

        props[propCount++] = paramsProp;
      }

      return new BasicDynaClass(re.getName(), Class.forName("de.iritgo.aktera.clients.ResponseElementDynaBean"),
              props);
    }
    catch (Exception e)
    {
      System.err.println("ResponseElementDynaClassFactory: Unable to get instance of dynaclass:");
View Full Code Here

              dattr[j++] = new DynaProperty(oneAttribName, oneAttribValue.getClass());
            }
          }
        }

        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)
View Full Code Here

    public List processResultSet(String name, ResultSet result, int numberPerPage, ValueListInfo info) throws SQLException {
        List list = new ArrayList();

        ResultSetDynaClass rsdc = new CFResultSetDynaClass(result, false, isUseName());
        BasicDynaClass bdc = new BasicDynaClass(name, BasicDynaBean.class, rsdc.getDynaProperties());

        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();
View Full Code Here

      new DynaProperty("mappedIntProperty", Map.class),
      new DynaProperty("nullProperty", String.class),
      new DynaProperty("shortProperty", Short.TYPE),
      new DynaProperty("stringProperty", String.class),
    };
        return new BasicDynaClass("TestDynaClass", null, properties);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.beanutils.BasicDynaClass

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.