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