View Javadoc
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   * Beginning of the XML document ... i.e. XML header
20   */
21  public class XmlDocumentStart {
22  
23      private final String encoding;
24      private final String version;
25      private final boolean standalone;
26      private final String encodingScheme;
27  
28      public XmlDocumentStart(String encoding, String version, boolean standalone, String encodingScheme) {
29          this.encoding = encoding;
30          this.version = version;
31          this.standalone = standalone;
32          this.encodingScheme = encodingScheme;
33      }
34  
35      /** Return defined or guessed XML encoding **/
36      public String encoding() {
37          return encoding;
38      }
39  
40      /** Return defined XML version or null **/
41      public String version() {
42          return version;
43      }
44  
45      /** Return standalonity of the document **/
46      public boolean standalone() {
47          return standalone;
48      }
49  
50      /** Return defined encoding or null **/
51      public String encodingScheme() {
52          return encodingScheme;
53      }
54  
55      @Override
56      public boolean equals(Object o) {
57          if (this == o) {
58              return true;
59          }
60          if (o == null || getClass() != o.getClass()) {
61              return false;
62          }
63  
64          XmlDocumentStart that = (XmlDocumentStart) o;
65  
66          if (standalone != that.standalone) {
67              return false;
68          }
69          if (encoding != null ? !encoding.equals(that.encoding) : that.encoding != null) {
70              return false;
71          }
72          if (encodingScheme != null ? !encodingScheme.equals(that.encodingScheme) : that.encodingScheme != null) {
73              return false;
74          }
75          if (version != null ? !version.equals(that.version) : that.version != null) {
76              return false;
77          }
78  
79          return true;
80      }
81  
82      @Override
83      public int hashCode() {
84          int result = encoding != null ? encoding.hashCode() : 0;
85          result = 31 * result + (version != null ? version.hashCode() : 0);
86          result = 31 * result + (standalone ? 1 : 0);
87          result = 31 * result + (encodingScheme != null ? encodingScheme.hashCode() : 0);
88          return result;
89      }
90  
91      @Override
92      public String toString() {
93          return "XmlDocumentStart{" +
94                  "encoding='" + encoding + '\'' +
95                  ", version='" + version + '\'' +
96                  ", standalone=" + standalone +
97                  ", encodingScheme='" + encodingScheme + '\'' +
98                  '}';
99      }
100 }