001// 002// Generated by protoc, do not edit by hand. 003// 004package org.apache.activemq.leveldb.record; 005 006 007public 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 input.skipField(tag); 173 break; 174 } 175 case 8: 176 setKey(input.readInt64()); 177 break; 178 } 179 } 180 } 181 public boolean equals(Object obj) { 182 if( obj==this ) 183 return true; 184 185 if( obj==null || obj.getClass()!=Bean.class ) 186 return false; 187 188 return equals((Bean)obj); 189 } 190 191 public boolean equals(Bean obj) { 192 if (hasKey() ^ obj.hasKey() ) 193 return false; 194 if (hasKey() && ( getKey()!=obj.getKey() )) 195 return false; 196 return true; 197 } 198 199 public int hashCode() { 200 int rc=2066384; 201 if (hasKey()) { 202 rc ^= ( 75327^(new Long(getKey())).hashCode() ); 203 } 204 return rc; 205 } 206 207 public Bean mergeFrom(Getter other) { 208 copyCheck(); 209 if (other.hasKey()) { 210 setKey(other.getKey()); 211 } 212 return this; 213 } 214 215 public void clear() { 216 clearKey(); 217 } 218 219 public void readExternal(java.io.DataInput in) throws java.io.IOException { 220 assert frozen==null : org.fusesource.hawtbuf.proto.MessageBufferSupport.FORZEN_ERROR_MESSAGE; 221 bean = this; 222 frozen = null; 223 f_key = in.readLong(); 224 b_key = true; 225 } 226 227 public void writeExternal(java.io.DataOutput out) throws java.io.IOException { 228 out.writeLong(bean.f_key); 229 } 230 231 } 232 233 static public final class Buffer implements org.fusesource.hawtbuf.proto.MessageBuffer<CollectionKey.Bean, CollectionKey.Buffer>, Getter { 234 235 private Bean bean; 236 private org.fusesource.hawtbuf.Buffer buffer; 237 private int size=-1; 238 private int hashCode; 239 240 private Buffer(org.fusesource.hawtbuf.Buffer buffer) { 241 this.buffer = buffer; 242 } 243 244 private Buffer(Bean bean) { 245 this.bean = bean; 246 } 247 248 public Bean copy() { 249 return bean().copy(); 250 } 251 252 public Buffer freeze() { 253 return this; 254 } 255 256 private Bean bean() { 257 if (bean == null) { 258 try { 259 bean = new Bean().mergeUnframed(new org.fusesource.hawtbuf.proto.CodedInputStream(buffer)); 260 bean.frozen=this; 261 } catch (org.fusesource.hawtbuf.proto.InvalidProtocolBufferException e) { 262 throw new RuntimeException(e); 263 } catch (java.io.IOException e) { 264 throw new RuntimeException("An IOException was thrown (should never happen in this method).", e); 265 } 266 } 267 return bean; 268 } 269 270 public String toString() { 271 return bean().toString(); 272 } 273 274 public java.lang.StringBuilder toString(java.lang.StringBuilder sb, String prefix) { 275 return bean().toString(sb, prefix); 276 } 277 278 // required int64 key = 1; 279 public boolean hasKey() { 280 return bean().hasKey(); 281 } 282 283 public long getKey() { 284 return bean().getKey(); 285 } 286 287 public org.fusesource.hawtbuf.Buffer toUnframedBuffer() { 288 if( buffer !=null ) { 289 return buffer; 290 } 291 return org.fusesource.hawtbuf.proto.MessageBufferSupport.toUnframedBuffer(this); 292 } 293 294 public org.fusesource.hawtbuf.Buffer toFramedBuffer() { 295 return org.fusesource.hawtbuf.proto.MessageBufferSupport.toFramedBuffer(this); 296 } 297 298 public byte[] toUnframedByteArray() { 299 return toUnframedBuffer().toByteArray(); 300 } 301 302 public byte[] toFramedByteArray() { 303 return toFramedBuffer().toByteArray(); 304 } 305 306 public void writeFramed(org.fusesource.hawtbuf.proto.CodedOutputStream output) throws java.io.IOException { 307 output.writeRawVarint32(serializedSizeUnframed()); 308 writeUnframed(output); 309 } 310 311 public void writeFramed(java.io.OutputStream output) throws java.io.IOException { 312 org.fusesource.hawtbuf.proto.CodedOutputStream codedOutput = new org.fusesource.hawtbuf.proto.CodedOutputStream(output); 313 writeFramed(codedOutput); 314 codedOutput.flush(); 315 } 316 317 public void writeUnframed(java.io.OutputStream output) throws java.io.IOException { 318 org.fusesource.hawtbuf.proto.CodedOutputStream codedOutput = new org.fusesource.hawtbuf.proto.CodedOutputStream(output); 319 writeUnframed(codedOutput); 320 codedOutput.flush(); 321 } 322 323 public void writeUnframed(org.fusesource.hawtbuf.proto.CodedOutputStream output) throws java.io.IOException { 324 if (buffer == null) { 325 int size = serializedSizeUnframed(); 326 buffer = output.getNextBuffer(size); 327 org.fusesource.hawtbuf.proto.CodedOutputStream original=null; 328 if( buffer == null ) { 329 buffer = new org.fusesource.hawtbuf.Buffer(new byte[size]); 330 original = output; 331 output = new org.fusesource.hawtbuf.proto.CodedOutputStream(buffer); 332 } 333 output.writeInt64(1, bean.getKey()); 334 if( original !=null ) { 335 output.checkNoSpaceLeft(); 336 output = original; 337 output.writeRawBytes(buffer); 338 } 339 } else { 340 output.writeRawBytes(buffer); 341 } 342 } 343 344 public int serializedSizeFramed() { 345 int t = serializedSizeUnframed(); 346 return org.fusesource.hawtbuf.proto.CodedOutputStream.computeRawVarint32Size(t) + t; 347 } 348 349 public int serializedSizeUnframed() { 350 if (buffer != null) { 351 return buffer.length; 352 } 353 if (size != -1) 354 return size; 355 356 size = 0; 357 size += org.fusesource.hawtbuf.proto.CodedOutputStream.computeInt64Size(1, getKey()); 358 return size; 359 } 360 361 public boolean equals(Object obj) { 362 if( obj==this ) 363 return true; 364 365 if( obj==null || obj.getClass()!=Buffer.class ) 366 return false; 367 368 return equals((Buffer)obj); 369 } 370 371 public boolean equals(Buffer obj) { 372 return toUnframedBuffer().equals(obj.toUnframedBuffer()); 373 } 374 375 public int hashCode() { 376 if( hashCode==0 ) { 377 hashCode=2000715872 ^ toUnframedBuffer().hashCode(); 378 } 379 return hashCode; 380 } 381 382 public boolean frozen() { 383 return true; 384 } 385 } 386 387} 388