commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject cvs commit: jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt XMLIntrospector.java
Date Mon, 03 Jun 2002 18:37:56 GMT
jon         2002/06/03 11:37:56

  Modified:    betwixt/src/java/org/apache/commons/betwixt
                        XMLIntrospector.java
  Log:
  check for isTraceEnabled
  
  code clean
  
  removed unused imports
  
  -jon
  
  Revision  Changes    Path
  1.27      +39 -32    jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java
  
  Index: XMLIntrospector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- XMLIntrospector.java	1 Jun 2002 01:49:14 -0000	1.26
  +++ XMLIntrospector.java	3 Jun 2002 18:37:56 -0000	1.27
  @@ -1,8 +1,6 @@
  +package org.apache.commons.betwixt;
  +
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java,v
1.26 2002/06/01 01:49:14 jvanzyl Exp $
  - * $Revision: 1.26 $
  - * $Date: 2002/06/01 01:49:14 $
  - *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -56,26 +54,16 @@
    * individuals on behalf of the Apache Software Foundation.  For more
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  - * 
  - * $Id: XMLIntrospector.java,v 1.26 2002/06/01 01:49:14 jvanzyl Exp $
    */
  -package org.apache.commons.betwixt;
   
   import java.beans.BeanDescriptor;
   import java.beans.BeanInfo;
  -import java.beans.FeatureDescriptor;
   import java.beans.Introspector;
   import java.beans.IntrospectionException;
  -import java.beans.MethodDescriptor;
  -import java.beans.ParameterDescriptor;
   import java.beans.PropertyDescriptor;
   import java.lang.reflect.Method;
   import java.net.URL;
   import java.util.ArrayList;
  -import java.util.Collection;
  -import java.util.Date;
  -import java.util.Enumeration;
  -import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
   import java.util.HashMap;
  @@ -84,7 +72,6 @@
   import org.apache.commons.logging.Log;
   
   import org.apache.commons.betwixt.expression.EmptyExpression;
  -import org.apache.commons.betwixt.expression.Expression;
   import org.apache.commons.betwixt.expression.IteratorExpression;
   import org.apache.commons.betwixt.expression.MethodExpression;
   import org.apache.commons.betwixt.expression.MethodUpdater;
  @@ -96,7 +83,9 @@
   import org.apache.commons.betwixt.strategy.NameMapper;
   import org.apache.commons.betwixt.strategy.PluralStemmer;
   
  -/** <p><code>XMLIntrospector</code> an introspector of beans to create
a XMLBeanInfo instance.</p>
  +/** 
  +  * <p><code>XMLIntrospector</code> an introspector of beans to create
a 
  +  * XMLBeanInfo instance.</p>
     *
     * <p>By default, <code>XMLBeanInfo</code> caching is switched on.
     * This means that the first time that a request is made for a <code>XMLBeanInfo</code>
  @@ -104,7 +93,7 @@
     * Later requests for the same class will return the cached value.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.26 $
  +  * @version $Id: XMLIntrospector.java,v 1.27 2002/06/03 18:37:56 jon Exp $
     */
   public class XMLIntrospector {
   
  @@ -121,7 +110,7 @@
       boolean cachingEnabled = true;
       
       /** Maps classes to <code>XMLBeanInfo</code>'s */
  -    protected HashMap cacheXMLBeanInfos = new HashMap();
  +    protected Map cacheXMLBeanInfos = new HashMap();
       
       /** Digester used to parse the XML descriptor files */
       private XMLBeanInfoDigester digester;
  @@ -227,8 +216,10 @@
           elementDescriptor.setLocalName( getNameMapper().mapTypeToElementName( beanDescriptor.getName()
) );
           elementDescriptor.setPropertyType( beanInfo.getBeanDescriptor().getBeanClass()
);
           
  -        log.trace(elementDescriptor);
  -        
  +        if (log.isTraceEnabled()) {
  +            log.trace(elementDescriptor);
  +        }
  +
           // add default string value for primitive types
           if ( isPrimitiveType( beanClass ) ) {
               elementDescriptor.setTextExpression( StringExpression.getInstance() );
  @@ -251,8 +242,8 @@
   */
           }
           else {
  -            ArrayList elements = new ArrayList();
  -            ArrayList attributes = new ArrayList();
  +            List elements = new ArrayList();
  +            List attributes = new ArrayList();
   
               addProperties( beanInfo, elements, attributes );
   
  @@ -414,8 +405,10 @@
                   addProperty(beanInfo, descriptors[i], elements, attributes);
               }
           }
  -        log.trace(elements);
  -        log.trace(attributes);
  +        if (log.isTraceEnabled()) {
  +            log.trace(elements);
  +            log.trace(attributes);
  +        }
       }
       
       /** 
  @@ -436,7 +429,9 @@
           Method writeMethod = propertyDescriptor.getWriteMethod();
           
           if ( readMethod == null ) {
  -            log.trace( "No read method" );
  +            if (log.isTraceEnabled()) {
  +                log.trace( "No read method" );
  +            }
               return;
           }
           
  @@ -448,18 +443,26 @@
           
           // XXX: ignore class property ??
           if ( Class.class.equals( type ) && "class".equals( propertyDescriptor.getName()
) ) {
  -            log.trace( "Ignoring class property" );
  +            if (log.isTraceEnabled()) {
  +                log.trace( "Ignoring class property" );
  +            }
               return;
           }
           if ( isPrimitiveType( type ) ) {
  -            log.trace( "Primative type" );
  +            if (log.isTraceEnabled()) {
  +                log.trace( "Primative type" );
  +            }
               if ( isAttributesForPrimitives() ) {
  -                log.trace( "Added attribute" );
  +                if (log.isTraceEnabled()) {
  +                    log.trace( "Added attribute" );
  +                }
                   nodeDescriptor = new AttributeDescriptor();
                   attributes.add( nodeDescriptor );
               }
               else {
  -                log.trace( "Added element" );
  +                if (log.isTraceEnabled()) {
  +                    log.trace( "Added element" );
  +                }
                   nodeDescriptor = new ElementDescriptor(true);
                   elements.add( nodeDescriptor );
               }
  @@ -470,12 +473,14 @@
               }
           }
           else if ( isLoopType( type ) ) {
  -            log.trace("Loop type");
  +            if (log.isTraceEnabled()) {
  +                log.trace("Loop type");
  +            }
               ElementDescriptor loopDescriptor = new ElementDescriptor();
               loopDescriptor.setContextExpression(
                   new IteratorExpression( new MethodExpression( readMethod ) )
               );
  -            // XXX: need to support some kind of 'add' or handle arrays, Lists or indexed
properties
  +            // XXX: need to support some kind of 'add' or handle arrays, s or indexed properties
               //loopDescriptor.setUpdater( new MethodUpdater( writeMethod ) );
               if ( Map.class.isAssignableFrom( type ) ) {
                   loopDescriptor.setQualifiedName( "entry" );
  @@ -488,7 +493,9 @@
               elements.add( nodeDescriptor );
           }
           else {
  -            log.trace( "Standard property" );
  +            if (log.isTraceEnabled()) {
  +                log.trace( "Standard property" );
  +            }
               ElementDescriptor elementDescriptor = new ElementDescriptor();
               elementDescriptor.setContextExpression( new MethodExpression( readMethod )
);
               
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message