cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation XPathDirectoryGenerator.java
Date Fri, 07 Nov 2003 13:00:17 GMT
giacomo     2003/11/07 05:00:17

  Modified:    src/java/org/apache/cocoon/generation
                        XPathDirectoryGenerator.java
  Log:
  missed one case of NPE
  
  Revision  Changes    Path
  1.6       +29 -19    cocoon-2.1/src/java/org/apache/cocoon/generation/XPathDirectoryGenerator.java
  
  Index: XPathDirectoryGenerator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/XPathDirectoryGenerator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -d -b -u -r1.5 -r1.6
  --- XPathDirectoryGenerator.java	7 Nov 2003 09:37:13 -0000	1.5
  +++ XPathDirectoryGenerator.java	7 Nov 2003 13:00:17 -0000	1.6
  @@ -94,18 +94,21 @@
    * resource. A <code>nsmapping</code> parameter can be specified to point to
a file containing lines to map prefixes
    * to namespaces like this:
    * </p>
  + * 
    * <p>
  - *  prefix=namespace-uri<br/>
  - *  prefix2=namespace-uri-2
  + * prefix=namespace-uri<br/> prefix2=namespace-uri-2
    * </p>
  + * 
    * <p>
    * A parameter <code>nsmapping-reload</code> specifies if the prefix-2-namespace
mapping file should be checked to be
    * reloaded on each request to this generator if it was modified since the last time it
was read. 
    * </p>
  + * 
    * <p>
    * An additional parameter <code>xmlFiles</code> can be set in the sitemap
setting the regular expression pattern for 
    * determining if a file should be handled as XML file or not. The default value for this
param is 
  - * <code>\.xml$</code>, so that it * matches all files ending <code>.xml</code>.
  + * <code>\.xml$</code>, so that it  matches all files ending <code>.xml</code>.
  + * </p>
    * 
    * <p></p>
    * <br>Sample usage: <br><br>Sitemap:
  @@ -249,11 +252,10 @@
   
               if ((null == mappingInfo) || (mappingInfo.reload == false) ||
                   (mappingInfo.mappingSource.getLastModified() < mappingSource.getLastModified()))
{
  -                this.prefixResolver = new MappingInfo(getLogger().getChildLogger( "prefix-resolver"
), mappingSource, mapping_reload);
  +                this.prefixResolver =
  +                    new MappingInfo(getLogger().getChildLogger("prefix-resolver"), mappingSource,
mapping_reload);
                   XPathDirectoryGenerator.mappingFiles.put(mappingKey, this.prefixResolver);
  -            }
  -            else
  -            {
  +            } else {
               	this.prefixResolver = mappingInfo;
               }
           }
  @@ -311,7 +313,10 @@
           }
   
           if (doc != null) {
  -            NodeList nl = this.processor.selectNodeList(this.doc.getDocumentElement(),
this.xpath,this.prefixResolver);
  +            NodeList nl =
  +                (null == this.prefixResolver)
  +                ? this.processor.selectNodeList(this.doc.getDocumentElement(), this.xpath)
  +                : this.processor.selectNodeList(this.doc.getDocumentElement(), this.xpath,
this.prefixResolver);
               AttributesImpl attributes = new AttributesImpl();
               attributes.addAttribute("", QUERY_ATTR_NAME, QUERY_ATTR_NAME, "CDATA", xpath);
               super.contentHandler.startElement(URI, XPATH_NODE_NAME, PREFIX + ":" + XPATH_NODE_NAME,
attributes);
  @@ -357,15 +362,16 @@
           /** Whether to reload if mapping file has changed */
           public final boolean reload;
   
  -        /** Map of prefixes to namespaces */
  -        private final Map prefixMap;
  -
           /** Our Logger */
           private final Logger logger;
   
  +        /** Map of prefixes to namespaces */
  +        private final Map prefixMap;
  +
           /**
            * Creates a new MappingInfo object.
            *
  +         * @param logger DOCUMENT ME!
            * @param mappingSource The Source of the mapping file
            * @param reload Whether to reload if mapping file has changed
            *
  @@ -388,7 +394,7 @@
                       final String prefix = line.substring(0, i);
                       final String namespace = line.substring(i + 1);
                       prefixMap.put(prefix, namespace);
  -                    logger.debug( "added mapping: '" + prefix + "'='" + namespace + "'"
);
  +                    logger.debug("added mapping: '" + prefix + "'='" + namespace + "'");
                   }
               }
           }
  @@ -398,7 +404,11 @@
            */
           public String prefixToNamespace(String prefix) {
               final String namespace = (String)this.prefixMap.get(prefix);
  -            logger.debug( "have to resolve prefix='" + prefix + ", found namespace='" +
namespace + "'" );
  +
  +            if (logger.isDebugEnabled()) {
  +                logger.debug("have to resolve prefix='" + prefix + ", found namespace='"
+ namespace + "'");
  +            }
  +
               return namespace;
           }
       }
  
  
  

Mime
View raw message