1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.rest.model;
21
22 import java.io.IOException;
23 import java.io.Serializable;
24 import java.util.ArrayList;
25 import java.util.List;
26
27 import javax.xml.bind.annotation.XmlAttribute;
28 import javax.xml.bind.annotation.XmlElement;
29 import javax.xml.bind.annotation.XmlRootElement;
30
31 import org.apache.hadoop.classification.InterfaceAudience;
32 import org.apache.hadoop.hbase.rest.ProtobufMessageHandler;
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 @XmlRootElement(name="Row")
50 @InterfaceAudience.Private
51 public class RowModel implements ProtobufMessageHandler, Serializable {
52 private static final long serialVersionUID = 1L;
53
54 private byte[] key;
55 private List<CellModel> cells = new ArrayList<CellModel>();
56
57
58
59
60 public RowModel() { }
61
62
63
64
65
66 public RowModel(final String key) {
67 this(key.getBytes());
68 }
69
70
71
72
73
74 public RowModel(final byte[] key) {
75 this.key = key;
76 cells = new ArrayList<CellModel>();
77 }
78
79
80
81
82
83
84 public RowModel(final String key, final List<CellModel> cells) {
85 this(key.getBytes(), cells);
86 }
87
88
89
90
91
92
93 public RowModel(final byte[] key, final List<CellModel> cells) {
94 this.key = key;
95 this.cells = cells;
96 }
97
98
99
100
101
102 public void addCell(CellModel cell) {
103 cells.add(cell);
104 }
105
106
107
108
109 @XmlAttribute
110 public byte[] getKey() {
111 return key;
112 }
113
114
115
116
117 public void setKey(byte[] key) {
118 this.key = key;
119 }
120
121
122
123
124 @XmlElement(name="Cell")
125 public List<CellModel> getCells() {
126 return cells;
127 }
128
129 @Override
130 public byte[] createProtobufOutput() {
131
132 throw new UnsupportedOperationException(
133 "no protobuf equivalent to RowModel");
134 }
135
136 @Override
137 public ProtobufMessageHandler getObjectFromMessage(byte[] message)
138 throws IOException {
139
140 throw new UnsupportedOperationException(
141 "no protobuf equivalent to RowModel");
142 }
143 }