Clover coverage report - Cactus 1.5 for J2EE API 1.3
Coverage timestamp: Wed Feb 18 2004 09:09:13 EST
file stats: LOC: 1,210   Methods: 49
NCLOC: 721   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
WebXml.java 74.7% 90.5% 100% 86.4%
coverage coverage
 1   
 /*
 2   
  * ====================================================================
 3   
  *
 4   
  * The Apache Software License, Version 1.1
 5   
  *
 6   
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
 7   
  * reserved.
 8   
  *
 9   
  * Redistribution and use in source and binary forms, with or without
 10   
  * modification, are permitted provided that the following conditions
 11   
  * are met:
 12   
  *
 13   
  * 1. Redistributions of source code must retain the above copyright
 14   
  *    notice, this list of conditions and the following disclaimer.
 15   
  *
 16   
  * 2. Redistributions in binary form must reproduce the above copyright
 17   
  *    notice, this list of conditions and the following disclaimer in
 18   
  *    the documentation and/or other materials provided with the
 19   
  *    distribution.
 20   
  *
 21   
  * 3. The end-user documentation included with the redistribution, if
 22   
  *    any, must include the following acknowlegement:
 23   
  *       "This product includes software developed by the
 24   
  *        Apache Software Foundation (http://www.apache.org/)."
 25   
  *    Alternately, this acknowlegement may appear in the software itself,
 26   
  *    if and wherever such third-party acknowlegements normally appear.
 27   
  *
 28   
  * 4. The names "The Jakarta Project", "Cactus" and "Apache Software
 29   
  *    Foundation" must not be used to endorse or promote products
 30   
  *    derived from this software without prior written permission. For
 31   
  *    written permission, please contact apache@apache.org.
 32   
  *
 33   
  * 5. Products derived from this software may not be called "Apache"
 34   
  *    nor may "Apache" appear in their names without prior written
 35   
  *    permission of the Apache Group.
 36   
  *
 37   
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 38   
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 39   
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 40   
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 41   
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 42   
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 43   
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 44   
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 45   
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 46   
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 47   
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 48   
  * SUCH DAMAGE.
 49   
  * ====================================================================
 50   
  *
 51   
  * This software consists of voluntary contributions made by many
 52   
  * individuals on behalf of the Apache Software Foundation.  For more
 53   
  * information on the Apache Software Foundation, please see
 54   
  * <http://www.apache.org/>.
 55   
  *
 56   
  */
 57   
 package org.apache.cactus.integration.ant.deployment;
 58   
 
 59   
 import java.util.ArrayList;
 60   
 import java.util.Iterator;
 61   
 import java.util.List;
 62   
 
 63   
 import org.w3c.dom.Document;
 64   
 import org.w3c.dom.DocumentType;
 65   
 import org.w3c.dom.Element;
 66   
 import org.w3c.dom.Node;
 67   
 import org.w3c.dom.NodeList;
 68   
 
 69   
 /**
 70   
  * Encapsulates the DOM representation of a web deployment descriptor 
 71   
  * <code>web.xml</code> to provide convenience methods for easy access and 
 72   
  * manipulation.
 73   
  *
 74   
  * @author <a href="mailto:cmlenz@apache.org">Christopher Lenz</a>
 75   
  * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
 76   
  *
 77   
  * @since Cactus 1.5
 78   
  * @version $Id: WebXml.java,v 1.9 2003/07/01 19:24:35 cmlenz Exp $
 79   
  */
 80   
 public class WebXml
 81   
 {
 82   
     
 83   
     // Private Constants -------------------------------------------------------
 84   
     
 85   
     /**
 86   
      * Specifies the order in which the top-level elements must appear in the
 87   
      * descriptor, according to the DTD.
 88   
      */
 89   
     private static final WebXmlTag[] ELEMENT_ORDER = {
 90   
         WebXmlTag.ICON,
 91   
         WebXmlTag.DISPLAY_NAME,
 92   
         WebXmlTag.DESCRIPTION,
 93   
         WebXmlTag.DISTRIBUTABLE,
 94   
         WebXmlTag.FILTER,
 95   
         WebXmlTag.FILTER_MAPPING,
 96   
         WebXmlTag.LISTENER,
 97   
         WebXmlTag.SERVLET,
 98   
         WebXmlTag.SERVLET_MAPPING,
 99   
         WebXmlTag.SESSION_CONFIG,
 100   
         WebXmlTag.MIME_MAPPING,
 101   
         WebXmlTag.WELCOME_FILE_LIST,
 102   
         WebXmlTag.ERROR_PAGE,
 103   
         WebXmlTag.TAGLIB,
 104   
         WebXmlTag.RESOURCE_ENV_REF,
 105   
         WebXmlTag.RESOURCE_REF,
 106   
         WebXmlTag.SECURITY_CONSTRAINT,
 107   
         WebXmlTag.LOGIN_CONFIG,
 108   
         WebXmlTag.SECURITY_ROLE,
 109   
         WebXmlTag.ENV_ENTRY,
 110   
         WebXmlTag.EJB_REF,
 111   
         WebXmlTag.EJB_LOCAL_REF,
 112   
     };
 113   
     
 114   
     // Instance Variables ------------------------------------------------------
 115   
     
 116   
     /**
 117   
      * The DOM representation of the deployment descriptor.
 118   
      */
 119   
     private final Document document;
 120   
     
 121   
     /**
 122   
      * The root element of the descriptor.
 123   
      */
 124   
     private final Element rootElement;
 125   
     
 126   
     // Constructors ------------------------------------------------------------
 127   
     
 128   
     /**
 129   
      * Constructor.
 130   
      * 
 131   
      * @param theDocument The DOM document representing the parsed deployment
 132   
      *         descriptor
 133   
      */
 134  135
     public WebXml(Document theDocument)
 135   
     {
 136  135
         this.document = theDocument;
 137  135
         this.rootElement = theDocument.getDocumentElement();
 138   
     }
 139   
     
 140   
     // Public Methods ----------------------------------------------------------
 141   
     
 142   
     /**
 143   
      * Returns the DOM document representing the deployment descriptor. The 
 144   
      * document will contain any modifications made through this instance.
 145   
      * 
 146   
      * @return The document representing the deploy descriptor
 147   
      */
 148  32
     public final Document getDocument()
 149   
     {
 150  32
         return this.document;
 151   
     }
 152   
     
 153   
     /**
 154   
      * Returns the servlet API version.
 155   
      * 
 156   
      * @return The version
 157   
      */
 158  26
     public final WebXmlVersion getVersion()
 159   
     {
 160  26
         DocumentType docType = this.document.getDoctype();
 161  26
         if (docType != null)
 162   
         {
 163  21
             return WebXmlVersion.valueOf(docType);
 164   
         }
 165  5
         return null;
 166   
     }
 167   
 
 168   
     /**
 169   
      * Adds a new servlet filter to the descriptor.
 170   
      * 
 171   
      * @param theFilterName The name of the filter to add
 172   
      * @param theFilterClass The name of the class implementing the filter
 173   
      */
 174  11
     public final void addFilter(String theFilterName, String theFilterClass)
 175   
     {
 176  11
         if (theFilterName == null)
 177   
         {
 178  0
             throw new NullPointerException();
 179   
         }
 180  11
         if (hasFilter(theFilterName))
 181   
         {
 182  0
             throw new IllegalStateException("Filter '" + theFilterName
 183   
                 + "' already defined");
 184   
         }
 185  11
         Element filterElement =
 186   
             this.document.createElement(WebXmlTag.FILTER.getTagName());
 187  11
         filterElement.appendChild(
 188   
             createNestedText(WebXmlTag.FILTER_NAME, theFilterName));
 189  11
         filterElement.appendChild(
 190   
             createNestedText(WebXmlTag.FILTER_CLASS, theFilterClass));
 191  11
         addElement(WebXmlTag.FILTER, filterElement);
 192   
     }
 193   
     
 194   
     /**
 195   
      * Adds a new servlet filter to the descriptor.
 196   
      * 
 197   
      * @param theFilter The element representing the filter definition
 198   
      */
 199  13
     public final void addFilter(Element theFilter)
 200   
     {
 201  13
         checkElement(theFilter, WebXmlTag.FILTER);
 202  13
         String filterName = getNestedText(theFilter, WebXmlTag.FILTER_NAME);
 203  13
         if (filterName == null)
 204   
         {
 205  0
             throw new IllegalArgumentException("Not a valid filter element");
 206   
         }
 207  13
         if (hasFilter(filterName))
 208   
         {
 209  1
             throw new IllegalStateException("Filter '" + filterName
 210   
                 + "' already defined");
 211   
         }
 212  12
         addElement(WebXmlTag.FILTER, theFilter);
 213   
     }
 214   
     
 215   
     /**
 216   
      * Adds an initialization parameter to the specified filter.
 217   
      * 
 218   
      * @param theFilterName The name of the filter
 219   
      * @param theParamName The name of the parameter
 220   
      * @param theParamValue The parameter value
 221   
      */
 222  5
     public final void addFilterInitParam(String theFilterName,
 223   
         String theParamName, String theParamValue)
 224   
     {
 225  5
         Element filterElement = getFilter(theFilterName);
 226  5
         if (filterElement == null)
 227   
         {
 228  0
             throw new IllegalStateException("Filter '" + theFilterName
 229   
                 + "' not defined");
 230   
         }
 231  5
         addInitParam(filterElement, theParamName, theParamValue);
 232   
     }
 233   
     
 234   
     /**
 235   
      * Adds a filter mapping to the descriptor.
 236   
      * 
 237   
      * @param theFilterName The name of the filter
 238   
      * @param theUrlPattern The URL pattern the filter should be mapped to
 239   
      */
 240  15
     public final void addFilterMapping(String theFilterName,
 241   
         String theUrlPattern)
 242   
     {
 243  15
         if (!hasFilter(theFilterName))
 244   
         {
 245  0
             throw new IllegalStateException("Filter '" + theFilterName
 246   
                 + "' not defined");
 247   
         }
 248  15
         Element filterMappingElement =
 249   
             this.document.createElement(WebXmlTag.FILTER_MAPPING.getTagName());
 250  15
         filterMappingElement.appendChild(
 251   
             createNestedText(WebXmlTag.FILTER_NAME, theFilterName));
 252  15
         filterMappingElement.appendChild(
 253   
             createNestedText(WebXmlTag.URL_PATTERN,  theUrlPattern));
 254  15
         addElement(WebXmlTag.FILTER_MAPPING, filterMappingElement);
 255   
     }
 256   
     
 257   
     /**
 258   
      * Returns the element that contains the definition of a specific servlet
 259   
      * filter, or <code>null</code> if a filter of the specified name is not
 260   
      * defined in the descriptor.
 261   
      * 
 262   
      * @param theFilterName The name of the servlet filter
 263   
      * @return The DOM element representing the filter definition
 264   
      */
 265  106
     public final Element getFilter(String theFilterName)
 266   
     {
 267  106
         if (theFilterName == null)
 268   
         {
 269  1
             throw new NullPointerException();
 270   
         }
 271  105
         Iterator filterElements = getElements(WebXmlTag.FILTER);
 272  105
         while (filterElements.hasNext())
 273   
         {
 274  93
             Element filterElement = (Element) filterElements.next();
 275  93
             if (theFilterName.equals(getNestedText(
 276   
                 filterElement, WebXmlTag.FILTER_NAME)))
 277   
             {
 278  54
                 return filterElement;
 279   
             }
 280   
         }
 281  51
         return null;
 282   
     }
 283   
     
 284   
     /**
 285   
      * Returns a list of names of filters that are mapped to the specified
 286   
      * class.
 287   
      * 
 288   
      * @param theClassName The fully qualified name of the filter class
 289   
      * @return An iterator over the names of the filters mapped to the class
 290   
      */
 291  10
     public final Iterator getFilterNamesForClass(String theClassName)
 292   
     {
 293  10
         if (theClassName == null)
 294   
         {
 295  0
             throw new NullPointerException();
 296   
         }
 297  10
         Iterator filterElements = getElements(WebXmlTag.FILTER);
 298  10
         List filterNames = new ArrayList();
 299  10
         while (filterElements.hasNext())
 300   
         {
 301  7
             Element filterElement = (Element) filterElements.next();
 302  7
             if (theClassName.equals(getNestedText(
 303   
                 filterElement, WebXmlTag.FILTER_CLASS)))
 304   
             {
 305  6
                 filterNames.add(getNestedText(
 306   
                     filterElement, WebXmlTag.FILTER_NAME));
 307   
             }
 308   
         }
 309  10
         return filterNames.iterator();
 310   
     }
 311   
     
 312   
     /**
 313   
      * Returns the value of an initialization parameter of the specified filter.
 314   
      * 
 315   
      * @param theFilterName The name of the servlet filter
 316   
      * @param theParamName The name of the initialization parameter
 317   
      * @return The parameter value
 318   
      */
 319  1
     public final String getFilterInitParam(String theFilterName,
 320   
         String theParamName)
 321   
     {
 322  1
         return getInitParam(getFilter(theFilterName), theParamName);
 323   
     }
 324   
     
 325   
     /**
 326   
      * Returns the names of the initialization parameters of the specified 
 327   
      * servlet filter.
 328   
      * 
 329   
      * @param theFilterName The name of the servlet filter of which the
 330   
      *         parameter names should be retrieved
 331   
      * @return An iterator over the ordered list of parameter names
 332   
      */
 333  5
     public final Iterator getFilterInitParamNames(String theFilterName)
 334   
     {
 335  5
         return getInitParamNames(getFilter(theFilterName));
 336   
     }
 337   
     
 338   
     /**
 339   
      * Returns the URL-patterns that the specified filter is mapped to in an
 340   
      * ordered list. If there are no mappings for the specified filter, an
 341   
      * iterator over an empty list is returned.
 342   
      * 
 343   
      * @param theFilterName The name of the servlet filter of which the 
 344   
      *         mappings should be retrieved
 345   
      * @return An iterator over the ordered list of URL-patterns
 346   
      */
 347  20
     public final Iterator getFilterMappings(String theFilterName)
 348   
     {
 349  20
         if (theFilterName == null)
 350   
         {
 351  0
             throw new NullPointerException();
 352   
         }
 353  20
         List filterMappings = new ArrayList();
 354  20
         Iterator filterMappingElements = getElements(WebXmlTag.FILTER_MAPPING);
 355  20
         while (filterMappingElements.hasNext())
 356   
         {
 357  20
             Element filterMappingElement = (Element)
 358   
                 filterMappingElements.next();
 359  20
             if (theFilterName.equals(getNestedText(
 360   
                 filterMappingElement, WebXmlTag.FILTER_NAME)))
 361   
             {
 362  18
                 String urlPattern = getNestedText(
 363   
                     filterMappingElement, WebXmlTag.URL_PATTERN);
 364  18
                 if (urlPattern != null)
 365   
                 {
 366  18
                     filterMappings.add(urlPattern);
 367   
                 }
 368   
             }
 369   
         }
 370  20
         return filterMappings.iterator();
 371   
     }
 372   
     
 373   
     /**
 374   
      * Returns the names of all filters defined in the deployment descriptor.
 375   
      * The names are returned as an iterator over an ordered list.
 376   
      * 
 377   
      * @return The filter names
 378   
      */
 379  14
     public final Iterator getFilterNames()
 380   
     {
 381  14
         List filterNames = new ArrayList();
 382  14
         Iterator filterElements = getElements(WebXmlTag.FILTER);
 383  14
         while (filterElements.hasNext())
 384   
         {
 385  20
             Element filterElement = (Element) filterElements.next();
 386  20
             String filterName =
 387   
                 getNestedText(filterElement, WebXmlTag.FILTER_NAME);
 388  20
             if (filterName != null)
 389   
             {
 390  20
                 filterNames.add(filterName);
 391   
             }
 392   
         }
 393  14
         return filterNames.iterator();
 394   
     }
 395   
     
 396   
     /**
 397   
      * Returns whether a servlet filter by the specified name is defined in the 
 398   
      * deployment descriptor.
 399   
      * 
 400   
      * @param theFilterName The name of the filter
 401   
      * @return <code>true</code> if the filter is defined, <code>false</code>
 402   
      *          otherwise
 403   
      */
 404  86
     public final boolean hasFilter(String theFilterName)
 405   
     {
 406  86
         return (getFilter(theFilterName) != null);
 407   
     }
 408   
     
 409   
     /**
 410   
      * Adds a mapped JSP file to the descriptor.
 411   
      * 
 412   
      * @param theServletName The name of the servlet to add
 413   
      * @param theJspFile The path to the JSP file relative to the root of the
 414   
      *        web application
 415   
      */
 416  18
     public final void addJspFile(String theServletName, String theJspFile)
 417   
     {
 418  18
         if (theServletName == null)
 419   
         {
 420  0
             throw new NullPointerException();
 421   
         }
 422  18
         if (hasFilter(theServletName))
 423   
         {
 424  0
             throw new IllegalStateException("Servlet '" + theServletName
 425   
                 + "' already defined");
 426   
         }
 427  18
         Element servletElement =
 428   
             this.document.createElement(WebXmlTag.SERVLET.getTagName());
 429  18
         servletElement.appendChild(
 430   
             createNestedText(WebXmlTag.SERVLET_NAME, theServletName));
 431  18
         servletElement.appendChild(
 432   
             createNestedText(WebXmlTag.JSP_FILE, theJspFile));
 433  18
         addElement(WebXmlTag.SERVLET, servletElement);
 434   
     }
 435   
     
 436   
     /**
 437   
      * Adds a new servlet to the descriptor.
 438   
      * 
 439   
      * @param theServletName The name of the servlet to add
 440   
      * @param theServletClass The name of the class implementing the servlet
 441   
      */
 442  19
     public final void addServlet(String theServletName, String theServletClass)
 443   
     {
 444  19
         if (theServletName == null)
 445   
         {
 446  0
             throw new NullPointerException();
 447   
         }
 448  19
         if (hasServlet(theServletName))
 449   
         {
 450  0
             throw new IllegalStateException("Servlet '" + theServletName
 451   
                 + "' already defined");
 452   
         }
 453  19
         Element servletElement =
 454   
             this.document.createElement(WebXmlTag.SERVLET.getTagName());
 455  19
         servletElement.appendChild(
 456   
             createNestedText(WebXmlTag.SERVLET_NAME, theServletName));
 457  19
         servletElement.appendChild(
 458   
             createNestedText(WebXmlTag.SERVLET_CLASS, theServletClass));
 459  19
         addElement(WebXmlTag.SERVLET, servletElement);
 460   
     }
 461   
     
 462   
     /**
 463   
      * Adds a new servlet to the descriptor.
 464   
      * 
 465   
      * @param theServlet The element representing the servlet definition
 466   
      */
 467  13
     public final void addServlet(Element theServlet)
 468   
     {
 469  13
         checkElement(theServlet, WebXmlTag.SERVLET);
 470  13
         String servletName = getNestedText(theServlet, WebXmlTag.SERVLET_NAME);
 471  13
         if (servletName == null)
 472   
         {
 473  0
             throw new IllegalArgumentException("Not a valid servlet element");
 474   
         }
 475  13
         if (hasServlet(servletName))
 476   
         {
 477  1
             throw new IllegalStateException("Servlet '" + servletName
 478   
                 + "' already defined");
 479   
         }
 480  12
         addElement(WebXmlTag.SERVLET, theServlet);
 481   
     }
 482   
     
 483   
     /**
 484   
      * Adds an initialization parameter to the specified servlet.
 485   
      * 
 486   
      * @param theServletName The name of the filter
 487   
      * @param theParamName The name of the parameter
 488   
      * @param theParamValue The parameter value
 489   
      */
 490  6
     public final void addServletInitParam(String theServletName,
 491   
         String theParamName, String theParamValue)
 492   
     {
 493  6
         Element servletElement = getServlet(theServletName);
 494  6
         if (servletElement == null)
 495   
         {
 496  0
             throw new IllegalStateException("Servlet '" + theServletName
 497   
                 + "' not defined");
 498   
         }
 499  6
         addInitParam(servletElement, theParamName, theParamValue);
 500   
     }
 501   
     
 502   
     /**
 503   
      * Adds a servlet mapping to the descriptor.
 504   
      * 
 505   
      * @param theServletName The name of the servlet
 506   
      * @param theUrlPattern The URL pattern the servlet should be mapped to
 507   
      */
 508  38
     public final void addServletMapping(String theServletName,
 509   
         String theUrlPattern)
 510   
     {
 511  38
         if (!hasServlet(theServletName))
 512   
         {
 513  0
             throw new IllegalStateException("Servlet '" + theServletName
 514   
                 + "' not defined");
 515   
         }
 516  38
         Element servletMappingElement =
 517   
             this.document.createElement(WebXmlTag.SERVLET_MAPPING.getTagName());
 518  38
         servletMappingElement.appendChild(
 519   
             createNestedText(WebXmlTag.SERVLET_NAME, theServletName));
 520  38
         servletMappingElement.appendChild(
 521   
             createNestedText(WebXmlTag.URL_PATTERN, theUrlPattern));
 522  38
         addElement(WebXmlTag.SERVLET_MAPPING, servletMappingElement);
 523   
     }
 524   
     
 525   
     /**
 526   
      * Returns the element that contains the definition of a specific servlet, 
 527   
      * or <code>null</code> if a servlet of the specified name is not defined
 528   
      * in the descriptor.
 529   
      * 
 530   
      * @param theServletName The name of the servlet
 531   
      * @return The DOM element representing the servlet definition
 532   
      */
 533  131
     public final Element getServlet(String theServletName)
 534   
     {
 535  131
         if (theServletName == null)
 536   
         {
 537  1
             throw new NullPointerException();
 538   
         }
 539  130
         Iterator servletElements = getElements(WebXmlTag.SERVLET);
 540  130
         while (servletElements.hasNext())
 541   
         {
 542  142
             Element servletElement = (Element) servletElements.next();
 543  142
             if (theServletName.equals(getNestedText(
 544   
                 servletElement, WebXmlTag.SERVLET_NAME)))
 545   
             {
 546  89
                 return servletElement;
 547   
             }
 548   
         }
 549  41
         return null;
 550   
     }
 551   
     
 552   
     /**
 553   
      * Returns the value of an initialization parameter of the specified
 554   
      * servlet.
 555   
      * 
 556   
      * @param theServletName The name of the servlet
 557   
      * @param theParamName The name of the initialization parameter
 558   
      * @return The parameter value
 559   
      */
 560  3
     public final String getServletInitParam(String theServletName,
 561   
         String theParamName)
 562   
     {
 563  3
         return getInitParam(getServlet(theServletName), theParamName);
 564   
     }
 565   
     
 566   
     /**
 567   
      * Returns the names of the initialization parameters of the specified 
 568   
      * servlet.
 569   
      * 
 570   
      * @param theServletName The name of the servlet of which the parameter
 571   
      *         names should be retrieved
 572   
      * @return An iterator over the ordered list of parameter names
 573   
      */
 574  6
     public final Iterator getServletInitParamNames(String theServletName)
 575   
     {
 576  6
         return getInitParamNames(getServlet(theServletName));
 577   
     }
 578   
     
 579   
     /**
 580   
      * Returns the URL-patterns that the specified servlet is mapped to in an
 581   
      * ordered list. If there are no mappings for the specified servlet, an
 582   
      * iterator over an empty list is returned.
 583   
      * 
 584   
      * @param theServletName The name of the servlet of which the mappings
 585   
      *         should be retrieved
 586   
      * @return An iterator over the ordered list of URL-patterns
 587   
      */
 588  37
     public final Iterator getServletMappings(String theServletName)
 589   
     {
 590  37
         if (theServletName == null)
 591   
         {
 592  0
             throw new NullPointerException();
 593   
         }
 594  37
         List servletMappings = new ArrayList();
 595  37
         Iterator servletMappingElements =
 596   
             getElements(WebXmlTag.SERVLET_MAPPING);
 597  37
         while (servletMappingElements.hasNext())
 598   
         {
 599  55
             Element servletMappingElement = (Element)
 600   
                 servletMappingElements.next();
 601  55
             if (theServletName.equals(getNestedText(
 602   
                 servletMappingElement, WebXmlTag.SERVLET_NAME)))
 603   
             {
 604  34
                 String urlPattern = getNestedText(
 605   
                     servletMappingElement, WebXmlTag.URL_PATTERN);
 606  34
                 if (urlPattern != null)
 607   
                 {
 608  34
                     servletMappings.add(urlPattern);
 609   
                 }
 610   
             }
 611   
         }
 612  37
         return servletMappings.iterator();
 613   
     }
 614   
     
 615   
     /**
 616   
      * Returns the names of all servlets defined in the deployment descriptor.
 617   
      * The names are returned as an iterator over an ordered list.
 618   
      * 
 619   
      * @return The servlet names
 620   
      */
 621  12
     public final Iterator getServletNames()
 622   
     {
 623  12
         List servletNames = new ArrayList();
 624  12
         Iterator servletElements = getElements(WebXmlTag.SERVLET);
 625  12
         while (servletElements.hasNext())
 626   
         {
 627  21
             Element servletElement = (Element) servletElements.next();
 628  21
             String servletName =
 629   
                 getNestedText(servletElement, WebXmlTag.SERVLET_NAME);
 630  21
             if (servletName != null)
 631   
             {
 632  21
                 servletNames.add(servletName);
 633   
             }
 634   
         }
 635  12
         return servletNames.iterator();
 636   
     }
 637   
     
 638   
     /**
 639   
      * Returns a list of names of servlets that are mapped to the specified
 640   
      * class.
 641   
      * 
 642   
      * @param theClassName The fully qualified name of the servlet class
 643   
      * @return An iterator over the names of the servlets mapped to the class
 644   
      */
 645  15
     public final Iterator getServletNamesForClass(String theClassName)
 646   
     {
 647  15
         if (theClassName == null)
 648   
         {
 649  0
             throw new NullPointerException();
 650   
         }
 651  15
         Iterator servletElements = getElements(WebXmlTag.SERVLET);
 652  15
         List servletNames = new ArrayList();
 653  15
         while (servletElements.hasNext())
 654   
         {
 655  21
             Element servletElement = (Element) servletElements.next();
 656  21
             if (theClassName.equals(getNestedText(
 657   
                 servletElement, WebXmlTag.SERVLET_CLASS)))
 658   
             {
 659  14
                 servletNames.add(getNestedText(
 660   
                     servletElement, WebXmlTag.SERVLET_NAME));
 661   
             }
 662   
         }
 663  15
         return servletNames.iterator();
 664   
     }
 665   
     
 666   
     /**
 667   
      * Returns a list of names of servlets that are mapped to the specified
 668   
      * JSP file.
 669   
      * 
 670   
      * @param theJspFile The path to the JSP file, relative to the root of the
 671   
      *        web-application
 672   
      * @return An iterator over the names of the servlets mapped to the JSP file
 673   
      */
 674  8
     public final Iterator getServletNamesForJspFile(String theJspFile)
 675   
     {
 676  8
         if (theJspFile == null)
 677   
         {
 678  0
             throw new NullPointerException();
 679   
         }
 680  8
         Iterator servletElements = getElements(WebXmlTag.SERVLET);
 681  8
         List servletNames = new ArrayList();
 682  8
         while (servletElements.hasNext())
 683   
         {
 684  16
             Element servletElement = (Element) servletElements.next();
 685  16
             if (theJspFile.equals(getNestedText(
 686   
                 servletElement, WebXmlTag.JSP_FILE)))
 687   
             {
 688  8
                 servletNames.add(getNestedText(
 689   
                     servletElement, WebXmlTag.SERVLET_NAME));
 690   
             }
 691   
         }
 692  8
         return servletNames.iterator();
 693   
     }
 694   
     
 695   
     /**
 696   
      * Returns whether a servlet by the specified name is defined in the 
 697   
      * deployment descriptor.
 698   
      * 
 699   
      * @param theServletName The name of the servlet
 700   
      * @return <code>true</code> if the servlet is defined, <code>false</code>
 701   
      *          otherwise
 702   
      */
 703  106
     public final boolean hasServlet(String theServletName)
 704   
     {
 705  106
         return (getServlet(theServletName) != null);
 706   
     }
 707   
     
 708   
     /**
 709   
      * Creates and adds a security-constraint to the descriptor.
 710   
      * 
 711   
      * @param theWebResourceName The name of the web resource collection to
 712   
      *        protect
 713   
      * @param theUrlPattern The URL pattern to apply the constraint to
 714   
      * @param theRoles The list of authorized roles
 715   
      */
 716  4
     public final void addSecurityConstraint(String theWebResourceName,
 717   
         String theUrlPattern, List theRoles)
 718   
     {
 719  4
         if ((theWebResourceName == null) || (theUrlPattern == null)
 720   
          || (theRoles == null))
 721   
         {
 722  0
             throw new NullPointerException();
 723   
         }
 724  4
         if (hasSecurityConstraint(theUrlPattern))
 725   
         {
 726  0
             throw new IllegalStateException("Security constraint for URL "
 727   
                 + "pattern " + theUrlPattern + " already defined");
 728   
         }
 729  4
         Element securityConstraintElement =
 730   
             this.document.createElement(
 731   
                 WebXmlTag.SECURITY_CONSTRAINT.getTagName());
 732  4
         Element webResourceCollectionElement =
 733   
             this.document.createElement(
 734   
                 WebXmlTag.WEB_RESOURCE_COLLECTION.getTagName());
 735  4
         webResourceCollectionElement.appendChild(
 736   
             createNestedText(WebXmlTag.WEB_RESOURCE_NAME, theWebResourceName));
 737  4
         webResourceCollectionElement.appendChild(
 738   
             createNestedText(WebXmlTag.URL_PATTERN, theUrlPattern));
 739  4
         securityConstraintElement.appendChild(webResourceCollectionElement);
 740  4
         Element authConstraintElement =
 741   
             this.document.createElement(WebXmlTag.AUTH_CONSTRAINT.getTagName());
 742  4
         for (Iterator i = theRoles.iterator(); i.hasNext();)
 743   
         {
 744  5
             authConstraintElement.appendChild(
 745   
                 createNestedText(WebXmlTag.ROLE_NAME, (String) i.next()));
 746   
         }
 747  4
         securityConstraintElement.appendChild(authConstraintElement);
 748  4
         addElement(WebXmlTag.SECURITY_CONSTRAINT, securityConstraintElement);
 749   
     }
 750   
 
 751   
     /**
 752   
      * Returns the element that contains the security constraint defined for the
 753   
      * specified URL pattern.
 754   
      * 
 755   
      * @param theUrlPattern The URL pattern
 756   
      * @return The DOM element representing the security constraint
 757   
      */
 758  17
     public final Element getSecurityConstraint(String theUrlPattern)
 759   
     {
 760  17
         if (theUrlPattern == null)
 761   
         {
 762  0
             throw new NullPointerException();
 763   
         }
 764  17
         Iterator securityConstraintElements =
 765   
             getElements(WebXmlTag.SECURITY_CONSTRAINT);
 766  17
         while (securityConstraintElements.hasNext())
 767   
         {
 768  13
             Element securityConstraintElement = (Element)
 769   
                 securityConstraintElements.next();
 770  13
             Iterator webResourceCollectionElements = 
 771   
                 getNestedElements(securityConstraintElement,
 772   
                     WebXmlTag.WEB_RESOURCE_COLLECTION);
 773  13
             if (webResourceCollectionElements.hasNext())
 774   
             {
 775  13
                 Element webResourceCollectionElement = (Element)
 776   
                     webResourceCollectionElements.next();
 777  13
                 if (theUrlPattern.equals(getNestedText(
 778   
                     webResourceCollectionElement, WebXmlTag.URL_PATTERN)))
 779   
                 {
 780  10
                     return securityConstraintElement;
 781   
                 }
 782   
             }
 783   
         }
 784  7
         return null;
 785   
     }
 786   
     
 787   
     /**
 788   
      * Returns whether a security constraint has been mapped to the specified
 789   
      * URL pattern.
 790   
      * 
 791   
      * @param theUrlPattern The URL patterm
 792   
      * @return <code>true</code> if a security constraint is defined,
 793   
      *         <code>false</code> otherwise
 794   
      */
 795  14
     public final boolean hasSecurityConstraint(String theUrlPattern)
 796   
     {
 797  14
         return (getSecurityConstraint(theUrlPattern) != null);
 798   
     }
 799   
     
 800   
     /**
 801   
      * Returns whether the descriptor has a login configuration.
 802   
      * 
 803   
      * @return <code>true</code> if a login config is defined,
 804   
      *         <code>false</code> otherwise
 805   
      */
 806  6
     public final boolean hasLoginConfig()
 807   
     {
 808  6
         return (getLoginConfig() != null);
 809   
     }
 810   
 
 811   
     /**
 812   
      * Returns whether the descriptor has a login configuration.
 813   
      * 
 814   
      * @return <code>true</code> if a login config is defined,
 815   
      *         <code>false</code> otherwise
 816   
      */
 817  10
     public final Element getLoginConfig()
 818   
     {
 819  10
         Iterator loginConfigElements = getElements(WebXmlTag.LOGIN_CONFIG);
 820  10
         if (loginConfigElements.hasNext())
 821   
         {
 822  8
             return (Element) loginConfigElements.next();
 823   
         }
 824  2
         return null;
 825   
     }
 826   
 
 827   
     /**
 828   
      * Returns the authorization method defined by the login configuration.
 829   
      * 
 830   
      * @return The authorization method
 831   
      */
 832  4
     public final String getLoginConfigAuthMethod()
 833   
     {
 834  4
         return getNestedText(getLoginConfig(), WebXmlTag.AUTH_METHOD);
 835   
     }
 836   
 
 837   
     /**
 838   
      * Sets the login configuration.
 839   
      * 
 840   
      * @param theAuthMethod The authentication method (for example, BASIC)
 841   
      * @param theRealmName The name of the realm
 842   
      */
 843  3
     public final void setLoginConfig(String theAuthMethod, String theRealmName)
 844   
     {
 845  3
         if ((theRealmName == null) || (theAuthMethod == null))
 846   
         {
 847  0
             throw new NullPointerException();
 848   
         }
 849  3
         Element loginConfigElement =
 850   
             document.createElement(WebXmlTag.LOGIN_CONFIG.getTagName());
 851  3
         loginConfigElement.appendChild(
 852   
             createNestedText(WebXmlTag.AUTH_METHOD, theAuthMethod));
 853  3
         loginConfigElement.appendChild(
 854   
             createNestedText(WebXmlTag.REALM_NAME, theRealmName));
 855  3
         replaceElement(WebXmlTag.LOGIN_CONFIG, loginConfigElement);
 856   
     }
 857   
 
 858   
     /**
 859   
      * Adds a new security role to the descriptor.
 860   
      * 
 861   
      * @param theRoleName The name of the role to add
 862   
      */
 863  4
     public final void addSecurityRole(String theRoleName)
 864   
     {
 865  4
         if (theRoleName == null)
 866   
         {
 867  0
             throw new NullPointerException();
 868   
         }
 869  4
         if (hasSecurityRole(theRoleName))
 870   
         {
 871  0
             throw new IllegalStateException("Security role '" + theRoleName
 872   
                 + "' already defined");
 873   
         }
 874  4
         Element securityRoleElement =
 875   
             this.document.createElement(WebXmlTag.SECURITY_ROLE.getTagName());
 876  4
         securityRoleElement.appendChild(
 877   
             createNestedText(WebXmlTag.ROLE_NAME, theRoleName));
 878  4
         addElement(WebXmlTag.SECURITY_ROLE, securityRoleElement);
 879   
     }
 880   
     
 881   
     /**
 882   
      * Returns the element that contains the specified security role, or
 883   
      * <code>null</code> if the role is not defined in the descriptor.
 884   
      * 
 885   
      * @param theRoleName The name of the role
 886   
      * @return The DOM element representing the security role
 887   
      */
 888  20
     public final Element getSecurityRole(String theRoleName)
 889   
     {
 890  20
         if (theRoleName == null)
 891   
         {
 892  0
             throw new NullPointerException();
 893   
         }
 894  20
         Iterator securityRoleElements = getElements(WebXmlTag.SECURITY_ROLE);
 895  20
         while (securityRoleElements.hasNext())
 896   
         {
 897  20
             Element securityRoleElement = (Element) securityRoleElements.next();
 898  20
             if (theRoleName.equals(getNestedText(
 899   
                 securityRoleElement, WebXmlTag.ROLE_NAME)))
 900   
             {
 901  11
                 return securityRoleElement;
 902   
             }
 903   
         }
 904  9
         return null;
 905   
     }
 906   
     
 907   
     /**
 908   
      * Returns a list of the security role names defined in the deployment 
 909   
      * descriptor
 910   
      * 
 911   
      * @return An iterator over the list of security role names, or an empty
 912   
      *         iterator if no security roles are defined in the descriptor
 913   
      */
 914  7
     public final Iterator getSecurityRoleNames()
 915   
     {
 916  7
         List securityRoleNames = new ArrayList();
 917  7
         Iterator securityRoleElements = getElements(WebXmlTag.SECURITY_ROLE);
 918  7
         while (securityRoleElements.hasNext())
 919   
         {
 920  8
             Element securityRoleElement = (Element) securityRoleElements.next();
 921  8
             String securityRoleName =
 922   
                 getNestedText(securityRoleElement, WebXmlTag.ROLE_NAME);
 923  8
             if (securityRoleName != null)
 924   
             {
 925  8
                 securityRoleNames.add(securityRoleName);
 926   
             }
 927   
         }
 928  7
         return securityRoleNames.iterator();
 929   
     }
 930   
     
 931   
     /**
 932   
      * Returns whether a specific security role has been defined.
 933   
      * 
 934   
      * @param theRoleName The name of the role
 935   
      * @return <code>true</code> if the security role is defined,
 936   
      *         <code>false</code> otherwise
 937   
      */
 938  16
     public final boolean hasSecurityRole(String theRoleName)
 939   
     {
 940  16
         return (getSecurityRole(theRoleName) != null);
 941   
     }
 942   
     
 943   
     /**
 944   
      * Returns an iterator over the elements that match the specified tag.
 945   
      * 
 946   
      * @param theTag The descriptor tag of which the elements should be
 947   
      *         returned
 948   
      * @return An iterator over the elements matching the tag, in the order 
 949   
      *          they occur in the descriptor
 950   
      */
 951  417
     public final Iterator getElements(WebXmlTag theTag)
 952   
     {
 953  417
         List elements = new ArrayList();
 954  417
         NodeList nodeList =
 955   
             this.rootElement.getElementsByTagName(theTag.getTagName()); 
 956  417
         for (int i = 0; i < nodeList.getLength(); i++)
 957   
         {
 958  486
             elements.add(nodeList.item(i));
 959   
         }
 960  417
         return elements.iterator();
 961   
     }
 962   
     
 963   
     /**
 964   
      * Adds an element of the specified tag to the descriptor.
 965   
      * 
 966   
      * @param theTag The descriptor tag
 967   
      * @param theElement The element to add
 968   
      */
 969  137
     public final void addElement(WebXmlTag theTag, Element theElement)
 970   
     {
 971  137
         checkElement(theElement, theTag);
 972  137
         if (!theTag.isMultipleAllowed() && getElements(theTag).hasNext())
 973   
         {
 974  0
             throw new IllegalStateException("The tag '" + theTag
 975   
                 + "' may not occur more than once in the descriptor");
 976   
         }
 977  137
         Node importedNode = this.document.importNode(theElement, true);
 978  137
         Node refNode = getInsertionPointFor(theTag);
 979  137
         this.rootElement.insertBefore(importedNode, refNode);
 980   
     }
 981   
     
 982   
     /**
 983   
      * Replaces all elements of the specified tag with the provided element.
 984   
      * 
 985   
      * @param theTag The descriptor tag
 986   
      * @param theElement The element to replace the current elements with
 987   
      */
 988  3
     public final void replaceElement(WebXmlTag theTag, Element theElement)
 989   
     {
 990  3
         Iterator elements = getElements(theTag);
 991  3
         while (elements.hasNext())
 992   
         {
 993  1
             Element element = (Element) elements.next();
 994  1
             element.getParentNode().removeChild(element);
 995   
         }
 996  3
         addElement(theTag, theElement);
 997   
     }
 998   
     
 999   
     // Private Methods ---------------------------------------------------------
 1000   
     
 1001   
     /**
 1002   
      * Adds an initialization parameter to the specified filter or servlet.
 1003   
      * 
 1004   
      * @param theElement The filter or servlet element to which the
 1005   
      *         initialization parameter should be added
 1006   
      * @param theParamName The name of the parameter
 1007   
      * @param theParamValue The parameter value
 1008   
      */
 1009  11
     private void addInitParam(Element theElement, String theParamName,
 1010   
         String theParamValue)
 1011   
     {
 1012  11
         Element initParamElement =
 1013   
             this.document.createElement(WebXmlTag.INIT_PARAM.getTagName());
 1014  11
         initParamElement.appendChild(
 1015   
             createNestedText(WebXmlTag.PARAM_NAME, theParamName));
 1016  11
         initParamElement.appendChild(
 1017   
             createNestedText(WebXmlTag.PARAM_VALUE, theParamValue));
 1018  11
         Iterator loadOnStartupElements = getNestedElements(theElement,
 1019   
             WebXmlTag.LOAD_ON_STARTUP);
 1020  11
         if (loadOnStartupElements.hasNext())
 1021   
         {
 1022  1
             theElement.insertBefore(initParamElement,
 1023   
                 (Element) loadOnStartupElements.next());
 1024   
         }
 1025   
         else
 1026   
         {
 1027  10
             theElement.appendChild(initParamElement);
 1028   
         }
 1029   
     }
 1030   
     
 1031   
     /**
 1032   
      * Checks an element whether its name matches the specified name.
 1033   
      * 
 1034   
      * @param theElement The element to check
 1035   
      * @param theExpectedTag The expected tag name
 1036   
      * @throws IllegalArgumentException If the element name doesn't match
 1037   
      */
 1038  163
     private void checkElement(Element theElement, WebXmlTag theExpectedTag)
 1039   
         throws IllegalArgumentException
 1040   
     {
 1041  163
         if (!theExpectedTag.getTagName().equals(theElement.getNodeName()))
 1042   
         {
 1043  0
             throw new IllegalArgumentException("Not a '" + theExpectedTag
 1044   
                 + "' element");
 1045   
         }
 1046   
     }
 1047   
     
 1048   
     /**
 1049   
      * Returns an iterator over the child elements of the specified element that
 1050   
      * match the specified tag.
 1051   
      *  
 1052   
      * @param theParent The element of which the nested elements should be
 1053   
      *        retrieved
 1054   
      * @param theTag The descriptor tag of which the elements should be
 1055   
      *        returned
 1056   
      * @return An iterator over the elements matching the tag, in the order 
 1057   
      *         they occur in the descriptor
 1058   
      */
 1059  24
     private Iterator getNestedElements(Element theParent,
 1060   
         WebXmlTag theTag)
 1061   
     {
 1062  24
         List elements = new ArrayList();
 1063  24
         NodeList nodeList = theParent.getElementsByTagName(theTag.getTagName());
 1064  24
         for (int i = 0; i < nodeList.getLength(); i++)
 1065   
         {
 1066  14
             elements.add(nodeList.item(i));
 1067   
         }
 1068  24
         return elements.iterator();
 1069   
     }
 1070   
 
 1071   
     /**
 1072   
      * Creates an element that contains nested text.
 1073   
      * 
 1074   
      * @param theTag The tag to create an instance of
 1075   
      * @param theText The text that should be nested in the element
 1076   
      * @return The created DOM element
 1077   
      */
 1078  247
     private Element createNestedText(WebXmlTag theTag, String theText)
 1079   
     {
 1080  247
         Element element = this.document.createElement(theTag.getTagName());
 1081  247
         element.appendChild(this.document.createTextNode(theText));
 1082  247
         return element;
 1083   
     }
 1084   
     
 1085   
     /**
 1086   
      * Returns the value of an initialization parameter of the specified filter
 1087   
      * or servlet.
 1088   
      * 
 1089   
      * @param theElement The filter or servlet element that contains the
 1090   
      *         initialization parameters
 1091   
      * @param theParamName The name of the initialization parameter
 1092   
      * @return The parameter value
 1093   
      */
 1094  4
     private String getInitParam(Element theElement, String theParamName)
 1095   
     {
 1096  4
         if (theElement != null)
 1097   
         {
 1098  4
             NodeList initParamElements =
 1099   
                 theElement.getElementsByTagName(
 1100   
                     WebXmlTag.INIT_PARAM.getTagName());
 1101  4
             for (int i = 0; i < initParamElements.getLength(); i++)
 1102   
             {
 1103  4
                 Element initParamElement = (Element) initParamElements.item(i);
 1104  4
                 String paramName = getNestedText(
 1105   
                     initParamElement, WebXmlTag.PARAM_NAME);
 1106  4
                 if (theParamName.equals(paramName))
 1107   
                 {
 1108  4
                     return getNestedText(
 1109   
                         initParamElement, WebXmlTag.PARAM_VALUE);
 1110   
                 }
 1111   
             }
 1112   
         }
 1113  0
         return null;
 1114   
     }
 1115   
     
 1116   
     /**
 1117   
      * Returns the names of the initialization parameters of the specified 
 1118   
      * filter or servlet.
 1119   
      * 
 1120   
      * @param theElement The filter or servlet element that contains the
 1121   
      *         initialization parameters
 1122   
      * @return An iterator over the ordered list of parameter names
 1123   
      */
 1124  11
     private Iterator getInitParamNames(Element theElement)
 1125   
     {
 1126  11
         List initParamNames = new ArrayList();
 1127  11
         if (theElement != null)
 1128   
         {
 1129  11
             NodeList initParamElements =
 1130   
                 theElement.getElementsByTagName(
 1131   
                     WebXmlTag.INIT_PARAM.getTagName());
 1132  11
             for (int i = 0; i < initParamElements.getLength(); i++)
 1133   
             {
 1134  13
                 Element initParamElement = (Element) initParamElements.item(i);
 1135  13
                 String paramName = getNestedText(
 1136   
                     initParamElement, WebXmlTag.PARAM_NAME);
 1137  13
                 if (paramName != null)
 1138   
                 {
 1139  13
                     initParamNames.add(paramName);
 1140   
                 }
 1141   
             }
 1142   
         }
 1143  11
         return initParamNames.iterator();
 1144   
     }
 1145   
     
 1146   
     /**
 1147   
      * Returns the node before which the specified tag should be inserted, or
 1148   
      * <code>null</code> if the node should be inserted at the end of the 
 1149   
      * descriptor.
 1150   
      * 
 1151   
      * @param theTag The tag that should be inserted
 1152   
      * @return The node before which the tag can be inserted
 1153   
      */
 1154  137
     private Node getInsertionPointFor(WebXmlTag theTag)
 1155   
     {
 1156  1158
         for (int i = 0; i < ELEMENT_ORDER.length; i++)
 1157   
         {
 1158  1158
             if (ELEMENT_ORDER[i] == theTag)
 1159   
             {
 1160  137
                 for (int j = i + 1; j < ELEMENT_ORDER.length; j++)
 1161   
                 {
 1162  1381
                     NodeList elements =
 1163   
                         this.rootElement.getElementsByTagName(
 1164   
                             ELEMENT_ORDER[j].getTagName());
 1165  1381
                     if (elements.getLength() > 0)
 1166   
                     {
 1167  40
                         Node result = elements.item(0);
 1168  40
                         Node previous = result.getPreviousSibling();
 1169  40
                         while ((previous != null)
 1170   
                             && ((previous.getNodeType() == Node.COMMENT_NODE)
 1171   
                              || (previous.getNodeType() == Node.TEXT_NODE)))
 1172   
                         {
 1173  14
                             result = previous;
 1174  14
                             previous = result.getPreviousSibling();
 1175   
                         }
 1176  40
                         return result;
 1177   
                     }
 1178   
                 }
 1179  97
                 break;
 1180   
             }
 1181   
         }
 1182  97
         return null;
 1183   
     }
 1184   
     
 1185   
     /**
 1186   
      * Returns the text nested inside a child element of the specified element.
 1187   
      * 
 1188   
      * @param theElement The element of which the nested text should be
 1189   
      *         returned
 1190   
      * @param theTag The descriptor tag in which the text is nested
 1191   
      * @return The text nested in the element
 1192   
      */
 1193  567
     private String getNestedText(Element theElement,
 1194   
         WebXmlTag theTag)
 1195   
     {
 1196  567
         NodeList nestedElements =
 1197   
             theElement.getElementsByTagName(theTag.getTagName());
 1198  567
         if (nestedElements.getLength() > 0)
 1199   
         {
 1200  554
             Node nestedText = nestedElements.item(0).getFirstChild();
 1201  554
             if (nestedText != null)
 1202   
             {
 1203  554
                 return nestedText.getNodeValue();
 1204   
             }
 1205   
         }
 1206  13
         return null;
 1207   
     }
 1208   
     
 1209   
 }
 1210