View Javadoc
1   /*
2    * The MIT License
3    * Copyright © 2004-2014 Fabrizio Giustina
4    * Copyright © 2022-2022 Web-Legacy
5    *
6    * Permission is hereby granted, free of charge, to any person obtaining a copy
7    * of this software and associated documentation files (the "Software"), to deal
8    * in the Software without restriction, including without limitation the rights
9    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10   * copies of the Software, and to permit persons to whom the Software is
11   * furnished to do so, subject to the following conditions:
12   *
13   * The above copyright notice and this permission notice shall be included in
14   * all copies or substantial portions of the Software.
15   *
16   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22   * THE SOFTWARE.
23   */
24  package net.sf.maventaglib.checker;
25  
26  import org.apache.commons.lang3.builder.CompareToBuilder;
27  import org.apache.commons.lang3.builder.EqualsBuilder;
28  import org.apache.commons.lang3.builder.HashCodeBuilder;
29  import org.apache.commons.lang3.builder.ToStringBuilder;
30  import org.apache.commons.lang3.builder.ToStringStyle;
31  
32  
33  /**
34   * Contains information about a tag.
35   * @author Fabrizio Giustina
36   * @version $Revision $ ($Author $)
37   */
38  public class Tag extends TldItem
39  {
40  
41      private String tagClass;
42  
43      private String teiClass;
44  
45      private String bodycontent;
46  
47      private TagAttribute[] attributes;
48  
49      private TagVariable[] variables;
50  
51      public TagAttribute[] getAttributes()
52      {
53          return this.attributes;
54      }
55  
56      public void setAttributes(TagAttribute[] tagAttributes)
57      {
58          this.attributes = tagAttributes;
59      }
60  
61      public String getTagClass()
62      {
63          return this.tagClass;
64      }
65  
66      public void setTagClass(String className)
67      {
68          this.tagClass = className;
69      }
70  
71      public String getTeiClass()
72      {
73          return this.teiClass;
74      }
75  
76      public void setTeiClass(String className)
77      {
78          this.teiClass = className;
79      }
80  
81      public String getBodycontent()
82      {
83          return this.bodycontent;
84      }
85  
86      public void setBodycontent(String bodycontent)
87      {
88          this.bodycontent = bodycontent;
89      }
90  
91      public TagVariable[] getVariables()
92      {
93          return this.variables;
94      }
95  
96      public void setVariables(TagVariable[] variables)
97      {
98          this.variables = variables;
99      }
100 
101     /**
102      * @see java.lang.Comparable#compareTo(Object)
103      */
104     @Override
105     public int compareTo(TldItem object)
106     {
107         int ret = super.compareTo(object);
108         if (ret != 0) {
109             return ret;
110         }
111 
112         Tag rhs = (Tag) object;
113         return new CompareToBuilder()
114             .append(this.tagClass, rhs.tagClass)
115             .append(this.teiClass, rhs.teiClass)
116             .append(this.attributes, rhs.attributes)
117             .toComparison();
118     }
119 
120     /**
121      * @see java.lang.Object#equals(Object)
122      */
123     @Override
124     public boolean equals(Object obj)
125     {
126         if(obj == null || !super.equals(obj))
127         {
128             return false;
129         }
130 
131         Tag rhs = (Tag) obj;
132         return new EqualsBuilder()
133                 .append(this.tagClass, rhs.tagClass)
134                 .append(this.teiClass, rhs.teiClass)
135                 .append(this.attributes, rhs.attributes)
136                 .isEquals();
137       }
138 
139     /**
140      * @see java.lang.Object#hashCode()
141      */
142     @Override
143     public int hashCode() {
144         return new HashCodeBuilder()
145                 .appendSuper(super.hashCode())
146                 .append(this.tagClass)
147                 .append(this.teiClass)
148                 .append(this.attributes)
149                 .toHashCode();
150       }
151 
152     /**
153      * @see java.lang.Object#toString()
154      */
155     @Override
156     public String toString()
157     {
158         return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE).append("name", this.getName()) //$NON-NLS-1$
159             .append("tagClass", this.tagClass).append("teiClass", this.teiClass).append("attributes", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
160                 this.attributes)
161             .toString();
162     }
163 
164 }