1 20 package org.apache.cactus.integration.ant.deployment.application; 21 22 import org.w3c.dom.DocumentType ; 23 24 31 public final class ApplicationXmlVersion implements Comparable 32 { 33 34 36 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 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 54 57 private String version; 58 59 62 private String publicId; 63 64 67 public String systemId; 68 69 71 78 private ApplicationXmlVersion(String theVersion, String thePublicId, 79 String theSystemId) 80 { 81 this.version = theVersion; 82 this.publicId = thePublicId; 83 this.systemId = theSystemId; 84 } 85 86 88 91 public int compareTo(Object theOther) 92 { 93 if (theOther == this) 94 { 95 return 0; 96 } 97 ApplicationXmlVersion otherVersion = (ApplicationXmlVersion) theOther; 98 if (otherVersion == V1_3) 99 { 100 return -1; 101 } 102 return 1; 103 } 104 105 108 public boolean equals(Object theOther) 109 { 110 return super.equals(theOther); 111 } 112 113 116 public int hashCode() 117 { 118 return super.hashCode(); 119 } 120 121 126 public String getVersion() 127 { 128 return this.version; 129 } 130 131 137 public String getPublicId() 138 { 139 return publicId; 140 } 141 142 148 public String getSystemId() 149 { 150 return systemId; 151 } 152 153 156 public String toString() 157 { 158 return getVersion(); 159 } 160 161 169 public static ApplicationXmlVersion valueOf(DocumentType theDocType) 170 throws NullPointerException 171 { 172 return valueOf(theDocType.getPublicId()); 173 } 174 175 182 public static ApplicationXmlVersion valueOf(String thePublicId) 183 { 184 if (V1_2.getPublicId().equals(thePublicId)) 185 { 186 return ApplicationXmlVersion.V1_2; 187 } 188 else if (V1_3.getPublicId().equals(thePublicId)) 189 { 190 return ApplicationXmlVersion.V1_3; 191 } 192 return null; 193 } 194 195 } 196 | Popular Tags |