2011/08/05 - Jakarta Cactus has been retired.

For more information, please explore the Attic.

Clover coverage report - Cactus 1.8dev for J2EE API 1.3
Coverage timestamp: Sun Mar 26 2006 18:50:18 BRT
file stats: LOC: 193   Methods: 10
NCLOC: 75   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
WebXmlVersion.java 100% 85.7% 70% 84.6%
coverage coverage
 1   
 /* 
 2   
  * ========================================================================
 3   
  * 
 4   
  * Copyright 2003 The Apache Software Foundation.
 5   
  *
 6   
  * Licensed under the Apache License, Version 2.0 (the "License");
 7   
  * you may not use this file except in compliance with the License.
 8   
  * You may obtain a copy of the License at
 9   
  * 
 10   
  *   http://www.apache.org/licenses/LICENSE-2.0
 11   
  * 
 12   
  * Unless required by applicable law or agreed to in writing, software
 13   
  * distributed under the License is distributed on an "AS IS" BASIS,
 14   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15   
  * See the License for the specific language governing permissions and
 16   
  * limitations under the License.
 17   
  * 
 18   
  * ========================================================================
 19   
  */
 20   
 package org.apache.cactus.integration.ant.deployment.webapp;
 21   
 
 22   
 import org.w3c.dom.DocumentType;
 23   
 
 24   
 /**
 25   
  * Enumerated type that represents the version of the web deployment descriptor.
 26   
  * 
 27   
  * @since Cactus 1.5
 28   
  * @version $Id: WebXmlVersion.java 239003 2004-05-31 20:05:27Z vmassol $
 29   
  */
 30   
 public final class WebXmlVersion implements Comparable
 31   
 {
 32   
 
 33   
     // Public Constants --------------------------------------------------------
 34   
 
 35   
     /**
 36   
      * Instance for version 2.2.
 37   
      */
 38   
     public static final WebXmlVersion V2_2 = new WebXmlVersion("2.2",
 39   
         "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN",
 40   
         "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd");
 41   
 
 42   
     /**
 43   
      * Instance for version 2.3.
 44   
      */
 45   
     public static final WebXmlVersion V2_3 = new WebXmlVersion("2.3",
 46   
         "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN",
 47   
         "http://java.sun.com/dtd/web-app_2_3.dtd");
 48   
 
 49   
     // Instance Variables ------------------------------------------------------
 50   
 
 51   
     /**
 52   
      * The version as strnig,
 53   
      */
 54   
     private String version;
 55   
 
 56   
     /**
 57   
      * The public ID of the corresponding document type.
 58   
      */
 59   
     private String publicId;
 60   
 
 61   
     /**
 62   
      * The system ID of the corresponding document type.
 63   
      */
 64   
     public String systemId;
 65   
 
 66   
     // Constructors ------------------------------------------------------------
 67   
     
 68   
     /**
 69   
      * Constructor.
 70   
      * 
 71   
      * @param theVersion The version as string
 72   
      * @param thePublicId The public ID of the correspondig document type
 73   
      * @param theSystemId The system ID of the correspondig document type
 74   
      */
 75  4
     private WebXmlVersion(String theVersion, String thePublicId,
 76   
         String theSystemId)
 77   
     {
 78  4
         this.version = theVersion;
 79  4
         this.publicId = thePublicId;
 80  4
         this.systemId = theSystemId;
 81   
     }
 82   
 
 83   
     // Public Methods ----------------------------------------------------------
 84   
     
 85   
     /**
 86   
      * @see java.lang.Comparable#compareTo
 87   
      */
 88  4
     public int compareTo(Object theOther)
 89   
     {
 90  4
         if (theOther == this)
 91   
         {
 92  2
             return 0;
 93   
         }
 94  2
         WebXmlVersion otherVersion = (WebXmlVersion) theOther;
 95  2
         if (otherVersion == V2_3)
 96   
         {
 97  1
             return -1;
 98   
         }
 99  1
         return 1;
 100   
     }
 101   
     
 102   
     /**
 103   
      * @see java.lang.Object#toString
 104   
      */
 105  4
     public boolean equals(Object theOther)
 106   
     {
 107  4
         return super.equals(theOther);
 108   
     }
 109   
     
 110   
     /**
 111   
      * @see java.lang.Object#hashCode
 112   
      */
 113  0
     public int hashCode()
 114   
     {
 115  0
         return super.hashCode();
 116   
     }
 117   
     
 118   
     /**
 119   
      * Returns the tag name.
 120   
      * 
 121   
      * @return The tag name
 122   
      */
 123  0
     public String getVersion()
 124   
     {
 125  0
         return this.version;
 126   
     }
 127   
     
 128   
     /**
 129   
      * Returns the public ID of the document type corresponding to the 
 130   
      * descriptor version.
 131   
      * 
 132   
      * @return The public ID
 133   
      */
 134  12
     public String getPublicId()
 135   
     {
 136  12
         return publicId;
 137   
     }
 138   
 
 139   
     /**
 140   
      * Returns the system ID of the document type corresponding to the 
 141   
      * descriptor version.
 142   
      * 
 143   
      * @return The system ID
 144   
      */
 145  2
     public String getSystemId()
 146   
     {
 147  2
         return systemId;
 148   
     }
 149   
 
 150   
     /**
 151   
      * @see java.lang.Object#toString
 152   
      */
 153  0
     public String toString()
 154   
     {
 155  0
         return getVersion();
 156   
     }
 157   
 
 158   
     /**
 159   
      * Returns the version corresponding to the given document type.
 160   
      * 
 161   
      * @param theDocType The document type
 162   
      * @return The version that matches the document type, or <code>null</code>
 163   
      *         if the doctype is not recognized
 164   
      * @throws NullPointerException If the document type is <code>null</code>
 165   
      */
 166  7
     public static WebXmlVersion valueOf(DocumentType theDocType)
 167   
         throws NullPointerException
 168   
     {
 169  7
         return valueOf(theDocType.getPublicId());
 170   
     }
 171   
 
 172   
     /**
 173   
      * Returns the version corresponding to the given public ID.
 174   
      * 
 175   
      * @param thePublicId The public ID
 176   
      * @return The version that matches the public ID, or <code>null</code>
 177   
      *         if the ID is not recognized
 178   
      */
 179  6
     public static WebXmlVersion valueOf(String thePublicId)
 180   
     {
 181  6
         if (V2_2.getPublicId().equals(thePublicId))
 182   
         {
 183  2
             return WebXmlVersion.V2_2;
 184   
         }
 185  4
         else if (V2_3.getPublicId().equals(thePublicId))
 186   
         {
 187  2
             return WebXmlVersion.V2_3;
 188   
         }
 189  2
         return null;
 190   
     }
 191   
 
 192   
 }
 193