HBASE-25611 ExportSnapshot chmod flag uses value as decimal (#3003)
[hbase.git] / hbase-common / src / main / java / org / apache / hadoop / hbase / ExtendedCellBuilderImpl.java
bloba8e02ed387ff723b373789c00c930cd82e0df163
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org.apache.hadoop.hbase;
20 import java.util.List;
22 import org.apache.commons.lang3.ArrayUtils;
23 import org.apache.yetus.audience.InterfaceAudience;
25 @InterfaceAudience.Private
26 public abstract class ExtendedCellBuilderImpl implements ExtendedCellBuilder {
27 protected byte[] row = null;
28 protected int rOffset = 0;
29 protected int rLength = 0;
30 protected byte[] family = null;
31 protected int fOffset = 0;
32 protected int fLength = 0;
33 protected byte[] qualifier = null;
34 protected int qOffset = 0;
35 protected int qLength = 0;
36 protected long timestamp = HConstants.LATEST_TIMESTAMP;
37 protected KeyValue.Type type = null;
38 protected byte[] value = null;
39 protected int vOffset = 0;
40 protected int vLength = 0;
41 protected long seqId = 0;
42 protected byte[] tags = null;
43 protected int tagsOffset = 0;
44 protected int tagsLength = 0;
46 @Override
47 public ExtendedCellBuilder setRow(final byte[] row) {
48 return setRow(row, 0, ArrayUtils.getLength(row));
51 @Override
52 public ExtendedCellBuilder setRow(final byte[] row, int rOffset, int rLength) {
53 this.row = row;
54 this.rOffset = rOffset;
55 this.rLength = rLength;
56 return this;
59 @Override
60 public ExtendedCellBuilder setFamily(final byte[] family) {
61 return setFamily(family, 0, ArrayUtils.getLength(family));
64 @Override
65 public ExtendedCellBuilder setFamily(final byte[] family, int fOffset, int fLength) {
66 this.family = family;
67 this.fOffset = fOffset;
68 this.fLength = fLength;
69 return this;
72 @Override
73 public ExtendedCellBuilder setQualifier(final byte[] qualifier) {
74 return setQualifier(qualifier, 0, ArrayUtils.getLength(qualifier));
77 @Override
78 public ExtendedCellBuilder setQualifier(final byte[] qualifier, int qOffset, int qLength) {
79 this.qualifier = qualifier;
80 this.qOffset = qOffset;
81 this.qLength = qLength;
82 return this;
85 @Override
86 public ExtendedCellBuilder setTimestamp(final long timestamp) {
87 this.timestamp = timestamp;
88 return this;
91 @Override
92 public ExtendedCellBuilder setType(final Cell.Type type) {
93 this.type = PrivateCellUtil.toTypeByte(type);
94 return this;
97 @Override
98 public ExtendedCellBuilder setType(final byte type) {
99 this.type = KeyValue.Type.codeToType(type);
100 return this;
103 @Override
104 public ExtendedCellBuilder setValue(final byte[] value) {
105 return setValue(value, 0, ArrayUtils.getLength(value));
108 @Override
109 public ExtendedCellBuilder setValue(final byte[] value, int vOffset, int vLength) {
110 this.value = value;
111 this.vOffset = vOffset;
112 this.vLength = vLength;
113 return this;
116 @Override
117 public ExtendedCellBuilder setTags(final byte[] tags) {
118 return setTags(tags, 0, ArrayUtils.getLength(tags));
121 @Override
122 public ExtendedCellBuilder setTags(final byte[] tags, int tagsOffset, int tagsLength) {
123 this.tags = tags;
124 this.tagsOffset = tagsOffset;
125 this.tagsLength = tagsLength;
126 return this;
129 @Override
130 public ExtendedCellBuilder setTags(List<Tag> tags) {
131 byte[] tagBytes = TagUtil.fromList(tags);
132 return setTags(tagBytes);
135 @Override
136 public ExtendedCellBuilder setSequenceId(final long seqId) {
137 this.seqId = seqId;
138 return this;
141 private void checkBeforeBuild() {
142 if (type == null) {
143 throw new IllegalArgumentException("The type can't be NULL");
147 protected abstract ExtendedCell innerBuild();
149 @Override
150 public ExtendedCell build() {
151 checkBeforeBuild();
152 return innerBuild();
155 @Override
156 public ExtendedCellBuilder clear() {
157 row = null;
158 rOffset = 0;
159 rLength = 0;
160 family = null;
161 fOffset = 0;
162 fLength = 0;
163 qualifier = null;
164 qOffset = 0;
165 qLength = 0;
166 timestamp = HConstants.LATEST_TIMESTAMP;
167 type = null;
168 value = null;
169 vOffset = 0;
170 vLength = 0;
171 seqId = 0;
172 tags = null;
173 tagsOffset = 0;
174 tagsLength = 0;
175 return this;