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.

EntityRef.java 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /*--
  2. $Id: EntityRef.java,v 1.22 2007/11/10 05:28:59 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 entity reference. Methods allow the user to manage its name, public
  48. * id, and system id.
  49. *
  50. * @version $Revision: 1.22 $, $Date: 2007/11/10 05:28:59 $
  51. * @author Brett McLaughlin
  52. * @author Jason Hunter
  53. * @author Philip Nelson
  54. */
  55. public class EntityRef extends Content {
  56. private static final String CVS_ID =
  57. "@(#) $RCSfile: EntityRef.java,v $ $Revision: 1.22 $ $Date: 2007/11/10 05:28:59 $ $Name: jdom_1_1 $";
  58. /** The name of the <code>EntityRef</code> */
  59. protected String name;
  60. /** The PublicID of the <code>EntityRef</code> */
  61. protected String publicID;
  62. /** The SystemID of the <code>EntityRef</code> */
  63. protected String systemID;
  64. /**
  65. * Default, no-args constructor for implementations to use if needed.
  66. */
  67. protected EntityRef() {}
  68. /**
  69. * This will create a new <code>EntityRef</code> with the supplied name.
  70. *
  71. * @param name <code>String</code> name of element.
  72. * @throws IllegalNameException if the given name is not a legal
  73. * XML name.
  74. */
  75. public EntityRef(String name) {
  76. this(name, null, null);
  77. }
  78. /**
  79. * This will create a new <code>EntityRef</code>
  80. * with the supplied name and system id.
  81. *
  82. * @param name <code>String</code> name of element.
  83. * @param systemID system id of the entity reference being constructed
  84. * @throws IllegalNameException if the given name is not a legal
  85. * XML name.
  86. * @throws IllegalDataException if the given system ID is not a legal
  87. * system literal.
  88. */
  89. public EntityRef(String name, String systemID) {
  90. this(name, null, systemID);
  91. }
  92. /**
  93. * This will create a new <code>EntityRef</code>
  94. * with the supplied name, public id, and system id.
  95. *
  96. * @param name <code>String</code> name of element.
  97. * @param publicID public id of the entity reference being constructed
  98. * @param systemID system id of the entity reference being constructed
  99. * @throws IllegalDataException if the given system ID is not a legal
  100. * system literal or the the given public ID is not a
  101. * legal public ID
  102. * @throws IllegalNameException if the given name is not a legal
  103. * XML name.
  104. */
  105. public EntityRef(String name, String publicID, String systemID) {
  106. setName(name);
  107. setPublicID(publicID);
  108. setSystemID(systemID);
  109. }
  110. /**
  111. * This returns the name of the <code>EntityRef</code>.
  112. *
  113. * @return <code>String</code> - entity name.
  114. */
  115. public String getName() {
  116. return name;
  117. }
  118. /**
  119. * Returns the empty string since entity references don't have an XPath
  120. * 1.0 string value.
  121. * @return the empty string
  122. */
  123. public String getValue() {
  124. return ""; // entity references don't have XPath string values
  125. }
  126. /**
  127. * This will return the publid ID of this <code>EntityRef</code>.
  128. * If there is no public ID, then this returns <code>null</code>.
  129. *
  130. * @return public ID of this <code>EntityRef</code>
  131. */
  132. public String getPublicID() {
  133. return publicID;
  134. }
  135. /**
  136. * This will return the system ID of this <code>EntityRef</code>.
  137. * If there is no system ID, then this returns <code>null</code>.
  138. *
  139. * @return system ID of this <code>EntityRef</code>
  140. */
  141. public String getSystemID() {
  142. return systemID;
  143. }
  144. /**
  145. * This will set the name of this <code>EntityRef</code>.
  146. *
  147. * @param name new name of the entity
  148. * @return this <code>EntityRef</code> modified.
  149. * @throws IllegalNameException if the given name is not a legal
  150. * XML name.
  151. */
  152. public EntityRef setName(String name) {
  153. // This can contain a colon so we use checkXMLName()
  154. // instead of checkElementName()
  155. String reason = Verifier.checkXMLName(name);
  156. if (reason != null) {
  157. throw new IllegalNameException(name, "EntityRef", reason);
  158. }
  159. this.name = name;
  160. return this;
  161. }
  162. /**
  163. * This will set the public ID of this <code>EntityRef</code>.
  164. *
  165. * @param publicID new public id
  166. * @return this <code>EntityRef</code> modified.
  167. * @throws IllegalDataException if the given public ID is not a legal
  168. * public ID.
  169. */
  170. public EntityRef setPublicID(String publicID) {
  171. String reason = Verifier.checkPublicID(publicID);
  172. if (reason != null) {
  173. throw new IllegalDataException(publicID, "EntityRef", reason);
  174. }
  175. this.publicID = publicID;
  176. return this;
  177. }
  178. /**
  179. * This will set the system ID of this <code>EntityRef</code>.
  180. *
  181. * @param systemID new system id
  182. * @throws IllegalDataException if the given system ID is not a legal
  183. * system literal.
  184. * @return this <code>EntityRef</code> modified.
  185. */
  186. public EntityRef setSystemID(String systemID) {
  187. String reason = Verifier.checkSystemLiteral(systemID);
  188. if (reason != null) {
  189. throw new IllegalDataException(systemID, "EntityRef", reason);
  190. }
  191. this.systemID = systemID;
  192. return this;
  193. }
  194. /**
  195. * This returns a <code>String</code> representation of the
  196. * <code>EntityRef</code>, suitable for debugging.
  197. *
  198. * @return <code>String</code> - information about the
  199. * <code>EntityRef</code>
  200. */
  201. public String toString() {
  202. return new StringBuffer()
  203. .append("[EntityRef: ")
  204. .append("&")
  205. .append(name)
  206. .append(";")
  207. .append("]")
  208. .toString();
  209. }
  210. }