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    *   http://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) { return true; }
58          if (o == null || getClass() != o.getClass()) { return false; }
59  
60          XmlDocumentStart that = (XmlDocumentStart) o;
61  
62          if (standalone != that.standalone) { return false; }
63          if (encoding != null ? !encoding.equals(that.encoding) : that.encoding != null) { return false; }
64          if (encodingScheme != null ? !encodingScheme.equals(that.encodingScheme) : that.encodingScheme != null) {
65              return false;
66          }
67          if (version != null ? !version.equals(that.version) : that.version != null) { return false; }
68  
69          return true;
70      }
71  
72      @Override
73      public int hashCode() {
74          int result = encoding != null ? encoding.hashCode() : 0;
75          result = 31 * result + (version != null ? version.hashCode() : 0);
76          result = 31 * result + (standalone ? 1 : 0);
77          result = 31 * result + (encodingScheme != null ? encodingScheme.hashCode() : 0);
78          return result;
79      }
80  
81      @Override
82      public String toString() {
83          return "XmlDocumentStart{" +
84                  "encoding='" + encoding + '\'' +
85                  ", version='" + version + '\'' +
86                  ", standalone=" + standalone +
87                  ", encodingScheme='" + encodingScheme + '\'' +
88                  '}';
89      }
90  }