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