You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/08/19 22:36:24 UTC

cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant AntTag.java

jstrachan    2002/08/19 13:36:23

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/ant AntTag.java
  Log:
  Patch so that any XML element in the Ant/Maven namespace that does not map to an Ant tag will be output as regular static XML. 
  This allows static XML and Ant/Maven tags all to coexist within the same namespace
  
  Revision  Changes    Path
  1.6       +44 -25    jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant/AntTag.java
  
  Index: AntTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant/AntTag.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AntTag.java	15 Aug 2002 16:13:04 -0000	1.5
  +++ AntTag.java	19 Aug 2002 20:36:23 -0000	1.6
  @@ -68,14 +68,15 @@
   import java.util.Iterator;
   import java.util.Map;
   
  +import org.apache.commons.beanutils.BeanUtils;
  +import org.apache.commons.beanutils.MethodUtils;
  +import org.apache.commons.beanutils.PropertyUtils;
  +
   import org.apache.commons.jelly.JellyContext;
   import org.apache.commons.jelly.MapTagSupport;
   import org.apache.commons.jelly.Tag;
   import org.apache.commons.jelly.XMLOutput;
  -
  -import org.apache.commons.beanutils.BeanUtils;
  -import org.apache.commons.beanutils.MethodUtils;
  -import org.apache.commons.beanutils.PropertyUtils;
  +import org.apache.commons.jelly.impl.StaticTag;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -229,23 +230,41 @@
                   }
                   catch (Exception e) {
                   }
  -            }
  -
  -            // now lets invoke the body
  -            String body = getBodyText();
   
  -            // now lets set any attributes of this tag...
  -            setBeanProperties();
  -
  -            // now lets add it to its parent
  -            if ( parentObject != null ) {
  -                IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() );
  -                try {
  -                    ih.storeElement( project, parentObject, nested, tagName );
  +                // now lets invoke the body
  +                String body = getBodyText();
  +    
  +                // now lets set any attributes of this tag...
  +                setBeanProperties();
  +    
  +                // now lets add it to its parent
  +                if ( parentObject != null ) {
  +                    IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() );
  +                    try {
  +                        ih.storeElement( project, parentObject, nested, tagName );
  +                    }
  +                    catch (Exception e) {
  +                        //log.warn( "Caught exception setting nested: " + tagName, e );
  +                    }
                   }
  -                catch (Exception e) {
  -                    //log.warn( "Caught exception setting nested: " + tagName, e );
  +            }
  +            else {
  +                // lets treat this tag as static XML...                
  +                StaticTag tag = new StaticTag("", tagName, tagName);
  +                tag.setParent( getParent() );
  +                tag.setBody( getBody() );
  +    
  +                tag.setContext(context);
  +        
  +                for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) {
  +                    Map.Entry entry = (Map.Entry) iter.next();
  +                    String name = (String) entry.getKey();
  +                    Object value = entry.getValue();
  +        
  +                    tag.setAttribute(name, value);
                   }
  +            
  +                tag.doTag(output);
               }
           }
       }
  @@ -290,13 +309,13 @@
       public void setBeanProperties() throws Exception {
           Object object = getTaskObject();
           if ( object != null ) {
  -        Map map = getAttributes();
  -        for ( Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
  -            Map.Entry entry = (Map.Entry) iter.next();
  -            String name = (String) entry.getKey();
  -            Object value = entry.getValue();
  -            setBeanProperty( object, name, value );
  -        }
  +            Map map = getAttributes();
  +            for ( Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
  +                Map.Entry entry = (Map.Entry) iter.next();
  +                String name = (String) entry.getKey();
  +                Object value = entry.getValue();
  +                setBeanProperty( object, name, value );
  +            }
           }
       }
   
  
  
  

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