Desktop tool for browsing account info from EVE-Online
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DocType.java 9.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. /*--
  2. $Id: DocType.java,v 1.32 2007/11/10 05:28:58 jhunter Exp $
  3. Copyright (C) 2000-2007 Jason Hunter & Brett McLaughlin.
  4. All rights reserved.
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following conditions
  7. are met:
  8. 1. Redistributions of source code must retain the above copyright
  9. notice, this list of conditions, and the following disclaimer.
  10. 2. Redistributions in binary form must reproduce the above copyright
  11. notice, this list of conditions, and the disclaimer that follows
  12. these conditions in the documentation and/or other materials
  13. provided with the distribution.
  14. 3. The name "JDOM" must not be used to endorse or promote products
  15. derived from this software without prior written permission. For
  16. written permission, please contact <request_AT_jdom_DOT_org>.
  17. 4. Products derived from this software may not be called "JDOM", nor
  18. may "JDOM" appear in their name, without prior written permission
  19. from the JDOM Project Management <request_AT_jdom_DOT_org>.
  20. In addition, we request (but do not require) that you include in the
  21. end-user documentation provided with the redistribution and/or in the
  22. software itself an acknowledgement equivalent to the following:
  23. "This product includes software developed by the
  24. JDOM Project (http://www.jdom.org/)."
  25. Alternatively, the acknowledgment may be graphical using the logos
  26. available at http://www.jdom.org/images/logos.
  27. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  28. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  29. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  30. DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
  31. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  32. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  33. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  34. USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  35. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  36. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  38. SUCH DAMAGE.
  39. This software consists of voluntary contributions made by many
  40. individuals on behalf of the JDOM Project and was originally
  41. created by Jason Hunter <jhunter_AT_jdom_DOT_org> and
  42. Brett McLaughlin <brett_AT_jdom_DOT_org>. For more information
  43. on the JDOM Project, please see <http://www.jdom.org/>.
  44. */
  45. package org.jdom;
  46. /**
  47. * An XML DOCTYPE declaration. Method allow the user to get and set the
  48. * root element name, public id, and system id.
  49. *
  50. * @author Brett McLaughlin
  51. * @author Jason Hunter
  52. * @version $Revision: 1.32 $, $Date: 2007/11/10 05:28:58 $
  53. */
  54. public class DocType extends Content {
  55. private static final String CVS_ID =
  56. "@(#) $RCSfile: DocType.java,v $ $Revision: 1.32 $ $Date: 2007/11/10 05:28:58 $ $Name: jdom_1_1 $";
  57. /** The element being constrained */
  58. protected String elementName;
  59. /** The public ID of the DOCTYPE */
  60. protected String publicID;
  61. /** The system ID of the DOCTYPE */
  62. protected String systemID;
  63. /** The internal subset of the DOCTYPE */
  64. protected String internalSubset;
  65. /**
  66. * Default, no-args constructor for implementations to use if needed.
  67. */
  68. protected DocType() {}
  69. /*
  70. * XXX:
  71. * We need to take care of entities and notations here.
  72. */
  73. /**
  74. * This will create the <code>DocType</code> with
  75. * the specified element name and a reference to an
  76. * external DTD.
  77. *
  78. * @param elementName <code>String</code> name of
  79. * element being constrained.
  80. * @param publicID <code>String</code> public ID of
  81. * referenced DTD
  82. * @param systemID <code>String</code> system ID of
  83. * referenced DTD
  84. * @throws IllegalDataException if the given system ID is not a legal
  85. * system literal or the public ID is not a legal public ID.
  86. * @throws IllegalNameException if the given root element name is not a
  87. * legal XML element name.
  88. */
  89. public DocType(String elementName, String publicID, String systemID) {
  90. setElementName(elementName);
  91. setPublicID(publicID);
  92. setSystemID(systemID);
  93. }
  94. /**
  95. * This will create the <code>DocType</code> with
  96. * the specified element name and reference to an
  97. * external DTD.
  98. *
  99. * @param elementName <code>String</code> name of
  100. * element being constrained.
  101. * @param systemID <code>String</code> system ID of
  102. * referenced DTD
  103. * @throws IllegalDataException if the given system ID is not a legal
  104. * system literal.
  105. * @throws IllegalNameException if the given root element name is not a
  106. * legal XML element name.
  107. */
  108. public DocType(String elementName, String systemID) {
  109. this(elementName, null, systemID);
  110. }
  111. /**
  112. * This will create the <code>DocType</code> with
  113. * the specified element name
  114. *
  115. * @param elementName <code>String</code> name of
  116. * element being constrained.
  117. * @throws IllegalNameException if the given root element name is not a
  118. * legal XML element name.
  119. */
  120. public DocType(String elementName) {
  121. this(elementName, null, null);
  122. }
  123. /**
  124. * This will retrieve the element name being constrained.
  125. *
  126. * @return <code>String</code> - element name for DOCTYPE
  127. */
  128. public String getElementName() {
  129. return elementName;
  130. }
  131. /**
  132. * This will set the root element name declared by this
  133. * DOCTYPE declaration.
  134. *
  135. * @return DocType <code>DocType</code> this DocType object
  136. * @param elementName <code>String</code> name of
  137. * root element being constrained.
  138. * @throws IllegalNameException if the given root element name is not a
  139. * legal XML element name.
  140. */
  141. public DocType setElementName(String elementName) {
  142. // This can contain a colon so we use checkXMLName()
  143. // instead of checkElementName()
  144. String reason = Verifier.checkXMLName(elementName);
  145. if (reason != null) {
  146. throw new IllegalNameException(elementName, "DocType", reason);
  147. }
  148. this.elementName = elementName;
  149. return this;
  150. }
  151. /**
  152. * This will retrieve the public ID of an externally
  153. * referenced DTD, or an empty <code>String</code> if
  154. * none is referenced.
  155. *
  156. * @return <code>String</code> - public ID of referenced DTD.
  157. */
  158. public String getPublicID() {
  159. return publicID;
  160. }
  161. /**
  162. * This will set the public ID of an externally
  163. * referenced DTD.
  164. *
  165. * @param publicID id to set
  166. * @return DocType <code>DocType</code> this DocType object
  167. * @throws IllegalDataException if the given public ID is not a legal
  168. * public ID.
  169. */
  170. public DocType setPublicID(String publicID) {
  171. String reason = Verifier.checkPublicID(publicID);
  172. if (reason != null) {
  173. throw new IllegalDataException(publicID, "DocType", reason);
  174. }
  175. this.publicID = publicID;
  176. return this;
  177. }
  178. /**
  179. * This will retrieve the system ID of an externally
  180. * referenced DTD, or an empty <code>String</code> if
  181. * none is referenced.
  182. *
  183. * @return <code>String</code> - system ID of referenced DTD.
  184. */
  185. public String getSystemID() {
  186. return systemID;
  187. }
  188. /**
  189. * This will set the system ID of an externally
  190. * referenced DTD.
  191. *
  192. * @param systemID id to set
  193. * @return systemID <code>String</code> system ID of
  194. * referenced DTD.
  195. * @throws IllegalDataException if the given system ID is not a legal
  196. * system literal.
  197. */
  198. public DocType setSystemID(String systemID) {
  199. String reason = Verifier.checkSystemLiteral(systemID);
  200. if (reason != null) {
  201. throw new IllegalDataException(systemID, "DocType", reason);
  202. }
  203. this.systemID = systemID;
  204. return this;
  205. }
  206. /**
  207. * Returns the empty string since doctypes don't have an XPath
  208. * 1.0 string value.
  209. * @return the empty string
  210. */
  211. public String getValue() {
  212. return ""; // doctypes don't have an XPath string value
  213. }
  214. /**
  215. * This sets the data for the internal subset.
  216. *
  217. * @param newData data for the internal subset, as a
  218. * <code>String</code>.
  219. */
  220. public void setInternalSubset(String newData) {
  221. internalSubset = newData;
  222. }
  223. /**
  224. * This returns the data for the internal subset.
  225. *
  226. * @return <code>String</code> - the internal subset
  227. */
  228. public String getInternalSubset() {
  229. return internalSubset;
  230. }
  231. /**
  232. * This returns a <code>String</code> representation of the
  233. * <code>DocType</code>, suitable for debugging.
  234. *
  235. * @return <code>String</code> - information about the
  236. * <code>DocType</code>
  237. */
  238. public String toString() {
  239. return new StringBuffer()
  240. .append("[DocType: ")
  241. .append(new org.jdom.output.XMLOutputter().outputString(this))
  242. .append("]")
  243. .toString();
  244. }
  245. }