1 // $Id: XmlSchemaAnnotation.java 165 2009-05-28 21:46:38Z agony $
2 /*
3 * xsAnalyzer - XML schema analyzing tool. Copyright (C) 2008 Michael Engelhardt
4 *
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7 * version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
10 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
13 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 */
15 /**
16 *
17 */
18 package de.mindcrimeilab.xsanalyzer.xml;
19
20 import org.apache.commons.lang.builder.EqualsBuilder;
21 import org.apache.commons.lang.builder.HashCodeBuilder;
22 import org.apache.commons.lang.builder.ToStringBuilder;
23
24 /**
25 * This class represents an XML schema annotation {@code xs:annotation} child - which could be either an application
26 * info {@code xs:appinfo} or an user documentation entry {@code xs:documentation}.
27 *
28 * @author Michael Engelhardt<me@mindcrime-ilab.de>
29 * @author $Author: agony $
30 * @version $Revision: 165 $
31 *
32 */
33 public class XmlSchemaAnnotation {
34
35 /** content inside the element */
36 private String content;
37
38 /** type of the annotation */
39 private Type type;
40
41 /**
42 * Type of annotation entry. Possible values are @ APPINFO} or {@DOCUMENTATION}.
43 *
44 * @author Michael Engelhardt<me@mindcrime-ilab.de>
45 * @author $Author: agony $
46 * @version $Revision: 165 $
47 *
48 */
49 public static enum Type {
50 APPINFO, DOCUMENTATION
51 };
52
53 /**
54 * ctor();
55 */
56 public XmlSchemaAnnotation() {
57 this(null, null);
58 }
59
60 /**
61 * ctor().
62 *
63 * @param type
64 * of annotation entry
65 * @param content
66 * of annotation entry
67 */
68 public XmlSchemaAnnotation(XmlSchemaAnnotation.Type type, String content) {
69 this.type = type;
70 this.content = content;
71 }
72
73 /**
74 * Returns content of this annotation entry.
75 *
76 * @return
77 */
78 public String getContent() {
79 return content;
80 }
81
82 /**
83 * Sets content of this annotation entry.
84 *
85 * @param content
86 */
87 public void setContent(String content) {
88 this.content = content;
89 }
90
91 /**
92 * Returns type of this annotation entry.
93 *
94 * @return
95 */
96 public Type getType() {
97 return type;
98 }
99
100 /**
101 * Sets type of this annotation entry.
102 */
103 public void setType(Type type) {
104 this.type = type;
105 }
106
107 @Override
108 public String toString() {
109 return new ToStringBuilder(this).append(type).append(content).toString();
110 }
111
112 @Override
113 public int hashCode() {
114 return new HashCodeBuilder().append(type).append(content).toHashCode();
115 }
116
117 @Override
118 public boolean equals(Object obj) {
119 if (!(obj instanceof XmlSchemaAnnotation)) return false;
120 XmlSchemaAnnotation other = (XmlSchemaAnnotation) obj;
121 return new EqualsBuilder().append(type, other.getType()).append(content, other.getContent()).isEquals();
122 }
123 }