Examples of DynaClass


Examples of org.apache.commons.beanutils.DynaClass

                new ArrayList<DynaClass>(beans.size());

        for (Object bean : beans)
        {
            DynaBean dynaBean = createDynaBean(bean);
            DynaClass beanClass = dynaBean.getDynaClass();
            for (DynaProperty prop : beanClass.getDynaProperties())
            {
                // ensure an order of properties
                if (!propsToBeans.containsKey(prop.getName()))
                {
                    propsToBeans.put(prop.getName(), dynaBean);
View Full Code Here

Examples of org.apache.commons.beanutils.DynaClass

     * Tests whether the class of bean can be queried.
     */
    @Test
    public void testGetDynaClass()
    {
        DynaClass cls = createBean(false).getDynaClass();
        assertNotNull("Property not found (1)",
                cls.getDynaProperty("throwExceptionOnMissing"));
        assertNotNull("Property not found (2)", cls.getDynaProperty("text"));
    }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaClass

    }

    public String[] getPropertyNames() {
        /* @todo do something about the sorting - LIKE WHAT? - MJB */
        if (names == null) {
            DynaClass dynaClass = dynaBean.getDynaClass();
            DynaProperty[] properties = dynaClass.getDynaProperties();
            int count = properties.length;
            boolean hasClass = dynaClass.getDynaProperty("class") != null;
            if (hasClass) {
                count--;       // Exclude "class" from properties
            }
            names = new String[count];
            for (int i = 0, j = 0; i < properties.length; i++) {
View Full Code Here

Examples of org.apache.commons.beanutils.DynaClass

    /**
     * Returns true if the bean has the currently selected property.
     * @return boolean
     */
    protected boolean isActualProperty() {
        DynaClass dynaClass = dynaBean.getDynaClass();
        return dynaClass.getDynaProperty(getPropertyName()) != null;
    }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaClass

    /**
     * Learn whether the property referenced is an indexed property.
     * @return boolean
     */
    protected boolean isIndexedProperty() {
        DynaClass dynaClass = dynaBean.getDynaClass();
        DynaProperty property = dynaClass.getDynaProperty(name);
        return property.isIndexed();
    }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaClass

     * @param value to convert
     * @param element whether this should be a collection element.
     * @return conversion result
     */
    private Object convert(Object value, boolean element) {
        DynaClass dynaClass = (DynaClass) dynaBean.getDynaClass();
        DynaProperty property = dynaClass.getDynaProperty(getPropertyName());
        Class type = property.getType();
        if (element) {
            if (type.isArray()) {
                type = type.getComponentType();
            }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaClass

    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

Examples of org.apache.commons.beanutils.DynaClass

     * @param dynaBean The bean
     * @return The dyna bean class
     */
    public SqlDynaClass getDynaClass(DynaBean dynaBean) throws SqlDynaException
    {
        DynaClass dynaClass = dynaBean.getDynaClass();

        if (dynaClass instanceof SqlDynaClass)
        {
            return (SqlDynaClass)dynaClass;
        }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaClass

     * {@inheritDoc}
     */
    public String toString()
    {
        StringBuffer   result = new StringBuffer();
        DynaClass      type   = getDynaClass();
        DynaProperty[] props  = type.getDynaProperties();

        result.append(type.getName());
        result.append(": ");
        for (int idx = 0; idx < props.length; idx++)
        {
            if (idx > 0)
            {
View Full Code Here

Examples of org.apache.commons.beanutils.DynaClass

          // //By default 4 Megs allowed - already set.
          // }
          log.debug("Starting request parse...");

          DynaActionForm df = (DynaActionForm) form;
          DynaClass dc = df.getDynaClass();

          if (dc == null)
          {
            throw new ClientException("Null dynaclass from the DynaActionForm - can't read properties");
          }

          DynaProperty[] props = dc.getDynaProperties();
          DynaProperty oneProp = null;

          if (log.isDebugEnabled())
          {
            // They are not available in Struts Dynaform objects.
            for (final Enumeration enumeration = this.hreq.getParameterNames(); enumeration
                    .hasMoreElements();)
            {
              // get parameter name
              // Get paramater values...
              // See if present in form.
              final String name = (String) enumeration.nextElement();

              try
              {
                for (int idx = 0;; idx++)
                {
                  final Object value = df.get(name, idx);

                  log.debug("Array Access Parameter/Value/Index: " + name + '/' + value + '/' + idx);
                }
              }
              catch (Exception e)
              {
                log.debug("Exception: " + e);
                log.debug("No more values for: " + name);
              }
            }

            for (final Enumeration enumeration = hreq.getParameterNames(); enumeration.hasMoreElements();)
            {
              final String name = (String) enumeration.nextElement();
              final String[] values = hreq.getParameterValues(name);

              log.debug("Servlet Parameter name: " + name);
              log.debug("Number of values: " + values.length);

              for (int idx = 0; idx < values.length; idx++)
              {
                log.debug("Idx/Value: " + idx + '/' + values[idx]);
              }
            }

            log.debug("# of properties: " + props.length);
          }

          for (int i = 0; i < props.length; i++)
          {
            oneProp = props[i];

            String oneName = oneProp.getName();
            final Object value = df.get(oneName);

            log.debug("Getting parameter/value/type:" + oneName + '/' + value + '/'
                    + (value == null ? "null" : value.getClass().getName()));

            // TODO: Handle mapped and indexed properties here
            // getName(), getType, isIndexed(), isMapped()
            if (df.get(oneName) != null && df.get(oneName) instanceof FormFile)
            {
              log.debug("Formfile");

              FormFile fileInfo = (FormFile) df.get(oneName);

              if (fileInfo != null && fileInfo.getFileSize() > 0)
              {
                BufferedInputStream inStream = null;

                try
                {
                  inStream = new BufferedInputStream(fileInfo.getInputStream(), BUFFER_SIZE);
                }
                catch (IOException e)
                {
                  throw new ClientException(e.getMessage(), e);
                }

                // Problem - DefaultFileItem is not comprised
                // completely of serializable components.
                // final FileItem fileItem =
                // DFIF.createItem(oneName,
                // fileInfo.getContentType(), false,
                // fileInfo.getFileName());
                // So we use BinaryWrapper instead, which is
                // completely serializable
                // TODO: Reset First parameter with Context Name
                // so that this will work over distributed
                // environments(I could not find the call to get
                // it - SPD)
                final BinaryWrapper fileWrapper = new BinaryWrapper(null, hreq.getContentType(),
                        fileInfo.getFileName(), BUFFER_SIZE, null);

                try
                {
                  final long written = fileWrapper.writeFrom(inStream);

                  if (this.log.isDebugEnabled())
                  {
                    log.debug("Read/Wrote " + written + "bytes.");
                  }
                }
                catch (IOException e)
                {
                  throw new ClientException(e.getMessage(), e);
                }
                finally
                {
                  if (inStream != null)
                  {
                    try
                    {
                      inStream.close();
                    }

                    // Done Anyways, so just print for log
                    // (hopefully) and carry on.
                    catch (IOException e)
                    {
                      e.printStackTrace();
                    }
                  } // end if(inStream

                  try
                  {
                    fileWrapper.close();
                  }

                  // Done Anyways, so just print for log
                  // (hopefully) and carry on.
                  catch (IOException e)
                  {
                    e.printStackTrace();
                  }
                } // end finally

                if (log.isDebugEnabled())
                {
                  log.debug("Setting FormFile parameter/value:" + oneName + '/'
                          + fileWrapper.getName());
                }

                kreq.setParameter(oneName, fileWrapper);
              } // end if (fileInfo!= null..
            } // end if(df.get(oneName)!=null
            else if (df.get(oneName) != null && df.get(oneName) instanceof java.io.Serializable)
            {
              if (log.isDebugEnabled())
              {
                log.debug("Setting FormField parameter/value:" + oneName + '/' + df.get(oneName));
              }

              // TODO: Fix this.
              // BUG # 880906 Need to get value(s) directly from
              // request.
              final String[] values = hreq.getParameterValues(oneName);

              if (values.length < 1)
              {
                log.debug("No values, so setting value=null");
                kreq.setParameter(oneName, null);
              }
              else if (values.length == 1)
              {
                log.debug("One value, saving as string");
                kreq.setParameter(oneName, values[1]);
              }
              else
              {
                // More than one value in this list, so send the
                // entire array
                log.debug("Many values, saving as array");
                kreq.setParameter(oneName, values);
              }
            } // end else if(df.get(oneName)!=null...instanceof
            // Serializable

            log.debug("Name/Value written to request: " + oneName);
          } // end for
        }
        else
        {
          // isMultipart == false - Just a regular dynaform
          log.debug("Standard Dyna Form...");

          // Populate the model parameters from the form
          DynaActionForm df = (DynaActionForm) form;
          DynaClass dc = df.getDynaClass();

          if (dc == null)
          {
            throw new ClientException("Null dynaclass from the DynaActionForm - can't read properties");
          }

          DynaProperty[] props = dc.getDynaProperties();
          DynaProperty oneProp = null;

          for (int i = 0; i < props.length; i++)
          {
            oneProp = props[i];
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.