Clover coverage report - Cactus 1.5 for J2EE API 1.2
Coverage timestamp: Wed Feb 18 2004 09:04:33 EST
file stats: LOC: 235   Methods: 10
NCLOC: 77   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ApplicationXmlVersion.java 100% 85.7% 70% 84.6%
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 org.w3c.dom.DocumentType;
 60   
 
 61   
 /**
 62   
  * Enumerated type that represents the version of the deployment descriptor of
 63   
  * a enterprise application (application.xml).
 64   
  * 
 65   
  * @author <a href="mailto:cmlenz@apache.org">Christopher Lenz</a>
 66   
  *
 67   
  * @since Cactus 1.5
 68   
  * @version $Id: ApplicationXmlVersion.java,v 1.3.2.3 2003/10/23 18:20:45 vmassol Exp $
 69   
  */
 70   
 public final class ApplicationXmlVersion implements Comparable
 71   
 {
 72   
 
 73   
     // Public Constants --------------------------------------------------------
 74   
 
 75   
     /**
 76   
      * Instance for version 1.2.
 77   
      */
 78   
     public static final ApplicationXmlVersion V1_2 = new ApplicationXmlVersion(
 79   
         "1.2",
 80   
         "-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN",
 81   
         "http://java.sun.com/j2ee/dtds/application_1_2.dtd");
 82   
 
 83   
     /**
 84   
      * Instance for version 1.3.
 85   
      */
 86   
     public static final ApplicationXmlVersion V1_3 = new ApplicationXmlVersion(
 87   
         "1.3",
 88   
         "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN",
 89   
         "http://java.sun.com/dtd/application_1_3.dtd");
 90   
 
 91   
     // Instance Variables ------------------------------------------------------
 92   
 
 93   
     /**
 94   
      * The version as strnig,
 95   
      */
 96   
     private String version;
 97   
 
 98   
     /**
 99   
      * The public ID of the corresponding document type.
 100   
      */
 101   
     private String publicId;
 102   
 
 103   
     /**
 104   
      * The system ID of the corresponding document type.
 105   
      */
 106   
     public String systemId;
 107   
 
 108   
     // Constructors ------------------------------------------------------------
 109   
     
 110   
     /**
 111   
      * Constructor.
 112   
      * 
 113   
      * @param theVersion The version as string
 114   
      * @param thePublicId The public ID of the correspondig document type
 115   
      * @param theSystemId The system ID of the correspondig document type
 116   
      */
 117  2
     private ApplicationXmlVersion(String theVersion, String thePublicId,
 118   
         String theSystemId)
 119   
     {
 120  2
         this.version = theVersion;
 121  2
         this.publicId = thePublicId;
 122  2
         this.systemId = theSystemId;
 123   
     }
 124   
 
 125   
     // Public Methods ----------------------------------------------------------
 126   
     
 127   
     /**
 128   
      * @see java.lang.Comparable#compareTo
 129   
      */
 130  4
     public int compareTo(Object theOther)
 131   
     {
 132  4
         if (theOther == this)
 133   
         {
 134  2
             return 0;
 135   
         }
 136  2
         ApplicationXmlVersion otherVersion = (ApplicationXmlVersion) theOther;
 137  2
         if (otherVersion == V1_3)
 138   
         {
 139  1
             return -1;
 140   
         }
 141  1
         return 1;
 142   
     }
 143   
     
 144   
     /**
 145   
      * @see java.lang.Object#toString
 146   
      */
 147  2
     public boolean equals(Object theOther)
 148   
     {
 149  2
         return super.equals(theOther);
 150   
     }
 151   
     
 152   
     /**
 153   
      * @see java.lang.Object#hashCode
 154   
      */
 155  0
     public int hashCode()
 156   
     {
 157  0
         return super.hashCode();
 158   
     }
 159   
     
 160   
     /**
 161   
      * Returns the tag name.
 162   
      * 
 163   
      * @return The tag name
 164   
      */
 165  0
     public String getVersion()
 166   
     {
 167  0
         return this.version;
 168   
     }
 169   
     
 170   
     /**
 171   
      * Returns the public ID of the document type corresponding to the 
 172   
      * descriptor version.
 173   
      * 
 174   
      * @return The public ID
 175   
      */
 176  7
     public String getPublicId()
 177   
     {
 178  7
         return publicId;
 179   
     }
 180   
 
 181   
     /**
 182   
      * Returns the system ID of the document type corresponding to the 
 183   
      * descriptor version.
 184   
      * 
 185   
      * @return The system ID
 186   
      */
 187  2
     public String getSystemId()
 188   
     {
 189  2
         return systemId;
 190   
     }
 191   
 
 192   
     /**
 193   
      * @see java.lang.Object#toString
 194   
      */
 195  0
     public String toString()
 196   
     {
 197  0
         return getVersion();
 198   
     }
 199   
 
 200   
     /**
 201   
      * Returns the version corresponding to the given document type.
 202   
      * 
 203   
      * @param theDocType The document type
 204   
      * @return The version that matches the document type, or <code>null</code>
 205   
      *         if the doctype is not recognized
 206   
      * @throws NullPointerException If the document type is <code>null</code>
 207   
      */
 208  4
     public static ApplicationXmlVersion valueOf(DocumentType theDocType)
 209   
         throws NullPointerException
 210   
     {
 211  4
         return valueOf(theDocType.getPublicId());
 212   
     }
 213   
 
 214   
     /**
 215   
      * Returns the version corresponding to the given public ID.
 216   
      * 
 217   
      * @param thePublicId The public ID
 218   
      * @return The version that matches the public ID, or <code>null</code>
 219   
      *         if the ID is not recognized
 220   
      */
 221  3
     public static ApplicationXmlVersion valueOf(String thePublicId)
 222   
     {
 223  3
         if (V1_2.getPublicId().equals(thePublicId))
 224   
         {
 225  1
             return ApplicationXmlVersion.V1_2;
 226   
         }
 227  2
         else if (V1_3.getPublicId().equals(thePublicId))
 228   
         {
 229  1
             return ApplicationXmlVersion.V1_3;
 230   
         }
 231  1
         return null;
 232   
     }
 233   
 
 234   
 }
 235