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