|
|||||||||||||||||||
| 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 | |||||||||||||||
| ApplicationXmlVersion.java | 100% | 85.7% | 70% | 84.6% |
|
||||||||||||||
| 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.application;
|
|
| 21 |
|
|
| 22 |
import org.w3c.dom.DocumentType;
|
|
| 23 |
|
|
| 24 |
/**
|
|
| 25 |
* Enumerated type that represents the version of the deployment descriptor of
|
|
| 26 |
* a enterprise application (application.xml).
|
|
| 27 |
*
|
|
| 28 |
* @since Cactus 1.5
|
|
| 29 |
* @version $Id: ApplicationXmlVersion.java 239003 2004-05-31 20:05:27Z vmassol $
|
|
| 30 |
*/
|
|
| 31 |
public final class ApplicationXmlVersion implements Comparable |
|
| 32 |
{
|
|
| 33 |
|
|
| 34 |
// Public Constants --------------------------------------------------------
|
|
| 35 |
|
|
| 36 |
/**
|
|
| 37 |
* Instance for version 1.2.
|
|
| 38 |
*/
|
|
| 39 |
public static final ApplicationXmlVersion V1_2 = new ApplicationXmlVersion( |
|
| 40 |
"1.2",
|
|
| 41 |
"-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN",
|
|
| 42 |
"http://java.sun.com/j2ee/dtds/application_1_2.dtd");
|
|
| 43 |
|
|
| 44 |
/**
|
|
| 45 |
* Instance for version 1.3.
|
|
| 46 |
*/
|
|
| 47 |
public static final ApplicationXmlVersion V1_3 = new ApplicationXmlVersion( |
|
| 48 |
"1.3",
|
|
| 49 |
"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN",
|
|
| 50 |
"http://java.sun.com/dtd/application_1_3.dtd");
|
|
| 51 |
|
|
| 52 |
// Instance Variables ------------------------------------------------------
|
|
| 53 |
|
|
| 54 |
/**
|
|
| 55 |
* The version as strnig,
|
|
| 56 |
*/
|
|
| 57 |
private String version;
|
|
| 58 |
|
|
| 59 |
/**
|
|
| 60 |
* The public ID of the corresponding document type.
|
|
| 61 |
*/
|
|
| 62 |
private String publicId;
|
|
| 63 |
|
|
| 64 |
/**
|
|
| 65 |
* The system ID of the corresponding document type.
|
|
| 66 |
*/
|
|
| 67 |
public String systemId;
|
|
| 68 |
|
|
| 69 |
// Constructors ------------------------------------------------------------
|
|
| 70 |
|
|
| 71 |
/**
|
|
| 72 |
* Constructor.
|
|
| 73 |
*
|
|
| 74 |
* @param theVersion The version as string
|
|
| 75 |
* @param thePublicId The public ID of the correspondig document type
|
|
| 76 |
* @param theSystemId The system ID of the correspondig document type
|
|
| 77 |
*/
|
|
| 78 | 2 |
private ApplicationXmlVersion(String theVersion, String thePublicId,
|
| 79 |
String theSystemId) |
|
| 80 |
{
|
|
| 81 | 2 |
this.version = theVersion;
|
| 82 | 2 |
this.publicId = thePublicId;
|
| 83 | 2 |
this.systemId = theSystemId;
|
| 84 |
} |
|
| 85 |
|
|
| 86 |
// Public Methods ----------------------------------------------------------
|
|
| 87 |
|
|
| 88 |
/**
|
|
| 89 |
* @see java.lang.Comparable#compareTo
|
|
| 90 |
*/
|
|
| 91 | 4 |
public int compareTo(Object theOther) |
| 92 |
{
|
|
| 93 | 4 |
if (theOther == this) |
| 94 |
{
|
|
| 95 | 2 |
return 0;
|
| 96 |
} |
|
| 97 | 2 |
ApplicationXmlVersion otherVersion = (ApplicationXmlVersion) theOther; |
| 98 | 2 |
if (otherVersion == V1_3)
|
| 99 |
{
|
|
| 100 | 1 |
return -1;
|
| 101 |
} |
|
| 102 | 1 |
return 1;
|
| 103 |
} |
|
| 104 |
|
|
| 105 |
/**
|
|
| 106 |
* @see java.lang.Object#toString
|
|
| 107 |
*/
|
|
| 108 | 2 |
public boolean equals(Object theOther) |
| 109 |
{
|
|
| 110 | 2 |
return super.equals(theOther); |
| 111 |
} |
|
| 112 |
|
|
| 113 |
/**
|
|
| 114 |
* @see java.lang.Object#hashCode
|
|
| 115 |
*/
|
|
| 116 | 0 |
public int hashCode() |
| 117 |
{
|
|
| 118 | 0 |
return super.hashCode(); |
| 119 |
} |
|
| 120 |
|
|
| 121 |
/**
|
|
| 122 |
* Returns the tag name.
|
|
| 123 |
*
|
|
| 124 |
* @return The tag name
|
|
| 125 |
*/
|
|
| 126 | 0 |
public String getVersion()
|
| 127 |
{
|
|
| 128 | 0 |
return this.version; |
| 129 |
} |
|
| 130 |
|
|
| 131 |
/**
|
|
| 132 |
* Returns the public ID of the document type corresponding to the
|
|
| 133 |
* descriptor version.
|
|
| 134 |
*
|
|
| 135 |
* @return The public ID
|
|
| 136 |
*/
|
|
| 137 | 7 |
public String getPublicId()
|
| 138 |
{
|
|
| 139 | 7 |
return publicId;
|
| 140 |
} |
|
| 141 |
|
|
| 142 |
/**
|
|
| 143 |
* Returns the system ID of the document type corresponding to the
|
|
| 144 |
* descriptor version.
|
|
| 145 |
*
|
|
| 146 |
* @return The system ID
|
|
| 147 |
*/
|
|
| 148 | 2 |
public String getSystemId()
|
| 149 |
{
|
|
| 150 | 2 |
return systemId;
|
| 151 |
} |
|
| 152 |
|
|
| 153 |
/**
|
|
| 154 |
* @see java.lang.Object#toString
|
|
| 155 |
*/
|
|
| 156 | 0 |
public String toString()
|
| 157 |
{
|
|
| 158 | 0 |
return getVersion();
|
| 159 |
} |
|
| 160 |
|
|
| 161 |
/**
|
|
| 162 |
* Returns the version corresponding to the given document type.
|
|
| 163 |
*
|
|
| 164 |
* @param theDocType The document type
|
|
| 165 |
* @return The version that matches the document type, or <code>null</code>
|
|
| 166 |
* if the doctype is not recognized
|
|
| 167 |
* @throws NullPointerException If the document type is <code>null</code>
|
|
| 168 |
*/
|
|
| 169 | 4 |
public static ApplicationXmlVersion valueOf(DocumentType theDocType) |
| 170 |
throws NullPointerException
|
|
| 171 |
{
|
|
| 172 | 4 |
return valueOf(theDocType.getPublicId());
|
| 173 |
} |
|
| 174 |
|
|
| 175 |
/**
|
|
| 176 |
* Returns the version corresponding to the given public ID.
|
|
| 177 |
*
|
|
| 178 |
* @param thePublicId The public ID
|
|
| 179 |
* @return The version that matches the public ID, or <code>null</code>
|
|
| 180 |
* if the ID is not recognized
|
|
| 181 |
*/
|
|
| 182 | 3 |
public static ApplicationXmlVersion valueOf(String thePublicId) |
| 183 |
{
|
|
| 184 | 3 |
if (V1_2.getPublicId().equals(thePublicId))
|
| 185 |
{
|
|
| 186 | 1 |
return ApplicationXmlVersion.V1_2;
|
| 187 |
} |
|
| 188 | 2 |
else if (V1_3.getPublicId().equals(thePublicId)) |
| 189 |
{
|
|
| 190 | 1 |
return ApplicationXmlVersion.V1_3;
|
| 191 |
} |
|
| 192 | 1 |
return null; |
| 193 |
} |
|
| 194 |
|
|
| 195 |
} |
|
| 196 |
|
|
||||||||||