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.

Comment.java 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*--
  2. $Id: Comment.java,v 1.33 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 comment. Methods allow the user to get and set the text of the
  48. * comment.
  49. *
  50. * @version $Revision: 1.33 $, $Date: 2007/11/10 05:28:58 $
  51. * @author Brett McLaughlin
  52. * @author Jason Hunter
  53. */
  54. public class Comment extends Content {
  55. private static final String CVS_ID =
  56. "@(#) $RCSfile: Comment.java,v $ $Revision: 1.33 $ $Date: 2007/11/10 05:28:58 $ $Name: jdom_1_1 $";
  57. /** Text of the <code>Comment</code> */
  58. protected String text;
  59. /**
  60. * Default, no-args constructor for implementations to use if needed.
  61. */
  62. protected Comment() {}
  63. /**
  64. * This creates the comment with the supplied text.
  65. *
  66. * @param text <code>String</code> content of comment.
  67. */
  68. public Comment(String text) {
  69. setText(text);
  70. }
  71. /**
  72. * Returns the XPath 1.0 string value of this element, which is the
  73. * text of this comment.
  74. *
  75. * @return the text of this comment
  76. */
  77. public String getValue() {
  78. return text;
  79. }
  80. /**
  81. * This returns the textual data within the <code>Comment</code>.
  82. *
  83. * @return <code>String</code> - text of comment.
  84. */
  85. public String getText() {
  86. return text;
  87. }
  88. /**
  89. * This will set the value of the <code>Comment</code>.
  90. *
  91. * @param text <code>String</code> text for comment.
  92. * @return <code>Comment</code> - this Comment modified.
  93. * @throws IllegalDataException if the given text is illegal for a
  94. * Comment.
  95. */
  96. public Comment setText(String text) {
  97. String reason;
  98. if ((reason = Verifier.checkCommentData(text)) != null) {
  99. throw new IllegalDataException(text, "comment", reason);
  100. }
  101. this.text = text;
  102. return this;
  103. }
  104. /**
  105. * This returns a <code>String</code> representation of the
  106. * <code>Comment</code>, suitable for debugging. If the XML
  107. * representation of the <code>Comment</code> is desired,
  108. * {@link org.jdom.output.XMLOutputter#outputString(Comment)}
  109. * should be used.
  110. *
  111. * @return <code>String</code> - information about the
  112. * <code>Attribute</code>
  113. */
  114. public String toString() {
  115. return new StringBuffer()
  116. .append("[Comment: ")
  117. .append(new org.jdom.output.XMLOutputter().outputString(this))
  118. .append("]")
  119. .toString();
  120. }
  121. }