001 //
002 // Generated by protoc, do not edit by hand.
003 //
004 package org.apache.activemq.leveldb.record;
005
006
007 public class CollectionKey implements org.fusesource.hawtbuf.proto.PBMessageFactory<CollectionKey.Bean, CollectionKey.Buffer> {
008
009 public static final CollectionKey FACTORY = new CollectionKey();
010 public static final org.fusesource.hawtbuf.proto.PBMessageFramedCodec<Buffer> FRAMED_CODEC = new org.fusesource.hawtbuf.proto.PBMessageFramedCodec<Buffer>(FACTORY);
011 public static final org.fusesource.hawtbuf.proto.PBMessageUnframedCodec<Buffer> UNFRAMED_CODEC = new org.fusesource.hawtbuf.proto.PBMessageUnframedCodec<Buffer>(FACTORY);
012
013 public Bean create() {
014 return new Bean();
015 }
016
017 public Bean parseUnframed(org.fusesource.hawtbuf.proto.CodedInputStream data) throws org.fusesource.hawtbuf.proto.InvalidProtocolBufferException, java.io.IOException {
018 return new Bean().mergeUnframed(data);
019 }
020
021 public Bean parseUnframed(java.io.InputStream data) throws org.fusesource.hawtbuf.proto.InvalidProtocolBufferException, java.io.IOException {
022 return parseUnframed(new org.fusesource.hawtbuf.proto.CodedInputStream(data));
023 }
024
025 public Buffer parseUnframed(org.fusesource.hawtbuf.Buffer data) throws org.fusesource.hawtbuf.proto.InvalidProtocolBufferException {
026 return new Buffer(data);
027 }
028
029 public Buffer parseUnframed(byte[] data) throws org.fusesource.hawtbuf.proto.InvalidProtocolBufferException {
030 return parseUnframed(new org.fusesource.hawtbuf.Buffer(data));
031 }
032
033 public Buffer parseFramed(org.fusesource.hawtbuf.proto.CodedInputStream data) throws org.fusesource.hawtbuf.proto.InvalidProtocolBufferException, java.io.IOException {
034 int length = data.readRawVarint32();
035 int oldLimit = data.pushLimit(length);
036 Buffer rc = parseUnframed(data.readRawBytes(length));
037 data.popLimit(oldLimit);
038 return rc;
039 }
040
041 public Buffer parseFramed(org.fusesource.hawtbuf.Buffer data) throws org.fusesource.hawtbuf.proto.InvalidProtocolBufferException {
042 try {
043 org.fusesource.hawtbuf.proto.CodedInputStream input = new org.fusesource.hawtbuf.proto.CodedInputStream(data);
044 Buffer rc = parseFramed(input);
045 input.checkLastTagWas(0);
046 return rc;
047 } catch (org.fusesource.hawtbuf.proto.InvalidProtocolBufferException e) {
048 throw e;
049 } catch (java.io.IOException e) {
050 throw new RuntimeException("An IOException was thrown (should never happen in this method).", e);
051 }
052 }
053
054 public Buffer parseFramed(byte[] data) throws org.fusesource.hawtbuf.proto.InvalidProtocolBufferException {
055 return parseFramed(new org.fusesource.hawtbuf.Buffer(data));
056 }
057
058 public Buffer parseFramed(java.io.InputStream data) throws org.fusesource.hawtbuf.proto.InvalidProtocolBufferException, java.io.IOException {
059 return parseUnframed(org.fusesource.hawtbuf.proto.MessageBufferSupport.readFrame(data));
060 }
061
062 public interface Getter extends org.fusesource.hawtbuf.proto.PBMessage<CollectionKey.Bean, CollectionKey.Buffer> {
063
064 // required int64 key = 1;
065 public boolean hasKey();
066 public long getKey();
067 public Bean copy();
068 public Buffer freeze();
069 public java.lang.StringBuilder toString(java.lang.StringBuilder sb, String prefix);
070 }
071
072 static public final class Bean implements Getter {
073
074 Buffer frozen;
075 Bean bean;
076
077 public Bean() {
078 this.bean = this;
079 }
080
081 public Bean(Bean copy) {
082 this.bean = copy;
083 }
084
085 public Bean copy() {
086 return new Bean(bean);
087 }
088
089 public boolean frozen() {
090 return frozen!=null;
091 }
092
093 public Buffer freeze() {
094 if( frozen==null ) {
095 frozen = new Buffer(bean);
096 assert deepFreeze();
097 }
098 return frozen;
099 }
100
101 private boolean deepFreeze() {
102 frozen.serializedSizeUnframed();
103 return true;
104 }
105
106 private void copyCheck() {
107 assert frozen==null : org.fusesource.hawtbuf.proto.MessageBufferSupport.FORZEN_ERROR_MESSAGE;
108 if (bean != this) {
109 copy(bean);
110 }
111 }
112
113 private void copy(Bean other) {
114 this.bean = this;
115 this.f_key = other.f_key;
116 this.b_key = other.b_key;
117 }
118
119 // required int64 key = 1;
120 private long f_key = 0;
121 private boolean b_key;
122
123 public boolean hasKey() {
124 return bean.b_key;
125 }
126
127 public long getKey() {
128 return bean.f_key;
129 }
130
131 public Bean setKey(long key) {
132 copyCheck();
133 this.b_key = true;
134 this.f_key = key;
135 return this;
136 }
137
138 public void clearKey() {
139 copyCheck();
140 this.b_key = false;
141 this.f_key = 0;
142 }
143
144 public String toString() {
145 return toString(new java.lang.StringBuilder(), "").toString();
146 }
147
148 public java.lang.StringBuilder toString(java.lang.StringBuilder sb, String prefix) {
149 if( hasKey() ) {
150 sb.append(prefix+"key: ");
151 sb.append(getKey());
152 sb.append("\n");
153 }
154 return sb;
155 }
156
157 public Bean mergeUnframed(java.io.InputStream input) throws java.io.IOException {
158 return mergeUnframed(new org.fusesource.hawtbuf.proto.CodedInputStream(input));
159 }
160
161 public Bean mergeUnframed(org.fusesource.hawtbuf.proto.CodedInputStream input) throws java.io.IOException {
162 copyCheck();
163 while (true) {
164 int tag = input.readTag();
165 if ((tag & 0x07) == 4) {
166 return this;
167 }
168 switch (tag) {
169 case 0:
170 return this;
171 default: {
172 break;
173 }
174 case 8:
175 setKey(input.readInt64());
176 break;
177 }
178 }
179 }
180 public boolean equals(Object obj) {
181 if( obj==this )
182 return true;
183
184 if( obj==null || obj.getClass()!=Bean.class )
185 return false;
186
187 return equals((Bean)obj);
188 }
189
190 public boolean equals(Bean obj) {
191 if (hasKey() ^ obj.hasKey() )
192 return false;
193 if (hasKey() && ( getKey()!=obj.getKey() ))
194 return false;
195 return true;
196 }
197
198 public int hashCode() {
199 int rc=2066384;
200 if (hasKey()) {
201 rc ^= ( 75327^(new Long(getKey())).hashCode() );
202 }
203 return rc;
204 }
205
206 public Bean mergeFrom(Getter other) {
207 copyCheck();
208 if (other.hasKey()) {
209 setKey(other.getKey());
210 }
211 return this;
212 }
213
214 public void clear() {
215 clearKey();
216 }
217
218 public void readExternal(java.io.DataInput in) throws java.io.IOException {
219 assert frozen==null : org.fusesource.hawtbuf.proto.MessageBufferSupport.FORZEN_ERROR_MESSAGE;
220 bean = this;
221 frozen = null;
222 f_key = in.readLong();
223 b_key = true;
224 }
225
226 public void writeExternal(java.io.DataOutput out) throws java.io.IOException {
227 out.writeLong(bean.f_key);
228 }
229
230 }
231
232 static public final class Buffer implements org.fusesource.hawtbuf.proto.MessageBuffer<CollectionKey.Bean, CollectionKey.Buffer>, Getter {
233
234 private Bean bean;
235 private org.fusesource.hawtbuf.Buffer buffer;
236 private int size=-1;
237 private int hashCode;
238
239 private Buffer(org.fusesource.hawtbuf.Buffer buffer) {
240 this.buffer = buffer;
241 }
242
243 private Buffer(Bean bean) {
244 this.bean = bean;
245 }
246
247 public Bean copy() {
248 return bean().copy();
249 }
250
251 public Buffer freeze() {
252 return this;
253 }
254
255 private Bean bean() {
256 if (bean == null) {
257 try {
258 bean = new Bean().mergeUnframed(new org.fusesource.hawtbuf.proto.CodedInputStream(buffer));
259 bean.frozen=this;
260 } catch (org.fusesource.hawtbuf.proto.InvalidProtocolBufferException e) {
261 throw new RuntimeException(e);
262 } catch (java.io.IOException e) {
263 throw new RuntimeException("An IOException was thrown (should never happen in this method).", e);
264 }
265 }
266 return bean;
267 }
268
269 public String toString() {
270 return bean().toString();
271 }
272
273 public java.lang.StringBuilder toString(java.lang.StringBuilder sb, String prefix) {
274 return bean().toString(sb, prefix);
275 }
276
277 // required int64 key = 1;
278 public boolean hasKey() {
279 return bean().hasKey();
280 }
281
282 public long getKey() {
283 return bean().getKey();
284 }
285
286 public org.fusesource.hawtbuf.Buffer toUnframedBuffer() {
287 if( buffer !=null ) {
288 return buffer;
289 }
290 return org.fusesource.hawtbuf.proto.MessageBufferSupport.toUnframedBuffer(this);
291 }
292
293 public org.fusesource.hawtbuf.Buffer toFramedBuffer() {
294 return org.fusesource.hawtbuf.proto.MessageBufferSupport.toFramedBuffer(this);
295 }
296
297 public byte[] toUnframedByteArray() {
298 return toUnframedBuffer().toByteArray();
299 }
300
301 public byte[] toFramedByteArray() {
302 return toFramedBuffer().toByteArray();
303 }
304
305 public void writeFramed(org.fusesource.hawtbuf.proto.CodedOutputStream output) throws java.io.IOException {
306 output.writeRawVarint32(serializedSizeUnframed());
307 writeUnframed(output);
308 }
309
310 public void writeFramed(java.io.OutputStream output) throws java.io.IOException {
311 org.fusesource.hawtbuf.proto.CodedOutputStream codedOutput = new org.fusesource.hawtbuf.proto.CodedOutputStream(output);
312 writeFramed(codedOutput);
313 codedOutput.flush();
314 }
315
316 public void writeUnframed(java.io.OutputStream output) throws java.io.IOException {
317 org.fusesource.hawtbuf.proto.CodedOutputStream codedOutput = new org.fusesource.hawtbuf.proto.CodedOutputStream(output);
318 writeUnframed(codedOutput);
319 codedOutput.flush();
320 }
321
322 public void writeUnframed(org.fusesource.hawtbuf.proto.CodedOutputStream output) throws java.io.IOException {
323 if (buffer == null) {
324 int size = serializedSizeUnframed();
325 buffer = output.getNextBuffer(size);
326 org.fusesource.hawtbuf.proto.CodedOutputStream original=null;
327 if( buffer == null ) {
328 buffer = new org.fusesource.hawtbuf.Buffer(new byte[size]);
329 original = output;
330 output = new org.fusesource.hawtbuf.proto.CodedOutputStream(buffer);
331 }
332 output.writeInt64(1, bean.getKey());
333 if( original !=null ) {
334 output.checkNoSpaceLeft();
335 output = original;
336 output.writeRawBytes(buffer);
337 }
338 } else {
339 output.writeRawBytes(buffer);
340 }
341 }
342
343 public int serializedSizeFramed() {
344 int t = serializedSizeUnframed();
345 return org.fusesource.hawtbuf.proto.CodedOutputStream.computeRawVarint32Size(t) + t;
346 }
347
348 public int serializedSizeUnframed() {
349 if (buffer != null) {
350 return buffer.length;
351 }
352 if (size != -1)
353 return size;
354
355 size = 0;
356 size += org.fusesource.hawtbuf.proto.CodedOutputStream.computeInt64Size(1, getKey());
357 return size;
358 }
359
360 public boolean equals(Object obj) {
361 if( obj==this )
362 return true;
363
364 if( obj==null || obj.getClass()!=Buffer.class )
365 return false;
366
367 return equals((Buffer)obj);
368 }
369
370 public boolean equals(Buffer obj) {
371 return toUnframedBuffer().equals(obj.toUnframedBuffer());
372 }
373
374 public int hashCode() {
375 if( hashCode==0 ) {
376 hashCode=2000715872 ^ toUnframedBuffer().hashCode();
377 }
378 return hashCode;
379 }
380
381 public boolean frozen() {
382 return true;
383 }
384 }
385
386 }
387