1 20 package org.apache.cactus.integration.ant.deployment.webapp; 21 22 import org.w3c.dom.DocumentType ; 23 24 30 public final class WebXmlVersion implements Comparable 31 { 32 33 35 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 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 51 54 private String version; 55 56 59 private String publicId; 60 61 64 public String systemId; 65 66 68 75 private WebXmlVersion(String theVersion, String thePublicId, 76 String theSystemId) 77 { 78 this.version = theVersion; 79 this.publicId = thePublicId; 80 this.systemId = theSystemId; 81 } 82 83 85 88 public int compareTo(Object theOther) 89 { 90 if (theOther == this) 91 { 92 return 0; 93 } 94 WebXmlVersion otherVersion = (WebXmlVersion) theOther; 95 if (otherVersion == V2_3) 96 { 97 return -1; 98 } 99 return 1; 100 } 101 102 105 public boolean equals(Object theOther) 106 { 107 return super.equals(theOther); 108 } 109 110 113 public int hashCode() 114 { 115 return super.hashCode(); 116 } 117 118 123 public String getVersion() 124 { 125 return this.version; 126 } 127 128 134 public String getPublicId() 135 { 136 return publicId; 137 } 138 139 145 public String getSystemId() 146 { 147 return systemId; 148 } 149 150 153 public String toString() 154 { 155 return getVersion(); 156 } 157 158 166 public static WebXmlVersion valueOf(DocumentType theDocType) 167 throws NullPointerException 168 { 169 return valueOf(theDocType.getPublicId()); 170 } 171 172 179 public static WebXmlVersion valueOf(String thePublicId) 180 { 181 if (V2_2.getPublicId().equals(thePublicId)) 182 { 183 return WebXmlVersion.V2_2; 184 } 185 else if (V2_3.getPublicId().equals(thePublicId)) 186 { 187 return WebXmlVersion.V2_3; 188 } 189 return null; 190 } 191 192 } 193 | Popular Tags |