查看本类的 API文档回源码主页即时通讯网 - 即时通讯开发者社区!
1   /*
2    * Copyright 2014 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.handler.codec.xml;
17  
18  
19  /**
20   * XML attributes, it is part of {@link XmlElement}
21   */
22  public class XmlAttribute {
23  
24      private final String type;
25      private final String name;
26      private final String prefix;
27      private final String namespace;
28      private final String value;
29  
30      public XmlAttribute(String type, String name, String prefix, String namespace, String value) {
31          this.type = type;
32          this.name = name;
33          this.prefix = prefix;
34          this.namespace = namespace;
35          this.value = value;
36      }
37  
38      public String type() {
39          return type;
40      }
41  
42      public String name() {
43          return name;
44      }
45  
46      public String prefix() {
47          return prefix;
48      }
49  
50      public String namespace() {
51          return namespace;
52      }
53  
54      public String value() {
55          return value;
56      }
57  
58      @Override
59      public boolean equals(Object o) {
60          if (this == o) {
61              return true;
62          }
63          if (o == null || getClass() != o.getClass()) {
64              return false;
65          }
66  
67          XmlAttribute that = (XmlAttribute) o;
68  
69          if (!name.equals(that.name)) {
70              return false;
71          }
72          if (namespace != null ? !namespace.equals(that.namespace) : that.namespace != null) {
73              return false;
74          }
75          if (prefix != null ? !prefix.equals(that.prefix) : that.prefix != null) {
76              return false;
77          }
78          if (type != null ? !type.equals(that.type) : that.type != null) {
79              return false;
80          }
81          if (value != null ? !value.equals(that.value) : that.value != null) {
82              return false;
83          }
84  
85          return true;
86      }
87  
88      @Override
89      public int hashCode() {
90          int result = type != null ? type.hashCode() : 0;
91          result = 31 * result + name.hashCode();
92          result = 31 * result + (prefix != null ? prefix.hashCode() : 0);
93          result = 31 * result + (namespace != null ? namespace.hashCode() : 0);
94          result = 31 * result + (value != null ? value.hashCode() : 0);
95          return result;
96      }
97  
98      @Override
99      public String toString() {
100         return "XmlAttribute{" +
101                 "type='" + type + '\'' +
102                 ", name='" + name + '\'' +
103                 ", prefix='" + prefix + '\'' +
104                 ", namespace='" + namespace + '\'' +
105                 ", value='" + value + '\'' +
106                 '}';
107     }
108 }