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