1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.codec.string;
17
18 import io.netty.buffer.ByteBufUtil;
19 import io.netty.util.CharsetUtil;
20 import io.netty.util.internal.ObjectUtil;
21 import io.netty.util.internal.StringUtil;
22
23
24
25
26 public final class LineSeparator {
27
28
29
30
31 public static final LineSeparator DEFAULT = new LineSeparator(StringUtil.NEWLINE);
32
33
34
35
36 public static final LineSeparator UNIX = new LineSeparator("\n");
37
38
39
40
41 public static final LineSeparator WINDOWS = new LineSeparator("\r\n");
42
43 private final String value;
44
45
46
47
48 public LineSeparator(String lineSeparator) {
49 this.value = ObjectUtil.checkNotNull(lineSeparator, "lineSeparator");
50 }
51
52
53
54
55 public String value() {
56 return value;
57 }
58
59 @Override
60 public boolean equals(Object o) {
61 if (this == o) {
62 return true;
63 }
64 if (!(o instanceof LineSeparator)) {
65 return false;
66 }
67 LineSeparator that = (LineSeparator) o;
68 return value != null ? value.equals(that.value) : that.value == null;
69 }
70
71 @Override
72 public int hashCode() {
73 return value != null ? value.hashCode() : 0;
74 }
75
76
77
78
79 @Override
80 public String toString() {
81 return ByteBufUtil.hexDump(value.getBytes(CharsetUtil.UTF_8));
82 }
83 }