You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jo...@apache.org on 2002/06/03 18:53:07 UTC

cvs commit: jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester ElementRule.java

jon         2002/06/03 09:53:07

  Modified:    betwixt/src/java/org/apache/commons/betwixt/digester
                        ElementRule.java
  Log:
  line wrapping
  
  removed unused imports
  
  code cleanup
  
  -jon
  
  Revision  Changes    Path
  1.6       +27 -31    jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/ElementRule.java
  
  Index: ElementRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/ElementRule.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ElementRule.java	28 May 2002 23:01:07 -0000	1.5
  +++ ElementRule.java	3 Jun 2002 16:53:07 -0000	1.6
  @@ -1,8 +1,6 @@
  +package org.apache.commons.betwixt.digester;
  +
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/ElementRule.java,v 1.5 2002/05/28 23:01:07 jstrachan Exp $
  - * $Revision: 1.5 $
  - * $Date: 2002/05/28 23:01:07 $
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -57,28 +55,15 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: ElementRule.java,v 1.5 2002/05/28 23:01:07 jstrachan Exp $
    */
  -package org.apache.commons.betwixt.digester;
   
   import java.beans.BeanInfo;
  -import java.beans.IntrospectionException;
   import java.beans.Introspector;
   import java.beans.PropertyDescriptor;
  -import java.lang.reflect.Method;
   
  -import org.apache.commons.betwixt.AttributeDescriptor;
   import org.apache.commons.betwixt.ElementDescriptor;
   import org.apache.commons.betwixt.XMLBeanInfo;
  -import org.apache.commons.betwixt.XMLIntrospector;
   import org.apache.commons.betwixt.expression.ConstantExpression;
  -import org.apache.commons.betwixt.expression.Context;
  -import org.apache.commons.betwixt.expression.Updater;
  -import org.apache.commons.betwixt.expression.MethodExpression;
  -import org.apache.commons.betwixt.expression.MethodUpdater;
  -
  -import org.apache.commons.digester.Rule;
  -import org.apache.commons.digester.Digester;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -86,10 +71,12 @@
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   
  -/** <p><code>ElementRule</code> the digester Rule for parsing the &lt;element&gt; elements.</p>
  +/** 
  +  * <p><code>ElementRule</code> the digester Rule for parsing 
  +  * the &lt;element&gt; elements.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.5 $
  +  * @version $Id: ElementRule.java,v 1.6 2002/06/03 16:53:07 jon Exp $
     */
   public class ElementRule extends RuleSupport {
   
  @@ -127,7 +114,8 @@
           descriptor.setPropertyName( propertyName );
           
           descriptor.setPropertyType( 
  -            getPropertyType( attributes.getValue( "type" ), beanClass, propertyName ) 
  +            getPropertyType( attributes.getValue( "type" ), 
  +                beanClass, propertyName ) 
           );
           
           // set the property type using reflection
  @@ -154,8 +142,9 @@
               parent.addElementDescriptor( descriptor );
           }
           else {
  -            throw new SAXException( "Invalid use of <element>. It should be nested inside <info> or other <element> nodes" );
  -        }            
  +            throw new SAXException( "Invalid use of <element>. It should " + 
  +                "be nested inside <info> or other <element> nodes" );
  +        }
   
           digester.push(descriptor);        
       }
  @@ -171,8 +160,10 @@
       
       // Implementation methods
       //-------------------------------------------------------------------------    
  -    protected Class getPropertyType( String propertyClassName, Class beanClass, String propertyName ) {
  -        // XXX: should use a ClassLoader to handle complex class loading situations
  +    protected Class getPropertyType( String propertyClassName, 
  +                                     Class beanClass, String propertyName ) {
  +        // XXX: should use a ClassLoader to handle 
  +        //      complex class loading situations
           if ( propertyClassName != null ) {
               try {
                   Class answer = classLoader.loadClass(propertyClassName);
  @@ -183,7 +174,8 @@
               catch (Exception e) {
               }
           }
  -        PropertyDescriptor descriptor = getPropertyDescriptor( beanClass, propertyName );        
  +        PropertyDescriptor descriptor = 
  +            getPropertyDescriptor( beanClass, propertyName );        
           if ( descriptor != null ) { 
               return descriptor.getPropertyType();
           }
  @@ -195,9 +187,11 @@
           Class beanClass = getBeanClass();
           if ( beanClass != null ) {
               String name = elementDescriptor.getPropertyName();
  -            PropertyDescriptor descriptor = getPropertyDescriptor( beanClass, name );
  +            PropertyDescriptor descriptor = 
  +                getPropertyDescriptor( beanClass, name );
               if ( descriptor != null ) { 
  -                XMLIntrospectorHelper.configureProperty( elementDescriptor, descriptor );
  +                XMLIntrospectorHelper
  +                    .configureProperty( elementDescriptor, descriptor );
                   getProcessedPropertyNameSet().add( name );
               }
           }
  @@ -205,14 +199,16 @@
   
       /** 
        * Returns the property descriptor for the class and property name.
  -     * Note that some caching could be used to improve performance of this method.
  -     * Or this method could be added to PropertyUtils.
  +     * Note that some caching could be used to improve performance of 
  +     * this method. Or this method could be added to PropertyUtils.
        */
  -    protected PropertyDescriptor getPropertyDescriptor( Class beanClass, String propertyName ) {
  +    protected PropertyDescriptor getPropertyDescriptor( Class beanClass, 
  +                                                        String propertyName ) {
           if ( beanClass != null && propertyName != null ) {
               try {
                   BeanInfo beanInfo = Introspector.getBeanInfo( beanClass );
  -                PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
  +                PropertyDescriptor[] descriptors = 
  +                    beanInfo.getPropertyDescriptors();
                   if ( descriptors != null ) {
                       for ( int i = 0, size = descriptors.length; i < size; i++ ) {
                           PropertyDescriptor descriptor = descriptors[i];
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>