001//
002// Generated by protoc, do not edit by hand.
003//
004package org.apache.activemq.leveldb.record;
005
006
007public 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               input.skipField(tag);
204               break;
205            }
206            case 8:
207               setCollectionKey(input.readInt64());
208               break;
209            case 18:
210               setEntryKey(input.readBytes());
211               break;
212            }
213         }
214      }
215      public boolean equals(Object obj) {
216         if( obj==this )
217            return true;
218         
219         if( obj==null || obj.getClass()!=Bean.class )
220            return false;
221         
222         return equals((Bean)obj);
223      }
224      
225      public boolean equals(Bean obj) {
226         if (hasCollectionKey() ^ obj.hasCollectionKey() ) 
227            return false;
228         if (hasCollectionKey() && ( getCollectionKey()!=obj.getCollectionKey() ))
229            return false;
230         if (hasEntryKey() ^ obj.hasEntryKey() ) 
231            return false;
232         if (hasEntryKey() && ( !getEntryKey().equals(obj.getEntryKey()) ))
233            return false;
234         return true;
235      }
236      
237      public int hashCode() {
238         int rc=2066384;
239         if (hasCollectionKey()) {
240            rc ^= ( -22299967^(new Long(getCollectionKey())).hashCode() );
241         }
242         if (hasEntryKey()) {
243            rc ^= ( -2029038419^getEntryKey().hashCode() );
244         }
245         return rc;
246      }
247      
248      public Bean mergeFrom(Getter other) {
249         copyCheck();
250         if (other.hasCollectionKey()) {
251            setCollectionKey(other.getCollectionKey());
252         }
253         if (other.hasEntryKey()) {
254            setEntryKey(other.getEntryKey());
255         }
256         return this;
257      }
258
259      public void clear() {
260         clearCollectionKey();
261         clearEntryKey();
262      }
263
264      public void readExternal(java.io.DataInput in) throws java.io.IOException {
265         assert frozen==null : org.fusesource.hawtbuf.proto.MessageBufferSupport.FORZEN_ERROR_MESSAGE;
266         bean = this;
267         frozen = null;
268         f_collectionKey = in.readLong();
269         b_collectionKey = true;
270         {
271            int size = in.readInt();
272            if( size>=0 ) {
273               byte b[] = new byte[size];
274               in.readFully(b);
275               f_entryKey = new org.fusesource.hawtbuf.Buffer(b);
276            } else {
277               f_entryKey = null;
278            }
279         }
280      }
281
282      public void writeExternal(java.io.DataOutput out) throws java.io.IOException {
283         out.writeLong(bean.f_collectionKey);
284         if( bean.f_entryKey!=null ) {
285            out.writeInt(bean.f_entryKey.getLength());
286            out.write(bean.f_entryKey.getData(), bean.f_entryKey.getOffset(), bean.f_entryKey.getLength());
287         } else {
288            out.writeInt(-1);
289         }
290      }
291
292   }
293
294   static public final class Buffer implements org.fusesource.hawtbuf.proto.MessageBuffer<EntryKey.Bean, EntryKey.Buffer>, Getter {
295
296      private Bean bean;
297      private org.fusesource.hawtbuf.Buffer buffer;
298      private int size=-1;
299      private int hashCode;
300
301      private Buffer(org.fusesource.hawtbuf.Buffer buffer) {
302         this.buffer = buffer;
303      }
304
305      private Buffer(Bean bean) {
306         this.bean = bean;
307      }
308
309      public Bean copy() {
310         return bean().copy();
311      }
312
313      public Buffer freeze() {
314         return this;
315      }
316
317      private Bean bean() {
318         if (bean == null) {
319            try {
320               bean = new Bean().mergeUnframed(new org.fusesource.hawtbuf.proto.CodedInputStream(buffer));
321               bean.frozen=this;
322            } catch (org.fusesource.hawtbuf.proto.InvalidProtocolBufferException e) {
323               throw new RuntimeException(e);
324            } catch (java.io.IOException e) {
325               throw new RuntimeException("An IOException was thrown (should never happen in this method).", e);
326            }
327         }
328         return bean;
329      }
330
331      public String toString() {
332         return bean().toString();
333      }
334
335      public java.lang.StringBuilder toString(java.lang.StringBuilder sb, String prefix) {
336         return bean().toString(sb, prefix);
337      }
338
339      // required int64 collection_key = 1;
340      public boolean hasCollectionKey() {
341         return bean().hasCollectionKey();
342      }
343
344      public long getCollectionKey() {
345         return bean().getCollectionKey();
346      }
347
348      // required bytes entry_key = 2;
349      public boolean hasEntryKey() {
350         return bean().hasEntryKey();
351      }
352
353      public org.fusesource.hawtbuf.Buffer getEntryKey() {
354         return bean().getEntryKey();
355      }
356
357      public org.fusesource.hawtbuf.Buffer toUnframedBuffer() {
358         if( buffer !=null ) {
359            return buffer;
360         }
361         return org.fusesource.hawtbuf.proto.MessageBufferSupport.toUnframedBuffer(this);
362      }
363
364      public org.fusesource.hawtbuf.Buffer toFramedBuffer() {
365         return org.fusesource.hawtbuf.proto.MessageBufferSupport.toFramedBuffer(this);
366      }
367
368      public byte[] toUnframedByteArray() {
369         return toUnframedBuffer().toByteArray();
370      }
371
372      public byte[] toFramedByteArray() {
373         return toFramedBuffer().toByteArray();
374      }
375
376      public void writeFramed(org.fusesource.hawtbuf.proto.CodedOutputStream output) throws java.io.IOException {
377         output.writeRawVarint32(serializedSizeUnframed());
378         writeUnframed(output);
379      }
380
381      public void writeFramed(java.io.OutputStream output) throws java.io.IOException {
382         org.fusesource.hawtbuf.proto.CodedOutputStream codedOutput = new org.fusesource.hawtbuf.proto.CodedOutputStream(output);
383         writeFramed(codedOutput);
384         codedOutput.flush();
385      }
386
387      public void writeUnframed(java.io.OutputStream output) throws java.io.IOException {
388         org.fusesource.hawtbuf.proto.CodedOutputStream codedOutput = new org.fusesource.hawtbuf.proto.CodedOutputStream(output);
389         writeUnframed(codedOutput);
390         codedOutput.flush();
391      }
392
393      public void writeUnframed(org.fusesource.hawtbuf.proto.CodedOutputStream output) throws java.io.IOException {
394         if (buffer == null) {
395            int size = serializedSizeUnframed();
396            buffer = output.getNextBuffer(size);
397            org.fusesource.hawtbuf.proto.CodedOutputStream original=null;
398            if( buffer == null ) {
399               buffer = new org.fusesource.hawtbuf.Buffer(new byte[size]);
400               original = output;
401               output = new org.fusesource.hawtbuf.proto.CodedOutputStream(buffer);
402            }
403            output.writeInt64(1, bean.getCollectionKey());
404            output.writeBytes(2, bean.getEntryKey());
405            if( original !=null ) {
406               output.checkNoSpaceLeft();
407               output = original;
408               output.writeRawBytes(buffer);
409            }
410         } else {
411            output.writeRawBytes(buffer);
412         }
413      }
414
415      public int serializedSizeFramed() {
416         int t = serializedSizeUnframed();
417         return org.fusesource.hawtbuf.proto.CodedOutputStream.computeRawVarint32Size(t) + t;
418      }
419
420      public int serializedSizeUnframed() {
421         if (buffer != null) {
422            return buffer.length;
423         }
424         if (size != -1)
425            return size;
426
427         size = 0;
428         size += org.fusesource.hawtbuf.proto.CodedOutputStream.computeInt64Size(1, getCollectionKey());
429         size += org.fusesource.hawtbuf.proto.CodedOutputStream.computeBytesSize(2, getEntryKey());
430         return size;
431      }
432
433      public boolean equals(Object obj) {
434         if( obj==this )
435            return true;
436         
437         if( obj==null || obj.getClass()!=Buffer.class )
438            return false;
439         
440         return equals((Buffer)obj);
441      }
442      
443      public boolean equals(Buffer obj) {
444         return toUnframedBuffer().equals(obj.toUnframedBuffer());
445      }
446      
447      public int hashCode() {
448         if( hashCode==0 ) {
449         hashCode=2000715872 ^ toUnframedBuffer().hashCode();
450         }
451         return hashCode;
452      }
453      
454      public boolean frozen() {
455         return true;
456      }
457   }
458
459}
460