001    //
002    // Generated by protoc, do not edit by hand.
003    //
004    package org.apache.activemq.leveldb.record;
005    
006    
007    public 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                   break;
239                }
240                case 8:
241                   setKey(input.readInt64());
242                   break;
243                case 16:
244                   setType(input.readInt32());
245                   break;
246                case 26:
247                   setMeta(input.readBytes());
248                   break;
249                }
250             }
251          }
252          public boolean equals(Object obj) {
253             if( obj==this )
254                return true;
255             
256             if( obj==null || obj.getClass()!=Bean.class )
257                return false;
258             
259             return equals((Bean)obj);
260          }
261          
262          public boolean equals(Bean obj) {
263             if (hasKey() ^ obj.hasKey() ) 
264                return false;
265             if (hasKey() && ( getKey()!=obj.getKey() ))
266                return false;
267             if (hasType() ^ obj.hasType() ) 
268                return false;
269             if (hasType() && ( getType()!=obj.getType() ))
270                return false;
271             if (hasMeta() ^ obj.hasMeta() ) 
272                return false;
273             if (hasMeta() && ( !getMeta().equals(obj.getMeta()) ))
274                return false;
275             return true;
276          }
277          
278          public int hashCode() {
279             int rc=2066384;
280             if (hasKey()) {
281                rc ^= ( 75327^(new Long(getKey())).hashCode() );
282             }
283             if (hasType()) {
284                rc ^= ( 2622298^getType() );
285             }
286             if (hasMeta()) {
287                rc ^= ( 2394661^getMeta().hashCode() );
288             }
289             return rc;
290          }
291          
292          public Bean mergeFrom(Getter other) {
293             copyCheck();
294             if (other.hasKey()) {
295                setKey(other.getKey());
296             }
297             if (other.hasType()) {
298                setType(other.getType());
299             }
300             if (other.hasMeta()) {
301                setMeta(other.getMeta());
302             }
303             return this;
304          }
305    
306          public void clear() {
307             clearKey();
308             clearType();
309             clearMeta();
310          }
311    
312          public void readExternal(java.io.DataInput in) throws java.io.IOException {
313             assert frozen==null : org.fusesource.hawtbuf.proto.MessageBufferSupport.FORZEN_ERROR_MESSAGE;
314             bean = this;
315             frozen = null;
316             f_key = in.readLong();
317             b_key = true;
318             f_type = in.readInt();
319             b_type = true;
320             {
321                int size = in.readInt();
322                if( size>=0 ) {
323                   byte b[] = new byte[size];
324                   in.readFully(b);
325                   f_meta = new org.fusesource.hawtbuf.Buffer(b);
326                } else {
327                   f_meta = null;
328                }
329             }
330          }
331    
332          public void writeExternal(java.io.DataOutput out) throws java.io.IOException {
333             out.writeLong(bean.f_key);
334             out.writeInt(bean.f_type);
335             if( bean.f_meta!=null ) {
336                out.writeInt(bean.f_meta.getLength());
337                out.write(bean.f_meta.getData(), bean.f_meta.getOffset(), bean.f_meta.getLength());
338             } else {
339                out.writeInt(-1);
340             }
341          }
342    
343       }
344    
345       static public final class Buffer implements org.fusesource.hawtbuf.proto.MessageBuffer<CollectionRecord.Bean, CollectionRecord.Buffer>, Getter {
346    
347          private Bean bean;
348          private org.fusesource.hawtbuf.Buffer buffer;
349          private int size=-1;
350          private int hashCode;
351    
352          private Buffer(org.fusesource.hawtbuf.Buffer buffer) {
353             this.buffer = buffer;
354          }
355    
356          private Buffer(Bean bean) {
357             this.bean = bean;
358          }
359    
360          public Bean copy() {
361             return bean().copy();
362          }
363    
364          public Buffer freeze() {
365             return this;
366          }
367    
368          private Bean bean() {
369             if (bean == null) {
370                try {
371                   bean = new Bean().mergeUnframed(new org.fusesource.hawtbuf.proto.CodedInputStream(buffer));
372                   bean.frozen=this;
373                } catch (org.fusesource.hawtbuf.proto.InvalidProtocolBufferException e) {
374                   throw new RuntimeException(e);
375                } catch (java.io.IOException e) {
376                   throw new RuntimeException("An IOException was thrown (should never happen in this method).", e);
377                }
378             }
379             return bean;
380          }
381    
382          public String toString() {
383             return bean().toString();
384          }
385    
386          public java.lang.StringBuilder toString(java.lang.StringBuilder sb, String prefix) {
387             return bean().toString(sb, prefix);
388          }
389    
390          // optional int64 key = 1;
391          public boolean hasKey() {
392             return bean().hasKey();
393          }
394    
395          public long getKey() {
396             return bean().getKey();
397          }
398    
399          // optional int32 type = 2;
400          public boolean hasType() {
401             return bean().hasType();
402          }
403    
404          public int getType() {
405             return bean().getType();
406          }
407    
408          // optional bytes meta = 3;
409          public boolean hasMeta() {
410             return bean().hasMeta();
411          }
412    
413          public org.fusesource.hawtbuf.Buffer getMeta() {
414             return bean().getMeta();
415          }
416    
417          public org.fusesource.hawtbuf.Buffer toUnframedBuffer() {
418             if( buffer !=null ) {
419                return buffer;
420             }
421             return org.fusesource.hawtbuf.proto.MessageBufferSupport.toUnframedBuffer(this);
422          }
423    
424          public org.fusesource.hawtbuf.Buffer toFramedBuffer() {
425             return org.fusesource.hawtbuf.proto.MessageBufferSupport.toFramedBuffer(this);
426          }
427    
428          public byte[] toUnframedByteArray() {
429             return toUnframedBuffer().toByteArray();
430          }
431    
432          public byte[] toFramedByteArray() {
433             return toFramedBuffer().toByteArray();
434          }
435    
436          public void writeFramed(org.fusesource.hawtbuf.proto.CodedOutputStream output) throws java.io.IOException {
437             output.writeRawVarint32(serializedSizeUnframed());
438             writeUnframed(output);
439          }
440    
441          public void writeFramed(java.io.OutputStream output) throws java.io.IOException {
442             org.fusesource.hawtbuf.proto.CodedOutputStream codedOutput = new org.fusesource.hawtbuf.proto.CodedOutputStream(output);
443             writeFramed(codedOutput);
444             codedOutput.flush();
445          }
446    
447          public void writeUnframed(java.io.OutputStream output) throws java.io.IOException {
448             org.fusesource.hawtbuf.proto.CodedOutputStream codedOutput = new org.fusesource.hawtbuf.proto.CodedOutputStream(output);
449             writeUnframed(codedOutput);
450             codedOutput.flush();
451          }
452    
453          public void writeUnframed(org.fusesource.hawtbuf.proto.CodedOutputStream output) throws java.io.IOException {
454             if (buffer == null) {
455                int size = serializedSizeUnframed();
456                buffer = output.getNextBuffer(size);
457                org.fusesource.hawtbuf.proto.CodedOutputStream original=null;
458                if( buffer == null ) {
459                   buffer = new org.fusesource.hawtbuf.Buffer(new byte[size]);
460                   original = output;
461                   output = new org.fusesource.hawtbuf.proto.CodedOutputStream(buffer);
462                }
463                if (bean.hasKey()) {
464                   output.writeInt64(1, bean.getKey());
465                }
466                if (bean.hasType()) {
467                   output.writeInt32(2, bean.getType());
468                }
469                if (bean.hasMeta()) {
470                   output.writeBytes(3, bean.getMeta());
471                }
472                if( original !=null ) {
473                   output.checkNoSpaceLeft();
474                   output = original;
475                   output.writeRawBytes(buffer);
476                }
477             } else {
478                output.writeRawBytes(buffer);
479             }
480          }
481    
482          public int serializedSizeFramed() {
483             int t = serializedSizeUnframed();
484             return org.fusesource.hawtbuf.proto.CodedOutputStream.computeRawVarint32Size(t) + t;
485          }
486    
487          public int serializedSizeUnframed() {
488             if (buffer != null) {
489                return buffer.length;
490             }
491             if (size != -1)
492                return size;
493    
494             size = 0;
495             if (hasKey()) {
496                size += org.fusesource.hawtbuf.proto.CodedOutputStream.computeInt64Size(1, getKey());
497             }
498             if (hasType()) {
499                size += org.fusesource.hawtbuf.proto.CodedOutputStream.computeInt32Size(2, getType());
500             }
501             if (hasMeta()) {
502                size += org.fusesource.hawtbuf.proto.CodedOutputStream.computeBytesSize(3, getMeta());
503             }
504             return size;
505          }
506    
507          public boolean equals(Object obj) {
508             if( obj==this )
509                return true;
510             
511             if( obj==null || obj.getClass()!=Buffer.class )
512                return false;
513             
514             return equals((Buffer)obj);
515          }
516          
517          public boolean equals(Buffer obj) {
518             return toUnframedBuffer().equals(obj.toUnframedBuffer());
519          }
520          
521          public int hashCode() {
522             if( hashCode==0 ) {
523             hashCode=2000715872 ^ toUnframedBuffer().hashCode();
524             }
525             return hashCode;
526          }
527          
528          public boolean frozen() {
529             return true;
530          }
531       }
532    
533    }
534