1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.hbtop.terminal.impl;
19
20 import java.util.Objects;
21
22 import org.apache.hadoop.hbase.classification.InterfaceAudience;
23 import org.apache.hadoop.hbase.hbtop.terminal.Attributes;
24 import org.apache.hadoop.hbase.hbtop.terminal.Color;
25
26
27
28
29 @InterfaceAudience.Private
30 public class Cell {
31 private static final char UNSET_VALUE = (char) 65535;
32 private static final char END_OF_LINE = '\0';
33
34 private final Attributes attributes;
35 private char ch;
36
37 public Cell() {
38 attributes = new Attributes();
39 ch = ' ';
40 }
41
42 public char getChar() {
43 return ch;
44 }
45
46 public void setChar(char ch) {
47 this.ch = ch;
48 }
49
50 public void reset() {
51 attributes.reset();
52 ch = ' ';
53 }
54
55 public void unset() {
56 attributes.reset();
57 ch = UNSET_VALUE;
58 }
59
60 public void endOfLine() {
61 attributes.reset();
62 ch = END_OF_LINE;
63 }
64
65 public boolean isEndOfLine() {
66 return ch == END_OF_LINE;
67 }
68
69 public void set(Cell cell) {
70 attributes.set(cell.attributes);
71 this.ch = cell.ch;
72 }
73
74 public Attributes getAttributes() {
75 return new Attributes(attributes);
76 }
77
78 public void setAttributes(Attributes attributes) {
79 this.attributes.set(attributes);
80 }
81
82 public boolean isBold() {
83 return attributes.isBold();
84 }
85
86 public boolean isBlink() {
87 return attributes.isBlink();
88 }
89
90 public boolean isReverse() {
91 return attributes.isReverse();
92 }
93
94 public boolean isUnderline() {
95 return attributes.isUnderline();
96 }
97
98 public Color getForegroundColor() {
99 return attributes.getForegroundColor();
100 }
101
102 public Color getBackgroundColor() {
103 return attributes.getBackgroundColor();
104 }
105
106 @Override
107 public boolean equals(Object o) {
108 if (this == o) {
109 return true;
110 }
111 if (!(o instanceof Cell)) {
112 return false;
113 }
114 Cell cell = (Cell) o;
115 return ch == cell.ch && attributes.equals(cell.attributes);
116 }
117
118 @Override
119 public int hashCode() {
120 return Objects.hash(attributes, ch);
121 }
122 }