commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons/jelly/src/java/org/apache/commons/jelly/servlet JellyServlet.java
Date Wed, 08 Sep 2004 04:35:22 GMT
dion        2004/09/07 21:35:22

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/core
                        CoreTagLibrary.java InvokeStaticTag.java
                        InvokeTag.java FileTag.java ParseTag.java
                        MuteTag.java BreakTag.java SetTag.java
               jelly/src/java/org/apache/commons/jelly JellyContext.java
               jelly/src/java/org/apache/commons/jelly/expression/xpath
                        XPathExpression.java
               jelly/src/java/org/apache/commons/jelly/servlet
                        JellyServlet.java
  Log:
  detab
  
  Revision  Changes    Path
  1.33      +11 -11    jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/CoreTagLibrary.java
  
  Index: CoreTagLibrary.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/CoreTagLibrary.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- CoreTagLibrary.java	30 Aug 2004 00:48:40 -0000	1.32
  +++ CoreTagLibrary.java	8 Sep 2004 04:35:21 -0000	1.33
  @@ -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.
  @@ -17,9 +17,9 @@
   
   import org.apache.commons.jelly.TagLibrary;
   
  -/** 
  +/**
     * This is the core tag library for jelly and contains commonly
  -  * used tags. 
  +  * used tags.
     * This class could be generated by XDoclet
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  @@ -29,7 +29,7 @@
   
       public CoreTagLibrary() {
           registerTag("jelly", JellyTag.class);
  -        
  +
           // core tags
           registerTag("out", ExprTag.class);
           registerTag("catch", CatchTag.class);
  @@ -46,12 +46,12 @@
           registerTag("switch", SwitchTag.class);
           registerTag("case", CaseTag.class);
           registerTag("default", DefaultTag.class);
  -        
  +
           // other tags
           registerTag("include", IncludeTag.class);
           registerTag("import", ImportTag.class);
  -		registerTag("mute", MuteTag.class);
  -        
  +        registerTag("mute", MuteTag.class);
  +
           // extensions to JSTL
           registerTag("arg", ArgTag.class);
           registerTag("break", BreakTag.class);
  @@ -69,5 +69,5 @@
           registerTag("useList", UseListTag.class);
           registerTag("whitespace", WhitespaceTag.class);
       }
  -    
  +
   }
  
  
  
  1.8       +56 -56    jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/InvokeStaticTag.java
  
  Index: InvokeStaticTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/InvokeStaticTag.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- InvokeStaticTag.java	16 Aug 2004 01:59:00 -0000	1.7
  +++ InvokeStaticTag.java	8 Sep 2004 04:35:22 -0000	1.8
  @@ -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.
  @@ -25,8 +25,8 @@
   import org.apache.commons.jelly.TagSupport;
   import org.apache.commons.jelly.XMLOutput;
   
  -/** 
  -  * A Tag which can invoke a static method on a class, without an 
  +/**
  +  * A Tag which can invoke a static method on a class, without an
     * instance of the class being needed.
     * <p>
     * Like the {@link InvokeTag}, this tag can take a set of
  @@ -48,23 +48,23 @@
   
       /** the variable exported */
       private String var;
  -    
  +
       /** the variable where the method's exception is exported */
       private String exceptionVar;
  -    
  +
       /** the method to invoke */
       private String methodName;
  -    
  +
       /** the object to invoke the method on */
       private String className;
  -    
  +
       private List paramTypes = new ArrayList();
       private List paramValues = new ArrayList();
  -    
  +
       public InvokeStaticTag() {
       }
   
  -    /** 
  +    /**
        * Sets the name of the variable exported by this tag
        *
        * @param var The variable name
  @@ -72,14 +72,14 @@
       public void setVar(String var) {
           this.var = var;
       }
  -    
  +
       /** Sets the name of a variable that exports the exception thrown by
        * the method's invocation (if any)
        */
       public void setExceptionVar(String var) {
           this.exceptionVar = var;
       }
  -    
  +
       /**
        * Sets the name of the method to invoke
        *
  @@ -88,7 +88,7 @@
       public void setMethod(String methodName) {
           this.methodName = methodName;
       }
  -    
  +
       /**
        * Sets the fully qualified class name containing the static method
        *
  @@ -97,7 +97,7 @@
       public void setClassName(String className) {
           this.className = className;
       }
  -    
  +
       /**
        * Adds an argument to supply to the method
        *
  @@ -108,60 +108,60 @@
           paramTypes.add(type);
           paramValues.add(value);
       }
  -    
  +
       // Tag interface
  -    //------------------------------------------------------------------------- 
  +    //-------------------------------------------------------------------------
       public void doTag(XMLOutput output) throws JellyTagException {
  -        try {        
  -	        if ( null == methodName) {
  -	            throw new MissingAttributeException( "method" );
  -	        }
  -	        invokeBody(output);
  -	
  -	        Object[] values = paramValues.toArray();
  -	        Class[] types = (Class[])(paramTypes.toArray(new Class[paramTypes.size()]));
  -	        Method method = loadClass().getMethod( methodName, types );
  -	        Object result = method.invoke( null, values );
  -	        if(null != var) {
  -	            context.setVariable(var, result);
  -	        }
  -	        
  -	        ArgTag parentArg = (ArgTag)(findAncestorWithClass(ArgTag.class));
  -	        if(null != parentArg) {
  -	            parentArg.setValue(result);
  -	        }
  +        try {
  +            if ( null == methodName) {
  +                throw new MissingAttributeException( "method" );
  +            }
  +            invokeBody(output);
  +
  +            Object[] values = paramValues.toArray();
  +            Class[] types = (Class[])(paramTypes.toArray(new Class[paramTypes.size()]));
  +            Method method = loadClass().getMethod( methodName, types );
  +            Object result = method.invoke( null, values );
  +            if(null != var) {
  +                context.setVariable(var, result);
  +            }
  +
  +            ArgTag parentArg = (ArgTag)(findAncestorWithClass(ArgTag.class));
  +            if(null != parentArg) {
  +                parentArg.setValue(result);
  +            }
           }
           catch (ClassNotFoundException e) {
               throw createLoadClassFailedException(e);
  -        } 
  +        }
           catch (NoSuchMethodException e) {
               throw createLoadClassFailedException(e);
  -        } 
  +        }
           catch (IllegalAccessException e) {
               throw createLoadClassFailedException(e);
  -        } 
  +        }
           catch (InvocationTargetException e) {
  -        	if(null != exceptionVar) {
  -        		context.setVariable(exceptionVar,e.getTargetException());
  -        	} else {
  -        		throw new JellyTagException("method " + methodName + 
  -            		" threw exception: "+ e.getTargetException().getMessage(), 
  -					e.getTargetException() );
  -        	}
  +            if(null != exceptionVar) {
  +                context.setVariable(exceptionVar,e.getTargetException());
  +            } else {
  +                throw new JellyTagException("method " + methodName +
  +                    " threw exception: "+ e.getTargetException().getMessage(),
  +                    e.getTargetException() );
  +            }
           }
           finally {
               paramTypes.clear();
               paramValues.clear();
           }
       }
  -    
  +
       // Tag interface
       //-------------------------------------------------------------------------
  -    
  +
       /**
  -     * Loads the class using either the class loader which loaded me or the 
  +     * Loads the class using either the class loader which loaded me or the
        * current threads context class loader
  -     */ 
  +     */
       protected Class loadClass() throws ClassNotFoundException {
           ClassLoader loader = getClass().getClassLoader();
           if (loader != null) {
  @@ -175,12 +175,12 @@
           return getClass().getClassLoader().loadClass( className );
       }
   
  -	/**
  -	 * Factory method to create a new JellyTagException instance from a given
  -	 * failure exception
  -	 * @param e is the exception which occurred attempting to load the class
  -	 * @return JellyTagException
  -	 */
  +    /**
  +     * Factory method to create a new JellyTagException instance from a given
  +     * failure exception
  +     * @param e is the exception which occurred attempting to load the class
  +     * @return JellyTagException
  +     */
       protected JellyTagException createLoadClassFailedException(Exception e) {
           return new JellyTagException(
               "Could not load class: " + className + ". Reason: " + e, e
  
  
  
  1.10      +32 -32    jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/InvokeTag.java
  
  Index: InvokeTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/InvokeTag.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- InvokeTag.java	27 Aug 2004 05:01:32 -0000	1.9
  +++ InvokeTag.java	8 Sep 2004 04:35:22 -0000	1.10
  @@ -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.
  @@ -25,9 +25,9 @@
   import org.apache.commons.jelly.TagSupport;
   import org.apache.commons.jelly.XMLOutput;
   
  -/** 
  -  * A tag which calls a method in an object instantied by core:new 
  -  * 
  +/**
  +  * A tag which calls a method in an object instantied by core:new
  +  *
     *
     * @author Rodney Waldhoff
     * @version $Revision$
  @@ -36,19 +36,19 @@
   
       /** the variable exported */
       private String var;
  -    
  +
       /** the variable where the method's exception is exported */
       private String exceptionVar;
  -    
  +
       /** the method to invoke */
       private String methodName;
  -    
  +
       /** the object to invoke the method on */
       private Object onInstance;
  -    
  +
       private List paramTypes = new ArrayList();
       private List paramValues = new ArrayList();
  -    
  +
       public InvokeTag() {
       }
   
  @@ -56,29 +56,29 @@
       public void setVar(String var) {
           this.var = var;
       }
  -    
  +
       /** Sets the name of a variable that exports the exception thrown by
        * the method's invocation (if any)
        */
       public void setExceptionVar(String var) {
           this.exceptionVar = var;
       }
  -    
  +
       public void setMethod(String method) {
           this.methodName = method;
       }
  -    
  +
       public void setOn(Object instance) {
           this.onInstance = instance;
       }
  -    
  +
       public void addArgument(Class type, Object value) {
           paramTypes.add(type);
           paramValues.add(value);
       }
  -    
  +
       // Tag interface
  -    //------------------------------------------------------------------------- 
  +    //-------------------------------------------------------------------------
       public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {
           if ( null == methodName) {
               throw new MissingAttributeException( "method" );
  @@ -86,12 +86,12 @@
           if ( null == onInstance ) {
               throw new MissingAttributeException( "on" );
           }
  -        
  +
           invokeBody(output);
  -        
  +
           Object[] values = paramValues.toArray();
           Class[] types = (Class[])(paramTypes.toArray(new Class[paramTypes.size()]));
  -        
  +
           Object result = null;
           try {
               result = MethodUtils.invokeMethod(onInstance,methodName,values,types);
  @@ -101,21 +101,21 @@
           }
           catch (IllegalAccessException e) {
               throw new JellyTagException(e);
  -        } 
  +        }
           catch (InvocationTargetException e) {
  -        	if(null != exceptionVar) {
  -        		context.setVariable(exceptionVar,e.getTargetException());
  -        	} else {
  -        		throw new JellyTagException("method " + methodName + 
  -            		" threw exception: "+ e.getTargetException().getMessage(),
  -				    e.getTargetException() );
  -        	}
  +            if(null != exceptionVar) {
  +                context.setVariable(exceptionVar,e.getTargetException());
  +            } else {
  +                throw new JellyTagException("method " + methodName +
  +                    " threw exception: "+ e.getTargetException().getMessage(),
  +                    e.getTargetException() );
  +            }
           }
           finally {
  -        	paramTypes.clear();
  -        	paramValues.clear();
  +            paramTypes.clear();
  +            paramValues.clear();
           }
  -        
  +
           ArgTag parentArg = (ArgTag)(findAncestorWithClass(ArgTag.class));
           if(null != parentArg) {
               parentArg.setValue(result);
  
  
  
  1.15      +22 -22    jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/FileTag.java
  
  Index: FileTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/FileTag.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- FileTag.java	5 Sep 2004 12:00:24 -0000	1.14
  +++ FileTag.java	8 Sep 2004 04:35:22 -0000	1.15
  @@ -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.
  @@ -32,7 +32,7 @@
   import org.dom4j.io.XMLWriter;
   import org.xml.sax.SAXException;
   
  -/** 
  +/**
    * A tag that pipes its body to a file denoted by the name attribute or to an in memory String
    * which is then output to a variable denoted by the var variable.
    *
  @@ -45,12 +45,12 @@
       private String outputMode = "xml";
       private boolean prettyPrint;
       private String encoding;
  -    
  +
       public FileTag(){
       }
   
       // Tag interface
  -    //------------------------------------------------------------------------- 
  +    //-------------------------------------------------------------------------
       public void doTag(final XMLOutput output) throws JellyTagException {
           try {
               if ( name != null ) {
  @@ -74,25 +74,25 @@
               throw new JellyTagException("could not write file",e);
           }
       }
  -        
  +
       // Properties
  -    //------------------------------------------------------------------------- 
  -    
  +    //-------------------------------------------------------------------------
  +
       /**
        * Sets the file name for the output
        */
       public void setName(String name) {
           this.name = name;
       }
  -    
  +
       /**
  -     * Sets whether the XML declaration should be output or not 
  +     * Sets whether the XML declaration should be output or not
        */
       public void setOmitXmlDeclaration(boolean omitXmlDeclaration) {
           this.omitXmlDeclaration = omitXmlDeclaration;
       }
  -    
  -    
  +
  +
       /**
        * Sets the output mode, whether XML or HTML
        */
  @@ -106,14 +106,14 @@
       public void setPrettyPrint(boolean prettyPrint) {
           this.prettyPrint = prettyPrint;
       }
  -        
  +
       /**
        * Sets the XML encoding mode, which defaults to UTF-8
        */
       public void setEncoding(String encoding) {
           this.encoding = encoding;
       }
  -        
  +
       /**
        * Returns the var.
        * @return String
  @@ -139,22 +139,22 @@
           try {
               // we need to avoid multiple start/end document events
               newOutput.setContentHandler(
  -            	new SafeContentHandler(newOutput.getContentHandler())
  +                new SafeContentHandler(newOutput.getContentHandler())
               );
               newOutput.startDocument();
               invokeBody(newOutput);
               newOutput.endDocument();
  -        }  
  +        }
           finally {
               try { newOutput.close(); } catch (IOException e) {}
           }
       }
  -    
  +
       /**
        * A Factory method to create a new XMLOutput from the given Writer.
        */
       protected XMLOutput createXMLOutput(Writer writer) {
  -        
  +
           OutputFormat format = null;
           if (prettyPrint) {
               format = OutputFormat.createPrettyPrint();
  @@ -164,13 +164,13 @@
           }
           if ( encoding != null ) {
               format.setEncoding( encoding );
  -        }           
  +        }
           if ( omitXmlDeclaration ) {
               format.setSuppressDeclaration(true);
           }
  -                    
  +
           boolean isHtml = outputMode != null && outputMode.equalsIgnoreCase( "html" );
  -        final XMLWriter xmlWriter = (isHtml) 
  +        final XMLWriter xmlWriter = (isHtml)
               ? new HTMLWriter(writer, format)
               : new XMLWriter(writer, format);
   
  
  
  
  1.5       +28 -28    jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/ParseTag.java
  
  Index: ParseTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/ParseTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ParseTag.java	21 Jun 2004 11:16:29 -0000	1.4
  +++ ParseTag.java	8 Sep 2004 04:35:22 -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.
  @@ -34,7 +34,7 @@
   import org.xml.sax.SAXException;
   import org.xml.sax.XMLReader;
   
  -/** 
  +/**
    * Parses the output of this tags body or of a given String as a Jelly script
    * then either outputting the Script as a variable or executing the script.
    *
  @@ -48,21 +48,21 @@
   
       /** The variable that will be generated for the document */
       private String var;
  -    
  +
       /** The markup text to be parsed */
       private String text;
   
       /** The XMLReader used to parser the document */
       private XMLReader xmlReader;
   
  -	/** The Jelly parser */
  -	private XMLParser jellyParser;
  -	
  +    /** The Jelly parser */
  +    private XMLParser jellyParser;
  +
       public ParseTag() {
       }
   
       // Tag interface
  -    //-------------------------------------------------------------------------                
  +    //-------------------------------------------------------------------------
   
       /* (non-Javadoc)
        * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
  @@ -74,10 +74,10 @@
           if (text != null) {
               parseText(text);
           }
  -        else {            
  +        else {
               parseBody(output);
           }
  -	
  +
           Script script = getJellyParser().getScript();
           if (var != null) {
               context.setVariable(var, script);
  @@ -89,7 +89,7 @@
       }
   
       // Properties
  -    //-------------------------------------------------------------------------                
  +    //-------------------------------------------------------------------------
       /** The variable name that will be used for the Document variable created
        */
       public String getVar() {
  @@ -118,7 +118,7 @@
           this.text = text;
       }
   
  -    
  +
       /** @return the XMLReader used for parsing, creating one lazily if need be  */
       public XMLReader getXMLReader() throws ParserConfigurationException, SAXException {
           if (xmlReader == null) {
  @@ -140,7 +140,7 @@
           if (jellyParser == null) {
               jellyParser = createJellyParser();
           }
  -	    return jellyParser;
  +        return jellyParser;
       }
   
       /**
  @@ -150,39 +150,39 @@
       public void setJellyParser(XMLParser jellyParser) {
           this.jellyParser = jellyParser;
       }
  -    
  +
   
       // Implementation methods
  -    //-------------------------------------------------------------------------                
  +    //-------------------------------------------------------------------------
   
       /**
        * Factory method to create a new XMLReader
  -     */    
  +     */
       protected XMLReader createXMLReader() throws ParserConfigurationException, SAXException {
           SAXParserFactory factory = SAXParserFactory.newInstance();
           factory.setNamespaceAware(true);
           SAXParser parser = factory.newSAXParser();
  -        return parser.getXMLReader(); 
  +        return parser.getXMLReader();
       }
  -    
  -    
  +
  +
       /**
        * Parses the body of this tag and returns the parsed document
        */
       protected void parseBody(XMLOutput output) throws JellyTagException {
           ContentHandler handler = getJellyParser();
           XMLOutput newOutput = new XMLOutput(handler);
  -        
  +
           try {
               handler.startDocument();
               invokeBody(newOutput);
               handler.endDocument();
  -        } 
  +        }
           catch (SAXException e) {
               throw new JellyTagException(e);
           }
       }
  -    
  +
       /**
        * Parses the give piece of text as being markup
        */
  @@ -190,22 +190,22 @@
           if ( log.isDebugEnabled() ) {
               log.debug( "About to parse: " + text );
           }
  -        
  +
           try {
               getXMLReader().parse( new InputSource( new StringReader( text ) ) );
  -        } 
  +        }
           catch (Exception e) {
               throw new JellyTagException(e);
           }
       }
  -    
  +
       /**
        * Factory method to create a new Jelly parser
        * @return XMLParser
        */
       protected XMLParser createJellyParser() {
           XMLParser answer = new XMLParser();
  -        answer.setContext(context); 
  +        answer.setContext(context);
           return answer;
       }
   }
  
  
  
  1.2       +21 -21    jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/MuteTag.java
  
  Index: MuteTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/MuteTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MuteTag.java	21 Jun 2004 11:18:30 -0000	1.1
  +++ MuteTag.java	8 Sep 2004 04:35:22 -0000	1.2
  @@ -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.
  @@ -24,26 +24,26 @@
   /** A tag which executes its body but passing no output.
    *  <p>
    * Using this tag will still take the time to perform toString on each object
  - * returned to the output (but this toString value is discarded. 
  + * returned to the output (but this toString value is discarded.
    * A future version should go more internally so that this is avoided.
  - * 
  + *
    * @author <a href="mailto:paul@activemath.org">Paul Libbrecht</a>
    * @version $Revision$
     */
   public class MuteTag extends TagSupport {
  -	
  -	public MuteTag() {
  -		super();
  -	}
  -	
  -	
  -	public void doTag(XMLOutput output) throws JellyTagException {
  -		super.invokeBody(makeMuteOutput());
  -	}
  -	
  -	
  -	private XMLOutput makeMuteOutput() {
  -		return new XMLOutput(new DefaultHandler());
  -	}
  -	
  +
  +    public MuteTag() {
  +        super();
  +    }
  +
  +
  +    public void doTag(XMLOutput output) throws JellyTagException {
  +        super.invokeBody(makeMuteOutput());
  +    }
  +
  +
  +    private XMLOutput makeMuteOutput() {
  +        return new XMLOutput(new DefaultHandler());
  +    }
  +
   } // class TagSupport
  
  
  
  1.9       +16 -16    jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/BreakTag.java
  
  Index: BreakTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/BreakTag.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BreakTag.java	12 Aug 2004 04:58:04 -0000	1.8
  +++ BreakTag.java	8 Sep 2004 04:35:22 -0000	1.9
  @@ -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.
  @@ -20,11 +20,11 @@
   import org.apache.commons.jelly.impl.BreakException;
   import org.apache.commons.jelly.expression.Expression;
   
  -/** 
  +/**
    * A tag which terminates the execution of the current &lt;forEach&gt; or &lg;while&gt;
    * loop. This tag can take an optional boolean test attribute which if its true
    * then the break occurs otherwise the loop continues processing.
  - * 
  + *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision$
    */
  @@ -33,7 +33,7 @@
       /** The expression to evaluate. */
       private Expression test;
   
  -    /** 
  +    /**
        * If specified, the given variable will hold a true/false value
        * indicating if the loop was broken.
        */
  @@ -43,22 +43,22 @@
       }
   
       // Tag interface
  -    //------------------------------------------------------------------------- 
  +    //-------------------------------------------------------------------------
       public void doTag(XMLOutput output) throws BreakException {
  -    	boolean broken = false;
  +        boolean broken = false;
           if (test == null || test.evaluateAsBoolean(context)) {
  -        	broken = true;
  +            broken = true;
           }
           if ( var != null ) {
  -        	context.setVariable( this.var, String.valueOf(broken));
  +            context.setVariable( this.var, String.valueOf(broken));
           }
           if ( broken ) {
  -            throw new BreakException();        	
  +            throw new BreakException();
           }
       }
   
  -    /** 
  -     * Sets the Jelly expression to evaluate (optional). 
  +    /**
  +     * Sets the Jelly expression to evaluate (optional).
        * If this is <code>null</code> or evaluates to
        * <code>true</code> then the loop is terminated
        *
  @@ -67,13 +67,13 @@
       public void setTest(Expression test) {
           this.test = test;
       }
  -    
  -    /** 
  +
  +    /**
        * Sets the variable name to export indicating if the item was broken
        * @param var name of the variable to be exported
        */
       public void setVar(String var) {
           this.var = var;
       }
  -    
  +
   }
  
  
  
  1.18      +27 -27    jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/SetTag.java
  
  Index: SetTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/tags/core/SetTag.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- SetTag.java	24 Feb 2004 14:10:38 -0000	1.17
  +++ SetTag.java	8 Sep 2004 04:35:22 -0000	1.18
  @@ -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.
  @@ -27,7 +27,7 @@
   import org.apache.commons.logging.LogFactory;
   
   
  -/** A tag which sets a variable from the result of an expression 
  +/** A tag which sets a variable from the result of an expression
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
     * @version $Revision$
  @@ -36,25 +36,25 @@
   
       /** The Log to which logging calls will be made. */
       private static final Log log = LogFactory.getLog(SetTag.class);
  -    
  +
       /** The variable name to export. */
       private String var;
   
       /** The variable scope to export */
       private String scope;
  -    
  +
       /** The expression to evaluate. */
       private Expression value;
   
  -	/** The default value */
  -	private Expression defaultValue;
  -	
  +    /** The default value */
  +    private Expression defaultValue;
  +
       /** The target object on which to set a property. */
       private Object target;
   
       /** The name of the property to set on the target object. */
       private String property;
  -    
  +
       /** Should we XML encode the body of this tag as text? */
       private boolean encode = true;
   
  @@ -62,7 +62,7 @@
       }
   
       // Tag interface
  -    //------------------------------------------------------------------------- 
  +    //-------------------------------------------------------------------------
       public void doTag(XMLOutput output) throws JellyTagException {
           // perform validation up front to fail fast
           if ( var != null ) {
  @@ -89,7 +89,7 @@
           else {
               answer = getBodyText(isEncode());
           }
  -        
  +
           if ( var != null ) {
               if ( scope != null ) {
                   context.setVariable(var, scope, answer);
  @@ -104,47 +104,47 @@
       }
   
       // Properties
  -    //-------------------------------------------------------------------------                
  +    //-------------------------------------------------------------------------
       /** Sets the variable name to define for this expression
        */
       public void setVar(String var) {
           this.var = var;
       }
  -    
  -    /** 
  +
  +    /**
        * Sets the variable scope for this variable. For example setting this value to 'parent' will
        * set this value in the parent scope. When Jelly is run from inside a Servlet environment
        * then other scopes will be available such as 'request', 'session' or 'application'.
  -     * 
  +     *
        * Other applications may implement their own custom scopes.
        */
       public void setScope(String scope) {
           this.scope = scope;
       }
  -    
  +
       /** Sets the expression to evaluate. */
       public void setValue(Expression value) {
           this.value = value;
       }
  -    
  -    /** 
  -     * Sets the default value to be used if the value exprsesion results 
  +
  +    /**
  +     * Sets the default value to be used if the value exprsesion results
        * in a null value or blank String
        */
       public void setDefaultValue(Expression defaultValue) {
           this.defaultValue = defaultValue;
       }
  -    
  +
       /** Sets the target object on which to set a property. */
       public void setTarget(Object target) {
           this.target = target;
       }
  -           
  +
       /** Sets the name of the property to set on the target object. */
       public void setProperty(String property) {
           this.property = property;
       }
  -    
  +
       /**
        * Returns whether the body of this tag will be XML encoded or not.
        */
  @@ -164,7 +164,7 @@
   
   
       // Implementation methods
  -    //-------------------------------------------------------------------------                
  +    //-------------------------------------------------------------------------
       protected void setPropertyValue( Object target, String property, Object value ) {
           try {
               if ( target instanceof Map ) {
  @@ -172,7 +172,7 @@
                   map.put( property, value );
               }
               else {
  -                BeanUtils.setProperty( target, property, value );       
  +                BeanUtils.setProperty( target, property, value );
               }
           } catch (InvocationTargetException e) {
               log.error( "Failed to set the property: " + property + " on bean: " + target + " to value: " + value + " due to exception: " + e, e );
  @@ -180,7 +180,7 @@
               log.error( "Failed to set the property: " + property + " on bean: " + target + " to value: " + value + " due to exception: " + e, e );
           }
       }
  -    
  +
       /**
        * @param value
        * @return true if the given value is null or an empty String
  
  
  
  1.58      +123 -123  jakarta-commons/jelly/src/java/org/apache/commons/jelly/JellyContext.java
  
  Index: JellyContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/JellyContext.java,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- JellyContext.java	5 Sep 2004 14:17:33 -0000	1.57
  +++ JellyContext.java	8 Sep 2004 04:35:22 -0000	1.58
  @@ -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.
  @@ -62,7 +62,7 @@
   
       /** Do we inherit variables from parent context? */
       private boolean inherit = JellyContext.DEFAULT_INHERIT;
  -    
  +
       /** Default for export of variables **/
       private static boolean DEFAULT_EXPORT = false;
   
  @@ -71,10 +71,10 @@
   
       /** Should we export tag libraries to our parents context */
       private boolean exportLibraries = true;
  -        
  +
       /** Should we cache Tag instances, per thread, to reduce object contruction overhead? */
       private boolean cacheTags = false;
  -    
  +
       /**
        * The class loader to use for instantiating application objects.
        * If not specified, the context class loader, or the class loader
  @@ -102,7 +102,7 @@
   
       /**
        * Create a new context with the given rootURL
  -     * @param rootURL the root URL used in resolving absolute resources i.e. those starting with '/' 
  +     * @param rootURL the root URL used in resolving absolute resources i.e. those starting with '/'
        */
       public JellyContext(URL rootURL) {
           this( rootURL, rootURL );
  @@ -110,8 +110,8 @@
   
       /**
        * Create a new context with the given rootURL and currentURL
  -     * @param rootURL the root URL used in resolving absolute resources i.e. those starting with '/' 
  -     * @param currentURL the root URL used in resolving relative resources 
  +     * @param rootURL the root URL used in resolving absolute resources i.e. those starting with '/'
  +     * @param currentURL the root URL used in resolving relative resources
        */
       public JellyContext(URL rootURL, URL currentURL) {
           this.rootURL = rootURL;
  @@ -124,7 +124,7 @@
        * Create a new context with the given parent context.
        * The parent's rootURL and currentURL are set on the child, and the parent's variables are
        * available in the child context under the name <code>parentScope</code>.
  -     * 
  +     *
        * @param parent the parent context for the newly created context.
        */
       public JellyContext(JellyContext parent) {
  @@ -140,9 +140,9 @@
        * Create a new context with the given parent context.
        * The parent's rootURL are set on the child, and the parent's variables are
        * available in the child context under the name <code>parentScope</code>.
  -     * 
  +     *
        * @param parentJellyContext the parent context for the newly created context.
  -     * @param currentURL the root URL used in resolving relative resources 
  +     * @param currentURL the root URL used in resolving relative resources
        */
       public JellyContext(JellyContext parentJellyContext, URL currentURL) {
           this(parentJellyContext);
  @@ -152,10 +152,10 @@
       /**
        * Create a new context with the given parent context.
        * The parent's variables are available in the child context under the name <code>parentScope</code>.
  -     * 
  +     *
        * @param parentJellyContext the parent context for the newly created context.
  -     * @param rootURL the root URL used in resolving absolute resources i.e. those starting with '/' 
  -     * @param currentURL the root URL used in resolving relative resources 
  +     * @param rootURL the root URL used in resolving absolute resources i.e. those starting with '/'
  +     * @param currentURL the root URL used in resolving relative resources
        */
       public JellyContext(JellyContext parentJellyContext, URL rootURL, URL currentURL) {
           this(parentJellyContext, currentURL);
  @@ -168,14 +168,14 @@
        * making the System Properties available as <code>systemScope</code>
        */
       private void init() {
  -		variables.put("context",this);
  -		try {
  -			variables.put("systemScope", System.getProperties() );
  -		} catch (SecurityException e) {
  +        variables.put("context",this);
  +        try {
  +            variables.put("systemScope", System.getProperties() );
  +        } catch (SecurityException e) {
               log.debug("security exception accessing system properties", e);
  -		}
  -	}
  -    
  +        }
  +    }
  +
       /**
        * @return the parent context for this context
        */
  @@ -185,7 +185,7 @@
   
       /**
        * @return the scope of the given name, such as the 'parent' scope.
  -     * If Jelly is used in a Servlet situation then 'request', 'session' and 'application' are other names 
  +     * If Jelly is used in a Servlet situation then 'request', 'session' and 'application' are other names
        * for scopes
        */
       public JellyContext getScope(String name) {
  @@ -194,21 +194,21 @@
           }
           return null;
       }
  -    
  -    /** 
  +
  +    /**
        * Finds the variable value of the given name in this context or in any other parent context.
  -     * If this context does not contain the variable, then its parent is used and then its parent 
  +     * If this context does not contain the variable, then its parent is used and then its parent
        * and so forth until the context with no parent is found.
  -     * 
  +     *
        * @return the value of the variable in this or one of its descendant contexts or null
        *  if the variable could not be found.
        */
       public Object findVariable(String name) {
           Object answer = variables.get(name);
           boolean definedHere = answer != null || variables.containsKey(name);
  -        
  +
           if (definedHere) return answer;
  -        
  +
           if ( answer == null && parent != null ) {
               answer = parent.findVariable(name);
           }
  @@ -216,24 +216,24 @@
           if ( answer == null ) {
               answer = getSystemProperty(name);
           }
  -        
  +
           if (log.isDebugEnabled()) {
               log.debug("findVariable: " + name + " value: " + answer );
           }
           return answer;
       }
  -            
  -        
  +
  +
       /** @return the value of the given variable name */
       public Object getVariable(String name) {
           Object value = variables.get(name);
           boolean definedHere = value != null || variables.containsKey(name);
  -		
  +
           if (definedHere) return value;
  -        
  +
           if ( value == null && isInherit() ) {
               JellyContext parent = getParent();
  -            if (parent != null) {                
  +            if (parent != null) {
                   value = parent.getVariable( name );
               }
           }
  @@ -245,7 +245,7 @@
   
           return value;
       }
  -    
  +
       /**
        * Get a system property and handle security exceptions
        * @param name the name of the property to retrieve
  @@ -261,8 +261,8 @@
           return null;
       }
   
  -    /** 
  -     * @return the value of the given variable name in the given variable scope 
  +    /**
  +     * @return the value of the given variable name in the given variable scope
        * @param name is the name of the variable
        * @param scopeName is the optional scope name such as 'parent'. For servlet environments
        * this could be 'application', 'session' or 'request'.
  @@ -274,8 +274,8 @@
           }
           return null;
       }
  -    
  -    
  +
  +
   
       /** Sets the value of the named variable */
       public void setVariable(String name, Object value) {
  @@ -291,8 +291,8 @@
           }
       }
   
  -    /** 
  -     * Sets the value of the given variable name in the given variable scope 
  +    /**
  +     * Sets the value of the given variable name in the given variable scope
        * @param name is the name of the variable
        * @param scopeName is the optional scope name such as 'parent'. For servlet environments
        *  this could be 'application', 'session' or 'request'.
  @@ -304,15 +304,15 @@
               scope.setVariable(name, value);
           }
       }
  -    
  +
       /** Removes the given variable */
       public void removeVariable(String name) {
           variables.remove(name);
       }
   
  -    /** 
  +    /**
        * Removes the given variable in the specified scope.
  -     * 
  +     *
        * @param name is the name of the variable
        * @param scopeName is the optional scope name such as 'parent'. For servlet environments
        *  this could be 'application', 'session' or 'request'.
  @@ -323,10 +323,10 @@
               scope.removeVariable(name);
           }
       }
  -    
  -    /** 
  +
  +    /**
        * @return an Iterator over the current variable names in this
  -     * context 
  +     * context
        */
       public Iterator getVariableNames() {
           return variables.keySet().iterator();
  @@ -343,7 +343,7 @@
        * Sets the Map of variables to use
        */
       public void setVariables(Map variables) {
  -        // I have seen this fail when the passed Map contains a key, value 
  +        // I have seen this fail when the passed Map contains a key, value
           // pair where the value is null
           for (Iterator iter = variables.entrySet().iterator(); iter.hasNext();) {
               Map.Entry element = (Map.Entry) iter.next();
  @@ -360,7 +360,7 @@
        */
       public JellyContext newJellyContext(Map newVariables) {
           // XXXX: should allow this new context to
  -        // XXXX: inherit parent contexts? 
  +        // XXXX: inherit parent contexts?
           // XXXX: Or at least publish the parent scope
           // XXXX: as a Map in this new variable scope?
           newVariables.put("parentScope", variables);
  @@ -385,7 +385,7 @@
               log.debug("Registering tag library to: " + namespaceURI + " taglib: " + taglib);
           }
           taglibs.put(namespaceURI, taglib);
  -        
  +
           if (isExportLibraries() && parent != null) {
               parent.registerTagLibrary( namespaceURI, taglib );
           }
  @@ -398,12 +398,12 @@
       public void registerTagLibrary(
           String namespaceURI,
           String className) {
  -            
  +
           if (log.isDebugEnabled()) {
               log.debug("Registering tag library to: " + namespaceURI + " taglib: " + className);
           }
           taglibs.put(namespaceURI, className);
  -        
  +
           if (isExportLibraries() && parent != null) {
               parent.registerTagLibrary( namespaceURI, className );
           }
  @@ -422,14 +422,14 @@
           }
       }
   
  -    /** 
  +    /**
        * @return the TagLibrary for the given namespace URI or null if one could not be found
        */
       public TagLibrary getTagLibrary(String namespaceURI) {
   
  -        // use my own mapping first, so that namespaceURIs can 
  +        // use my own mapping first, so that namespaceURIs can
           // be redefined inside child contexts...
  -        
  +
           Object answer = taglibs.get(namespaceURI);
   
           if ( answer == null && parent != null ) {
  @@ -454,7 +454,7 @@
                       if (object instanceof TagLibrary) {
                           taglibs.put(namespaceURI, object);
                           return (TagLibrary) object;
  -                    }                
  +                    }
                       else {
                           log.error(
                               "The tag library object mapped to: "
  @@ -474,8 +474,8 @@
           return null;
       }
   
  -    /** 
  -     * Attempts to parse the script from the given uri using the 
  +    /**
  +     * Attempts to parse the script from the given uri using the
        * {@link #getResource} method then returns the compiled script.
        */
       public Script compileScript(String uri) throws JellyException {
  @@ -493,18 +493,18 @@
           } catch (SAXException e) {
               throw new JellyException(JellyContext.BAD_PARSE, e);
           }
  -        
  +
           return script.compile();
       }
   
  -    /** 
  -     * Attempts to parse the script from the given URL using the 
  +    /**
  +     * Attempts to parse the script from the given URL using the
        * {@link #getResource} method then returns the compiled script.
        */
       public Script compileScript(URL url) throws JellyException {
           XMLParser parser = getXMLParser();
           parser.setContext(this);
  -        
  +
           Script script = null;
           try {
               script = parser.parse(url.toString());
  @@ -513,18 +513,18 @@
           } catch (SAXException e) {
               throw new JellyException(JellyContext.BAD_PARSE, e);
           }
  -        
  +
           return script.compile();
       }
   
  -    /** 
  -     * Attempts to parse the script from the given InputSource using the 
  +    /**
  +     * Attempts to parse the script from the given InputSource using the
        * {@link #getResource} method then returns the compiled script.
        */
       public Script compileScript(InputSource source) throws JellyException {
           XMLParser parser = getXMLParser();
           parser.setContext(this);
  -        
  +
           Script script = null;
           try {
               script = parser.parse(source);
  @@ -533,7 +533,7 @@
           } catch (SAXException e) {
               throw new JellyException(JellyContext.BAD_PARSE, e);
           }
  -        
  +
           return script.compile();
       }
   
  @@ -546,17 +546,17 @@
           return parser;
       }
   
  -	/**
  -	 * Factory method to allow JellyContext implementations to overload how an XMLParser
  -	 * is created - such as to overload what the default ExpressionFactory should be.
  -	 */
  +    /**
  +     * Factory method to allow JellyContext implementations to overload how an XMLParser
  +     * is created - such as to overload what the default ExpressionFactory should be.
  +     */
       protected XMLParser createXMLParser() {
           return new XMLParser();
       }
   
  -    /** 
  +    /**
        * Parses the script from the given File then compiles it and runs it.
  -     * 
  +     *
        * @return the new child context that was used to run the script
        */
       public JellyContext runScript(File file, XMLOutput output) throws JellyException {
  @@ -568,9 +568,9 @@
           }
       }
   
  -    /** 
  +    /**
        * Parses the script from the given URL then compiles it and runs it.
  -     * 
  +     *
        * @return the new child context that was used to run the script
        */
       public JellyContext runScript(URL url, XMLOutput output) throws JellyException {
  @@ -578,9 +578,9 @@
               JellyContext.DEFAULT_INHERIT);
       }
   
  -    /** 
  +    /**
        * Parses the script from the given InputSource then compiles it and runs it.
  -     * 
  +     *
        * @return the new child context that was used to run the script
        */
       public JellyContext runScript(InputSource source, XMLOutput output) throws JellyException {
  @@ -588,10 +588,10 @@
               JellyContext.DEFAULT_INHERIT);
       }
   
  -    /** 
  -     * Parses the script from the given uri using the 
  +    /**
  +     * Parses the script from the given uri using the
        * JellyContext.getResource() API then compiles it and runs it.
  -     * 
  +     *
        * @return the new child context that was used to run the script
        */
       public JellyContext runScript(String uri, XMLOutput output) throws JellyException {
  @@ -601,7 +601,7 @@
           } catch (MalformedURLException e) {
               throw new JellyException(e.toString());
           }
  -        
  +
           if (url == null) {
               throw new JellyException("Could not find Jelly script: " + url);
           }
  @@ -609,10 +609,10 @@
               JellyContext.DEFAULT_INHERIT);
       }
   
  -    /** 
  -     * Parses the script from the given uri using the 
  +    /**
  +     * Parses the script from the given uri using the
        * JellyContext.getResource() API then compiles it and runs it.
  -     * 
  +     *
        * @return the new child context that was used to run the script
        */
       public JellyContext runScript(String uri, XMLOutput output,
  @@ -623,17 +623,17 @@
           } catch (MalformedURLException e) {
               throw new JellyException(e.toString());
           }
  -        
  +
           if (url == null) {
               throw new JellyException("Could not find Jelly script: " + url);
           }
  -        
  +
           return runScript(url, output, export, inherit);
       }
   
  -    /** 
  +    /**
        * Parses the script from the given file then compiles it and runs it.
  -     * 
  +     *
        * @return the new child context that was used to run the script
        */
       public JellyContext runScript(File file, XMLOutput output,
  @@ -645,9 +645,9 @@
           }
       }
   
  -    /** 
  +    /**
        * Parses the script from the given URL then compiles it and runs it.
  -     * 
  +     *
        * @return the new child context that was used to run the script
        */
       public JellyContext runScript(URL url, XMLOutput output,
  @@ -655,32 +655,32 @@
           return runScript(new InputSource(url.toString()), output, export, inherit);
       }
   
  -    /** 
  +    /**
        * Parses the script from the given InputSource then compiles it and runs it.
  -     * 
  +     *
        * @return the new child context that was used to run the script
        */
       public JellyContext runScript(InputSource source, XMLOutput output,
                             boolean export, boolean inherit) throws JellyException {
           Script script = compileScript(source);
  -        
  +
           URL newJellyContextURL = null;
           try {
               newJellyContextURL = getJellyContextURL(source);
           } catch (MalformedURLException e) {
               throw new JellyException(e.toString());
           }
  -        
  +
           JellyContext newJellyContext = newJellyContext();
           newJellyContext.setRootURL( newJellyContextURL );
           newJellyContext.setCurrentURL( newJellyContextURL );
           newJellyContext.setExport( export );
           newJellyContext.setInherit( inherit );
  -            
  +
           if ( inherit ) {
               // use the same variable scopes
               newJellyContext.variables = this.variables;
  -        } 
  +        }
   
           if (log.isDebugEnabled() ) {
               log.debug( "About to run script: " + source.getSystemId() );
  @@ -689,13 +689,13 @@
           }
   
           script.run(newJellyContext, output);
  -        
  +
           return newJellyContext;
       }
   
       /**
        * Returns a URL for the given resource from the specified path.
  -     * If the uri starts with "/" then the path is taken as relative to 
  +     * If the uri starts with "/" then the path is taken as relative to
        * the current context root.
        * If the uri is a well formed URL then it is used.
        * If the uri is a file that exists and can be read then it is used.
  @@ -724,12 +724,12 @@
   
       /**
        * Attempts to open an InputStream to the given resource at the specified path.
  -     * If the uri starts with "/" then the path is taken as relative to 
  +     * If the uri starts with "/" then the path is taken as relative to
        * the current context root. If the uri is a well formed URL then it
        * is used. Otherwise the uri is interpreted as relative to the current
        * context (the location of the current script).
        *
  -     * @return null if this resource could not be loaded, otherwise the resources 
  +     * @return null if this resource could not be loaded, otherwise the resources
        *  input stream is returned.
        */
       public InputStream getResourceAsStream(String uri) {
  @@ -749,7 +749,7 @@
   
   
       // Properties
  -    //-------------------------------------------------------------------------                
  +    //-------------------------------------------------------------------------
   
       /**
        * @return the current root context URL from which all absolute resource URIs
  @@ -759,7 +759,7 @@
       public URL getRootURL() {
           return rootURL;
       }
  -    
  +
       /**
        * Sets the current root context URL from which all absolute resource URIs
        *  will be relative to. For example in a web application the root URL will
  @@ -768,32 +768,32 @@
       public void setRootURL(URL rootURL) {
           this.rootURL = rootURL;
       }
  -    
   
  -    /** 
  -     * @return the current URL context of the current script that is executing. 
  +
  +    /**
  +     * @return the current URL context of the current script that is executing.
        *  This URL context is used to deduce relative scripts when relative URIs are
        *  used in calls to {@link #getResource} to process relative scripts.
  -     */ 
  +     */
       public URL getCurrentURL() {
           return currentURL;
       }
  -    
  -    /** 
  -     * Sets the current URL context of the current script that is executing. 
  +
  +    /**
  +     * Sets the current URL context of the current script that is executing.
        *  This URL context is used to deduce relative scripts when relative URIs are
        *  used in calls to {@link #getResource} to process relative scripts.
  -     */ 
  -    public void setCurrentURL(URL currentURL) { 
  +     */
  +    public void setCurrentURL(URL currentURL) {
           this.currentURL = currentURL;
       }
  -    
  +
       /**
        * Returns whether caching of Tag instances, per thread, is enabled.
        * Caching Tags can boost performance, on some JVMs, by reducing the cost of
        * object construction when running Jelly inside a multi-threaded application server
        * such as a Servlet engine.
  -     * 
  +     *
        * @return whether caching of Tag instances is enabled.
        */
       public boolean isCacheTags() {
  @@ -805,13 +805,13 @@
        * Caching Tags can boost performance, on some JVMs, by reducing the cost of
        * object construction when running Jelly inside a multi-threaded application server
        * such as a Servlet engine.
  -     * 
  +     *
        * @param cacheTags Whether caching should be enabled or disabled.
        */
       public void setCacheTags(boolean cacheTags) {
           this.cacheTags = cacheTags;
       }
  -    
  +
       /**
        * Returns whether we export tag libraries to our parents context
        * @return boolean
  @@ -827,7 +827,7 @@
       public void setExportLibraries(boolean exportLibraries) {
           this.exportLibraries = exportLibraries;
       }
  -    
  +
   
       /**
        * Sets whether we should export variable definitions to our parent context
  @@ -880,7 +880,7 @@
           }
           return (this.getClass().getClassLoader());
       }
  -    
  +
       /**
        * Set the class loader to be used for instantiating application objects
        * when required.
  @@ -891,7 +891,7 @@
       public void setClassLoader(ClassLoader classLoader) {
           this.classLoader = classLoader;
       }
  -    
  +
       /**
        * Return the boolean as to whether the context classloader should be used.
        */
  @@ -911,10 +911,10 @@
       public void setUseContextClassLoader(boolean use) {
           useContextClassLoader = use;
       }
  -    
  +
   
       // Implementation methods
  -    //-------------------------------------------------------------------------                
  +    //-------------------------------------------------------------------------
       /**
        * @return a new relative URL from the given root and with the addition of the
        * extra relative URI
  @@ -936,7 +936,7 @@
           return new URL(urlText);
       }
   
  -    /** 
  +    /**
        * Strips off the name of a script to create a new context URL
        */
       protected URL getJellyContextURL(URL url) throws MalformedURLException {
  @@ -946,7 +946,7 @@
           return new URL(text);
       }
   
  -    /** 
  +    /**
        * Strips off the name of a script to create a new context URL
        */
       protected URL getJellyContextURL(InputSource source) throws MalformedURLException {
  
  
  
  1.4       +29 -29    jakarta-commons/jelly/src/java/org/apache/commons/jelly/expression/xpath/XPathExpression.java
  
  Index: XPathExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/expression/xpath/XPathExpression.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XPathExpression.java	24 Feb 2004 14:01:54 -0000	1.3
  +++ XPathExpression.java	8 Sep 2004 04:35:22 -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.
  @@ -37,7 +37,7 @@
     * @version $Revision$
     */
   public class XPathExpression extends ExpressionSupport implements VariableContext {
  -    
  +
       /** The Log to which logging calls will be made. */
       private Log log = LogFactory.getLog(XPathExpression.class);
   
  @@ -45,7 +45,7 @@
       private Expression xpathExpr;
       private JellyContext context;
       private Map uris;
  -    
  +
       public XPathExpression() {
       }
   
  @@ -54,37 +54,37 @@
                              TagScript tagScript) {
           this.text = text;
           this.xpathExpr = xpathExpr;
  -        
  +
           Map namespaceContext = tagScript.getNamespaceContext();
  -        
  +
           this.uris = createUriMap(namespaceContext);
       }
   
       public String toString() {
           return getExpressionText();
       }
  -            
  +
       // Expression interface
  -    //------------------------------------------------------------------------- 
  +    //-------------------------------------------------------------------------
       public String getExpressionText() {
           return this.text;
       }
  -    
  +
       public Object evaluate(JellyContext context) {
           this.context = context;
   
           try
           {
               XPath xpath = new Dom4jXPath( this.xpathExpr.evaluateAsString( context ) );
  -            
  +
               xpath.setVariableContext(this);
  -            
  +
               if (log.isDebugEnabled()) {
                   log.debug( "Setting the namespace context to be: " + uris );
               }
  -            
  +
               xpath.setNamespaceContext( new SimpleNamespaceContext( this.uris ) );
  -            
  +
               return xpath;
           }
           catch (JaxenException e)
  @@ -95,37 +95,37 @@
   
           return null;
       }
  -    
  +
       // VariableContext interface
  -    //------------------------------------------------------------------------- 
  +    //-------------------------------------------------------------------------
       public Object getVariableValue(
           String namespaceURI,
           String prefix,
           String localName) {
  -            
  +
           Object value = context.getVariable(localName);
  -        
  -        //log.debug( "Looking up XPath variable of name: " + localName + " value is: " + value );            
  -        
  +
  +        //log.debug( "Looking up XPath variable of name: " + localName + " value is: " + value );
  +
           return value;
       }
  -    
  +
       // Implementation methods
       //-------------------------------------------------------------------------
  -    
  +
       /**
        * Factory method to create a synchronized Map of non-null and non-blank
        * namespace prefixes to namespace URIs
  -     */ 
  +     */
       protected Map createUriMap(Map namespaceContext) {
           // now lets clone the Map but ignoring default or null prefixes
           Map uris = new Hashtable(namespaceContext.size());
           for (Iterator iter = namespaceContext.entrySet().iterator(); iter.hasNext(); ) {
  -        	Map.Entry entry = (Map.Entry) iter.next();
  -        	String prefix = (String) entry.getKey();
  -        	if (prefix != null && prefix.length() != 0) {
  -        		uris.put(prefix, entry.getValue());
  -        	}
  +            Map.Entry entry = (Map.Entry) iter.next();
  +            String prefix = (String) entry.getKey();
  +            if (prefix != null && prefix.length() != 0) {
  +                uris.put(prefix, entry.getValue());
  +            }
           }
           return uris;
       }
  
  
  
  1.7       +140 -140  jakarta-commons/jelly/src/java/org/apache/commons/jelly/servlet/JellyServlet.java
  
  Index: JellyServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/servlet/JellyServlet.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JellyServlet.java	24 Feb 2004 14:04:03 -0000	1.6
  +++ JellyServlet.java	8 Sep 2004 04:35:22 -0000	1.7
  @@ -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.
  @@ -35,74 +35,74 @@
   
   /**
    * Servlet for handling display of Jelly-fied XML files. Modelled after VelocityServlet.
  - * 
  + *
    * @author Kelvin Tan
    * @version $Revision$
    */
   public class JellyServlet extends HttpServlet {
  -	/**
  -	 * The HTTP request object context key.
  -	 */
  -	public static final String REQUEST = "request";
  -
  -	/**
  -	 * The HTTP response object context key.
  -	 */
  -	public static final String RESPONSE = "response";
  +    /**
  +     * The HTTP request object context key.
  +     */
  +    public static final String REQUEST = "request";
  +
  +    /**
  +     * The HTTP response object context key.
  +     */
  +    public static final String RESPONSE = "response";
   
       protected void doGet(
  -		HttpServletRequest request,
  -		HttpServletResponse response)
  -		throws ServletException, IOException {
  -
  -		doRequest(request, response);
  -	}
  -
  -	protected void doPost(
  -		HttpServletRequest request,
  -		HttpServletResponse response)
  -		throws ServletException, IOException {
  -
  -		doRequest(request, response);
  -	}
  -
  -	/**
  -	 * Handles all requests
  -	 * @param req HttpServletRequest object containing client request
  -	 * @param res HttpServletResponse object for the response
  -	 * @throws ServletException
  -	 * @throws IOException
  -	 */
  -	protected void doRequest(HttpServletRequest req, HttpServletResponse res)
  -		throws ServletException, IOException {
  +        HttpServletRequest request,
  +        HttpServletResponse response)
  +        throws ServletException, IOException {
  +
  +        doRequest(request, response);
  +    }
  +
  +    protected void doPost(
  +        HttpServletRequest request,
  +        HttpServletResponse response)
  +        throws ServletException, IOException {
  +
  +        doRequest(request, response);
  +    }
  +
  +    /**
  +     * Handles all requests
  +     * @param req HttpServletRequest object containing client request
  +     * @param res HttpServletResponse object for the response
  +     * @throws ServletException
  +     * @throws IOException
  +     */
  +    protected void doRequest(HttpServletRequest req, HttpServletResponse res)
  +        throws ServletException, IOException {
   
  -		JellyContext context = createContext(req, res);
  -		try {
  +        JellyContext context = createContext(req, res);
  +        try {
               URL script = getScript(req);
  -			runScript(script, context, req, res);
  -		}
  -		catch (Exception e) {
  -			error(req, res, e);
  -		}
  -	}
  -
  -	/**
  -	 * @see org.apache.velocity.servlet.VelocityServlet#createContext
  -	 * @param req
  -	 * @param res
  -	 * @return
  -	 */
  -	protected JellyContext createContext(
  -		HttpServletRequest req,
  -		HttpServletResponse res) {
  -
  -		JellyContext ctx = new JellyServletContext(getServletContext());
  -		ctx.setVariable(REQUEST, req);
  -		ctx.setVariable(RESPONSE, res);
  -		return ctx;
  -	}
  +            runScript(script, context, req, res);
  +        }
  +        catch (Exception e) {
  +            error(req, res, e);
  +        }
  +    }
   
  -	/**
  +    /**
  +     * @see org.apache.velocity.servlet.VelocityServlet#createContext
  +     * @param req
  +     * @param res
  +     * @return
  +     */
  +    protected JellyContext createContext(
  +        HttpServletRequest req,
  +        HttpServletResponse res) {
  +
  +        JellyContext ctx = new JellyServletContext(getServletContext());
  +        ctx.setVariable(REQUEST, req);
  +        ctx.setVariable(RESPONSE, res);
  +        return ctx;
  +    }
  +
  +    /**
        * <p>
        * Either use the query parameter "script", or the URI itself
        * to denote the script to run.
  @@ -111,86 +111,86 @@
        * Example: script=index.jelly or http://localhost:8080/foo/index.jelly.
        * </p>
        *
  -	 * @see org.apache.velocity.servlet.VelocityServlet#getTemplate
  -	 * @param req
  -	 * @return
  -	 * @throws MalformedURLException
  -	 */
  -	protected URL getScript(HttpServletRequest req)
  -		throws MalformedURLException {
  -
  -		String scriptUrl = req.getParameter("script");
  -		if (scriptUrl == null) {
  -			scriptUrl = req.getPathInfo();
  -		}
  -		URL url = getServletContext().getResource(scriptUrl);
  +     * @see org.apache.velocity.servlet.VelocityServlet#getTemplate
  +     * @param req
  +     * @return
  +     * @throws MalformedURLException
  +     */
  +    protected URL getScript(HttpServletRequest req)
  +        throws MalformedURLException {
  +
  +        String scriptUrl = req.getParameter("script");
  +        if (scriptUrl == null) {
  +            scriptUrl = req.getPathInfo();
  +        }
  +        URL url = getServletContext().getResource(scriptUrl);
           if (url == null) {
               throw new IllegalArgumentException("Invalid script url:" + scriptUrl);
           }
           return url;
  -	}
  +    }
  +
  +    /**
  +     * @see org.apache.velocity.servlet.VelocityServlet#mergeTemplate
  +     * @param script
  +     * @param context
  +     * @param req
  +     * @param res
  +     * @throws IOException
  +     * @throws UnsupportedEncodingException
  +     * @throws JellyException
  +     */
  +    protected void runScript(
  +        URL script,
  +        JellyContext context,
  +        HttpServletRequest req,
  +        HttpServletResponse res)
  +        throws IOException, UnsupportedEncodingException, JellyException {
  +
  +        ServletOutputStream output = res.getOutputStream();
  +        XMLOutput xmlOutput = XMLOutput.createXMLOutput(output);
  +        context.runScript(script, xmlOutput);
  +        xmlOutput.flush();
  +        xmlOutput.close();
  +        output.flush();
  +    }
  +
  +    /**
  +     * Invoked when there is an error thrown in any part of doRequest() processing.
  +     * <br><br>
  +     * Default will send a simple HTML response indicating there was a problem.
  +     *<br><br>
  +     * Ripped from VelocityServlet.
  +     *
  +     * @param request original HttpServletRequest from servlet container.
  +     * @param response HttpServletResponse object from servlet container.
  +     * @param cause  Exception that was thrown by some other part of process.
  +     */
  +    protected void error(
  +        HttpServletRequest request,
  +        HttpServletResponse response,
  +        Exception cause)
  +        throws ServletException, IOException {
  +
  +        StringBuffer html = new StringBuffer();
  +        html.append("<html>");
  +        html.append("<title>Error</title>");
  +        html.append("<body bgcolor=\"#ffffff\">");
  +        html.append("<h2>JellyServlet : Error processing the script</h2>");
  +        html.append("<pre>");
  +        String why = cause.getMessage();
  +        if (why != null && why.trim().length() > 0) {
  +            html.append(why);
  +            html.append("<br>");
  +        }
  +
  +        StringWriter sw = new StringWriter();
  +        cause.printStackTrace(new PrintWriter(sw));
   
  -	/**
  -	 * @see org.apache.velocity.servlet.VelocityServlet#mergeTemplate
  -	 * @param script
  -	 * @param context
  -	 * @param req
  -	 * @param res
  -	 * @throws IOException
  -	 * @throws UnsupportedEncodingException
  -	 * @throws JellyException
  -	 */
  -	protected void runScript(
  -		URL script,
  -		JellyContext context,
  -		HttpServletRequest req,
  -		HttpServletResponse res)
  -		throws IOException, UnsupportedEncodingException, JellyException {
  -
  -		ServletOutputStream output = res.getOutputStream();
  -		XMLOutput xmlOutput = XMLOutput.createXMLOutput(output);
  -		context.runScript(script, xmlOutput);
  -		xmlOutput.flush();
  -		xmlOutput.close();
  -		output.flush();
  -	}
  -
  -	/**
  -	 * Invoked when there is an error thrown in any part of doRequest() processing.
  -	 * <br><br>
  -	 * Default will send a simple HTML response indicating there was a problem.
  -	 *<br><br>
  -	 * Ripped from VelocityServlet.
  -	 *
  -	 * @param request original HttpServletRequest from servlet container.
  -	 * @param response HttpServletResponse object from servlet container.
  -	 * @param cause  Exception that was thrown by some other part of process.
  -	 */
  -	protected void error(
  -		HttpServletRequest request,
  -		HttpServletResponse response,
  -		Exception cause)
  -		throws ServletException, IOException {
  -
  -		StringBuffer html = new StringBuffer();
  -		html.append("<html>");
  -		html.append("<title>Error</title>");
  -		html.append("<body bgcolor=\"#ffffff\">");
  -		html.append("<h2>JellyServlet : Error processing the script</h2>");
  -		html.append("<pre>");
  -		String why = cause.getMessage();
  -		if (why != null && why.trim().length() > 0) {
  -			html.append(why);
  -			html.append("<br>");
  -		}
  -
  -		StringWriter sw = new StringWriter();
  -		cause.printStackTrace(new PrintWriter(sw));
  -
  -		html.append(sw.toString());
  -		html.append("</pre>");
  -		html.append("</body>");
  -		html.append("</html>");
  -		response.getOutputStream().print(html.toString());
  -	}
  +        html.append(sw.toString());
  +        html.append("</pre>");
  +        html.append("</body>");
  +        html.append("</html>");
  +        response.getOutputStream().print(html.toString());
  +    }
   }
  
  
  

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


Mime
View raw message