dion        2004/09/07 21:48:32

  Modified:    jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define
                        BeanTag.java DynaBeanTag.java
               jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define
                        TestDynamicTags.java
  Log:
  detab
  
  Revision  Changes    Path
  1.5       +59 -59    
jakarta-commons/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/BeanTag.java
  
  Index: BeanTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/BeanTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BeanTag.java      25 Feb 2004 01:31:52 -0000      1.4
  +++ BeanTag.java      8 Sep 2004 04:48:32 -0000       1.5
  @@ -1,12 +1,12 @@
   /*
    * Copyright 2002,2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -33,10 +33,10 @@
   
   import org.xml.sax.Attributes;
   
  -/** 
  +/**
    * Binds a Java bean to the given named Jelly tag so that the attributes of
    * the tag set the bean properties..
  - * 
  + *
    * @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
    * @version $Revision$
    */
  @@ -50,21 +50,21 @@
   
       /** the name of the tag to create */
       private String name;
  -    
  +
       /** the Java class name to use for the tag */
       private String className;
   
       /** the ClassLoader used to load beans */
       private ClassLoader classLoader;
  -    
  +
       /** the name of the attribute used for the variable name */
       private String varAttribute = "var";
   
       /** the attribute definitions for this dynamic tag */
       private Map attributes;
  -    
  +
       /**
  -     * Adds a new attribute definition to this dynamic tag 
  +     * Adds a new attribute definition to this dynamic tag
        */
       public void addAttribute(Attribute attribute) {
           if ( attributes == null ) {
  @@ -72,79 +72,79 @@
           }
           attributes.put( attribute.getName(), attribute );
       }
  -    
  +
       // Tag interface
  -    //-------------------------------------------------------------------------     
               
  +    //-------------------------------------------------------------------------
       public void doTag(XMLOutput output) throws MissingAttributeException, 
