001//
002// Generated by protoc, do not edit by hand.
003//
004package org.apache.activemq.leveldb.record;
005
006
007public class CollectionRecord implements org.fusesource.hawtbuf.proto.PBMessageFactory<CollectionRecord.Bean, CollectionRecord.Buffer> {
008
009   public static final CollectionRecord FACTORY = new CollectionRecord();
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<CollectionRecord.Bean, CollectionRecord.Buffer> {
063
064      // optional int64 key = 1;
065      public boolean hasKey();
066      public long getKey();
067      // optional int32 type = 2;
068      public boolean hasType();
069      public int getType();
070      // optional bytes meta = 3;
071      public boolean hasMeta();
072      public org.fusesource.hawtbuf.Buffer getMeta();
073      public Bean copy();
074      public Buffer freeze();
075      public java.lang.StringBuilder toString(java.lang.StringBuilder sb, String prefix);
076   }
077
078   static public final class Bean implements Getter {
079
080      Buffer frozen;
081      Bean bean;
082
083      public Bean() {
084         this.bean = this;
085      }
086
087      public Bean(Bean copy) {
088         this.bean = copy;
089      }
090
091      public Bean copy() {
092         return new Bean(bean);
093      }
094
095      public boolean frozen() {
096         return frozen!=null;
097      }
098
099      public Buffer freeze() {
100         if( frozen==null ) {
101            frozen = new Buffer(bean);
102            assert deepFreeze();
103         }
104         return frozen;
105      }
106
107      private boolean deepFreeze() {
108         frozen.serializedSizeUnframed();
109         return true;
110      }
111
112      private void copyCheck() {
113         assert frozen==null : org.fusesource.hawtbuf.proto.MessageBufferSupport.FORZEN_ERROR_MESSAGE;
114         if (bean != this) {
115            copy(bean);
116         }
117      }
118
119      private void copy(Bean other) {
120         this.bean = this;
121         this.f_key = other.f_key;
122         this.b_key = other.b_key;
123         this.f_type = other.f_type;
124         this.b_type = other.b_type;
125         this.f_meta = other.f_meta;
126      }
127
128      // optional int64 key = 1;
129      private long f_key = 0;
130      private boolean b_key;
131
132      public boolean hasKey() {
133         return bean.b_key;
134      }
135
136      public long getKey() {
137         return bean.f_key;
138      }
139
140      public Bean setKey(long key) {
141         copyCheck();
142         this.b_key = true;
143         this.f_key = key;
144         return this;
145      }
146
147      public void clearKey() {
148         copyCheck();
149         this.b_key = false;
150         this.f_key = 0;
151      }
152
153      // optional int32 type = 2;
154      private int f_type = 0;
155      private boolean b_type;
156
157      public boolean hasType() {
158         return bean.b_type;
159      }
160
161      public int getType() {
162         return bean.f_type;
163      }
164
165      public Bean setType(int type) {
166         copyCheck();
167         this.b_type = true;
168         this.f_type = type;
169         return this;
170      }
171
172      public void clearType() {
173         copyCheck();
174         this.b_type = false;
175         this.f_type = 0;
176      }
177
178      // optional bytes meta = 3;
179      private org.fusesource.hawtbuf.Buffer f_meta = null;
180
181      public boolean hasMeta() {
182         return bean.f_meta!=null;
183      }
184
185      public org.fusesource.hawtbuf.Buffer getMeta() {
186         return bean.f_meta;
187      }
188
189      public Bean setMeta(org.fusesource.hawtbuf.Buffer meta) {
190         copyCheck();
191         this.f_meta = meta;
192         return this;
193      }
194
195      public void clearMeta() {
196         copyCheck();
197         this.f_meta = null;
198      }
199
200      public String toString() {
201         return toString(new java.lang.StringBuilder(), "").toString();
202      }
203
204      public java.lang.StringBuilder toString(java.lang.StringBuilder sb, String prefix) {
205         if(  hasKey() ) {
206            sb.append(prefix+"key: ");
207            sb.append(getKey());
208            sb.append("\n");
209         }
210         if(  hasType() ) {
211            sb.append(prefix+"type: ");
212            sb.append(getType());
213            sb.append("\n");
214         }
215         if(  hasMeta() ) {
216            sb.append(prefix+"meta: ");
217            sb.append(getMeta());
218            sb.append("\n");
219         }
220         return sb;
221      }
222
223      public Bean mergeUnframed(java.io.InputStream input) throws java.io.IOException {
224         return mergeUnframed(new org.fusesource.hawtbuf.proto.CodedInputStream(input));
225      }
226
227      public Bean mergeUnframed(org.fusesource.hawtbuf.proto.CodedInputStream input) throws java.io.IOException {
228         copyCheck();
229         while (true) {
230            int tag = input.readTag();
231            if ((tag & 0x07) == 4) {
232               return this;
233            }
234            switch (tag) {
235            case 0:
236               return this;
237            default: {
238               input.skipField(tag);
239               break;
240            }
241            case 8:
242               setKey(input.readInt64());
243               break;
244            case 16:
245               setType(input.readInt32());
246               break;
247            case 26:
248               setMeta(input.readBytes());
249               break;
250            }
251         }
252      }
253      public boolean equals(Object obj) {
254         if( obj==this )
255            return true;
256         
257         if( obj==null || obj.getClass()!=Bean.class )
258            return false;
259         
260         return equals((Bean)obj);
261      }
262      
263      public boolean equals(Bean obj) {
264         if (hasKey() ^ obj.hasKey() ) 
265            return false;
266         if (hasKey() && ( getKey()!=obj.getKey() ))
267            return false;
268         if (hasType() ^ obj.hasType() ) 
269            return false;
270         if (hasType() && ( getType()!=obj.getType() ))
271            return false;
272         if (hasMeta() ^ obj.hasMeta() ) 
273            return false;
274         if (hasMeta() && ( !getMeta().equals(obj.getMeta()) ))
275            return false;
276         return true;
277      }
278      
279      public int hashCode() {
280         int rc=2066384;
281         if (hasKey()) {
282            rc ^= ( 75327^(new Long(getKey())).hashCode() );
283         }
284         if (hasType()) {
285            rc ^= ( 2622298^getType() );
286         }
287         if (hasMeta()) {
288            rc ^= ( 2394661^getMeta().hashCode() );
289         }
290         return rc;
291      }
292      
293      public Bean mergeFrom(Getter other) {
294         copyCheck();
295         if (other.hasKey()) {
296            setKey(other.getKey());
297         }
298         if (other.hasType()) {
299            setType(other.getType());
300         }
301         if (other.hasMeta()) {
302            setMeta(other.getMeta());
303         }
304         return this;
305      }
306
307      public void clear() {
308         clearKey();
309         clearType();
310         clearMeta();
311      }
312
313      public void readExternal(java.io.DataInput in) throws java.io.IOException {
314         assert frozen==null : org.fusesource.hawtbuf.proto.MessageBufferSupport.FORZEN_ERROR_MESSAGE;
315         bean = this;
316         frozen = null;
317         f_key = in.readLong();
318         b_key = true;
319         f_type = in.readInt();
320         b_type = true;
321         {
322            int size = in.readInt();
323            if( size>=0 ) {
324               byte b[] = new byte[size];
325               in.readFully(b);
326               f_meta = new org.fusesource.hawtbuf.Buffer(b);
327            } else {
328               f_meta = null;
329            }
330         }
331      }
332
333      public void writeExternal(java.io.DataOutput out) throws java.io.IOException {
334         out.writeLong(bean.f_key);
335         out.writeInt(bean.f_type);
336         if( bean.f_meta!=null ) {
337            out.writeInt(bean.f_meta.getLength());
338            out.write(bean.f_meta.getData(), bean.f_meta.getOffset(), bean.f_meta.getLength());
339         } else {
340            out.writeInt(-1);
341         }
342      }
343
344   }
345
346   static public final class Buffer implements org.fusesource.hawtbuf.proto.MessageBuffer<CollectionRecord.Bean, CollectionRecord.Buffer>, Getter {
347
348      private Bean bean;
349      private org.fusesource.hawtbuf.Buffer buffer;
350      private int size=-1;
351      private int hashCode;
352
353      private Buffer(org.fusesource.hawtbuf.Buffer buffer) {
354         this.buffer = buffer;
355      }
356
357      private Buffer(Bean bean) {
358         this.bean = bean;
359      }
360
361      public Bean copy() {
362         return bean().copy();
363      }
364
365      public Buffer freeze() {
366         return this;
367      }
368
369      private Bean bean() {
370         if (bean == null) {
371            try {
372               bean = new Bean().mergeUnframed(new org.fusesource.hawtbuf.proto.CodedInputStream(buffer));
373               bean.frozen=this;
374            } catch (org.fusesource.hawtbuf.proto.InvalidProtocolBufferException e) {
375               throw new RuntimeException(e);
376            } catch (java.io.IOException e) {
377               throw new RuntimeException("An IOException was thrown (should never happen in this method).", e);
378            }
379         }
380         return bean;
381      }
382
383      public String toString() {
384         return bean().toString();
385      }
386
387      public java.lang.StringBuilder toString(java.lang.StringBuilder sb, String prefix) {
388         return bean().toString(sb, prefix);
389      }
390
391      // optional int64 key = 1;
392      public boolean hasKey() {
393         return bean().hasKey();
394      }
395
396      public long getKey() {
397         return bean().getKey();
398      }
399
400      // optional int32 type = 2;
401      public boolean hasType() {
402         return bean().hasType();
403      }
404
405      public int getType() {
406         return bean().getType();
407      }
408
409      // optional bytes meta = 3;
410      public boolean hasMeta() {
411         return bean().hasMeta();
412      }
413
414      public org.fusesource.hawtbuf.Buffer getMeta() {
415         return bean().getMeta();
416      }
417
418      public org.fusesource.hawtbuf.Buffer toUnframedBuffer() {
419         if( buffer !=null ) {
420            return buffer;
421         }
422         return org.fusesource.hawtbuf.proto.MessageBufferSupport.toUnframedBuffer(this);
423      }
424
425      public org.fusesource.hawtbuf.Buffer toFramedBuffer() {
426         return org.fusesource.hawtbuf.proto.MessageBufferSupport.toFramedBuffer(this);
427      }
428
429      public byte[] toUnframedByteArray() {
430         return toUnframedBuffer().toByteArray();
431      }
432
433      public byte[] toFramedByteArray() {
434         return toFramedBuffer().toByteArray();
435      }
436
437      public void writeFramed(org.fusesource.hawtbuf.proto.CodedOutputStream output) throws java.io.IOException {
438         output.writeRawVarint32(serializedSizeUnframed());
439         writeUnframed(output);
440      }
441
442      public void writeFramed(java.io.OutputStream output) throws java.io.IOException {
443         org.fusesource.hawtbuf.proto.CodedOutputStream codedOutput = new org.fusesource.hawtbuf.proto.CodedOutputStream(output);
444         writeFramed(codedOutput);
445         codedOutput.flush();
446      }
447
448      public void writeUnframed(java.io.OutputStream output) throws java.io.IOException {
449         org.fusesource.hawtbuf.proto.CodedOutputStream codedOutput = new org.fusesource.hawtbuf.proto.CodedOutputStream(output);
450         writeUnframed(codedOutput);
451         codedOutput.flush();
452      }
453
454      public void writeUnframed(org.fusesource.hawtbuf.proto.CodedOutputStream output) throws java.io.IOException {
455         if (buffer == null) {
456            int size = serializedSizeUnframed();
457            buffer = output.getNextBuffer(size);
458            org.fusesource.hawtbuf.proto.CodedOutputStream original=null;
459            if( buffer == null ) {
460               buffer = new org.fusesource.hawtbuf.Buffer(new byte[size]);
461               original = output;
462               output = new org.fusesource.hawtbuf.proto.CodedOutputStream(buffer);
463            }
464            if (bean.hasKey()) {
465               output.writeInt64(1, bean.getKey());
466            }
467            if (bean.hasType()) {
468               output.writeInt32(2, bean.getType());
469            }
470            if (bean.hasMeta()) {
471               output.writeBytes(3, bean.getMeta());
472            }
473            if( original !=null ) {
474               output.checkNoSpaceLeft();
475               output = original;
476               output.writeRawBytes(buffer);
477            }
478         } else {
479            output.writeRawBytes(buffer);
480         }
481      }
482
483      public int serializedSizeFramed() {
484         int t = serializedSizeUnframed();
485         return org.fusesource.hawtbuf.proto.CodedOutputStream.computeRawVarint32Size(t) + t;
486      }
487
488      public int serializedSizeUnframed() {
489         if (buffer != null) {
490            return buffer.length;
491         }
492         if (size != -1)
493            return size;
494
495         size = 0;
496         if (hasKey()) {
497            size += org.fusesource.hawtbuf.proto.CodedOutputStream.computeInt64Size(1, getKey());
498         }
499         if (hasType()) {
500            size += org.fusesource.hawtbuf.proto.CodedOutputStream.computeInt32Size(2, getType());
501         }
502         if (hasMeta()) {
503            size += org.fusesource.hawtbuf.proto.CodedOutputStream.computeBytesSize(3, getMeta());
504         }
505         return size;
506      }
507
508      public boolean equals(Object obj) {
509         if( obj==this )
510            return true;
511         
512         if( obj==null || obj.getClass()!=Buffer.class )
513            return false;
514         
515         return equals((Buffer)obj);
516      }
517      
518      public boolean equals(Buffer obj) {
519         return toUnframedBuffer().equals(obj.toUnframedBuffer());
520      }
521      
522      public int hashCode() {
523         if( hashCode==0 ) {
524         hashCode=2000715872 ^ toUnframedBuffer().hashCode();
525         }
526         return hashCode;
527      }
528      
529      public boolean frozen() {
530         return true;
531      }
532   }
533
534}
535