JellyTagException {
           invokeBody(output);
  -        
  -             if (name == null) {
  -                     throw new MissingAttributeException("name");
  -             }
  -             if (className == null) {
  -                     throw new MissingAttributeException("className");
  -             }
  -        
  -             Class theClass = null;
  -             try {
  -                     ClassLoader classLoader = getClassLoader();
  -                     theClass = classLoader.loadClass(className);
  -             } 
  -             catch (ClassNotFoundException e) {
  -                     try {
  -                             theClass = 
getClass().getClassLoader().loadClass(className);
  -                     } 
  +
  +        if (name == null) {
  +            throw new MissingAttributeException("name");
  +        }
  +        if (className == null) {
  +            throw new MissingAttributeException("className");
  +        }
  +
  +        Class theClass = null;
  +        try {
  +            ClassLoader classLoader = getClassLoader();
  +            theClass = classLoader.loadClass(className);
  +        }
  +        catch (ClassNotFoundException e) {
  +            try {
  +                theClass = getClass().getClassLoader().loadClass(className);
  +            }
               catch (ClassNotFoundException e2) {
  -                             try {
  -                                     theClass = Class.forName(className);
  -                             } 
  +                try {
  +                    theClass = Class.forName(className);
  +                }
                   catch (ClassNotFoundException e3) {
                       log.error( "Could not load class: " + className + " exception: 
" + e, e );
  -                                     throw new JellyTagException(
  -                                             "Could not find class: "
  -                                                     + className
  -                                                     + " using ClassLoader: "
  -                                                     + classLoader);
  -                             }
  -                     }
  -             }
  -        
  +                    throw new JellyTagException(
  +                        "Could not find class: "
  +                            + className
  +                            + " using ClassLoader: "
  +                            + classLoader);
  +                }
  +            }
  +        }
  +
           final Class beanClass = theClass;
           final Method invokeMethod = getInvokeMethod( theClass );
           final Map beanAttributes = (attributes != null) ? attributes : EMPTY_MAP;
  -        
  +
           TagFactory factory = new TagFactory() {
               public Tag createTag(String name, Attributes attributes) {
                   return  new DynamicBeanTag(beanClass, beanAttributes, varAttribute, 
invokeMethod);
               }
           };
  -        
  +
           getTagLibrary().registerBeanTag(name, factory);
  -        
  +
           // now lets clear the attributes for next invocation and help the GC
           attributes = null;
  -     }
  +    }
  +
   
  -    
       // Properties
  -    //-------------------------------------------------------------------------     
               
  -    
  -    /** 
  +    //-------------------------------------------------------------------------
  +
  +    /**
        * Sets the name of the tag to create
        */
       public void setName(String name) {
           this.name = name;
       }
  -    
  -    /** 
  +
  +    /**
        * Sets the Java class name to use for the tag
        */
       public void setClassName(String className) {
           this.className = className;
       }
  -    
  +
       /**
  -     * Sets the ClassLoader to use to load the class. 
  +     * Sets the ClassLoader to use to load the class.
        * If no value is set then the current threads context class
        * loader is used.
        */
  @@ -155,7 +155,7 @@
       /**
        * @return the ClassLoader to use to load classes
        *  or will use the thread context loader if none is specified.
  -     */    
  +     */
       public ClassLoader getClassLoader() {
           if ( classLoader == null ) {
               ClassLoader answer = Thread.currentThread().getContextClassLoader();
  @@ -172,14 +172,14 @@
        * tag will output its results as. This defaults to 'var' though this property
        * can be used to change this if it conflicts with a bean property called 'var'.
        */
  -    public void setVarAttribute(String varAttribute) {    
  +    public void setVarAttribute(String varAttribute) {
           this.varAttribute = varAttribute;
       }
  -        
  -    
  +
  +
       // Implementation methods
  -    //-------------------------------------------------------------------------     
               
  -    
  +    //-------------------------------------------------------------------------
  +
       /**
        * Extracts the invoke method for the class if one is used.
        */
  
  
  
  1.5       +29 -29    
jakarta-commons/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DynaBeanTag.java
  
  Index: DynaBeanTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DynaBeanTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DynaBeanTag.java  25 Feb 2004 01:31:52 -0000      1.4
  +++ DynaBeanTag.java  8 Sep 2004 04:48:32 -0000       1.5
  @@ -1,12 +1,12 @@
   /*
    * Copyright 2002,2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -31,10 +31,10 @@
   import org.apache.commons.logging.LogFactory;
   import org.xml.sax.Attributes;
   
  -/** 
  +/**
    * Binds a Java bean to the given named Jelly tag so that the attributes of
    * the tag set the bean properties..
  - * 
  + *
    * @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
    * @version $Revision$
    */
  @@ -48,7 +48,7 @@
   
       /** the name of the tag to create */
       private String name;
  -    
  +
       /** the DyanClass to bind to the tag */
       private DynaClass dynaClass;
   
  @@ -57,9 +57,9 @@
   
       /** the attribute definitions for this dynamic tag */
       private Map attributes;
  -    
  +
       /**
  -     * Adds a new attribute definition to this dynamic tag 
  +     * Adds a new attribute definition to this dynamic tag
        */
       public void addAttribute(Attribute attribute) {
           if ( attributes == null ) {
  @@ -67,53 +67,53 @@
           }
           attributes.put( attribute.getName(), attribute );
       }
  -    
  +
       // Tag interface
  -    //-------------------------------------------------------------------------     
               
  +    //-------------------------------------------------------------------------
       public void doTag(XMLOutput output) throws MissingAttributeException, 
JellyTagException {
           invokeBody(output);
  -        
  -             if (name == null) {
  -                     throw new MissingAttributeException("name");
  -             }
  -             if (dynaClass == null) {
  -                     throw new MissingAttributeException("dynaClass");
  -             }
  -        
  +
  +        if (name == null) {
  +            throw new MissingAttributeException("name");
  +        }
  +        if (dynaClass == null) {
  +            throw new MissingAttributeException("dynaClass");
  +        }
  +
           final DynaClass theDynaClass = dynaClass;
           final Map beanAttributes = (attributes != null) ? attributes : EMPTY_MAP;
  -        
  +
           TagFactory factory = new TagFactory() {
               public Tag createTag(String name, Attributes attributes) {
                   return  new DynamicDynaBeanTag(theDynaClass, beanAttributes, 
varAttribute);
               }
           };
           getTagLibrary().registerBeanTag(name, factory);
  -        
  +
           // now lets clear the attributes for next invocation and help the GC
           attributes = null;
  -     }
  +    }
  +
   
  -    
       // Properties
  -    //-------------------------------------------------------------------------     
               
  -    
  -    /** 
  +    //-------------------------------------------------------------------------
  +
  +    /**
        * Sets the name of the tag to create
        */
       public void setName(String name) {
           this.name = name;
       }
  -    
  +
       /**
        * Sets the name of the attribute used to define the bean variable that this 
dynamic
        * tag will output its results as. This defaults to 'var' though this property
        * can be used to change this if it conflicts with a bean property called 'var'.
        */
  -    public void setVarAttribute(String varAttribute) {    
  +    public void setVarAttribute(String varAttribute) {
           this.varAttribute = varAttribute;
       }
  -        
  +
       /**
        * Returns the dynaClass.
        * @return DynaClass
  
  
  
  1.4       +13 -13    
jakarta-commons/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/TestDynamicTags.java
  
  Index: TestDynamicTags.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/TestDynamicTags.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestDynamicTags.java      25 Feb 2004 01:31:59 -0000      1.3
  +++ TestDynamicTags.java      8 Sep 2004 04:48:32 -0000       1.4
  @@ -1,12 +1,12 @@
   /*
    * Copyright 2002,2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -54,27 +54,27 @@
       }
   
       public void testParse() throws Exception {
  -        StringWriter buffer = new StringWriter();        
  +        StringWriter buffer = new StringWriter();
           output = XMLOutput.createXMLOutput(buffer);
  -        
  +
           
//runScript("src/test/org/apache/commons/jelly/define/babelfishTaglib.jelly");
           runScript("src/test/org/apache/commons/jelly/tags/define/example.jelly");
  -        
  +
           log.info("The output was as follows");
           log.info(buffer.toString());
       }
  -    
  +
       public void testJellyBean() throws Exception {
  -        StringWriter buffer = new StringWriter();        
  +        StringWriter buffer = new StringWriter();
           output = XMLOutput.createXMLOutput(buffer);
  -        
  -     log.warn("commented out test, need to rewrite without ant");
  +
  +    log.warn("commented out test, need to rewrite without ant");
           
//runScript("src/test/org/apache/commons/jelly/define/jellyBeanSample.jelly");
  -        
  +
           log.info("The output was as follows");
           log.info(buffer.toString());
       }
  -    
  +
       protected void runScript(String name) throws Exception {
           context.runScript(new File(name), output);
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to