001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 4.0.2 004 * 005 * Do not make changes to this file unless you know what you are doing--modify 006 * the SWIG interface file instead. 007 * ----------------------------------------------------------------------------- */ 008 009package com.avpkit.ferry; 010 011/** 012 * Allows Java code to get data from a native buffers, and optionally modify native memory directly.<br> 013 * <p> <br> 014 * When accessing from Java, you can copy in and<br> 015 * out ranges of buffers. You can do this by-copy<br> 016 * (which is safer but a little slower) or by-reference<br> 017 * where you <b>directly access underlying C++/native<br> 018 * memory from Java</b>. Take special care if you decide<br> 019 * that native access is required.<br> 020 * </p><br> 021 * <p><br> 022 * When accessing from C++, you get direct access to<br> 023 * the underlying buffer.<br> 024 * </p><br> 025 * <p><br> 026 * To make an IBuffer object that is not a AVPKit internal object,<br> 027 * pass in null for the RefCounted parameter.<br> 028 * <br> 029 * </p> 030 */ 031public class IBuffer extends RefCounted { 032 // IBuffer.swg: Start generated code 033 // >>>>>>>>>>>>>>>>>>>>>>>>>>> 034 035 private volatile long swigCPtr; 036 037 /** 038 * <strong> 039 * DO NOT USE THIS CONSTRUCTOR - USE {@link #make(RefCounted,int)} INSTEAD. 040 * </strong> 041 * <p> 042 * Internal Only. Do not allocate this object using new. Not part of public API. 043 * </p> 044 * <p> 045 * Unfortunately this constructor is public because the internal 046 * implementation needs it to be, but do not pass in values to this method 047 * as you may end up crashing the virtual machine. 048 * </p> 049 * 050 * @param ignore1 ignore. 051 * @param ignore2 ignore. 052 * 053 */ 054 public IBuffer(long ignore1, boolean ignore2) { 055 super(FerryJNI.IBuffer_SWIGUpcast(ignore1), ignore2); 056 swigCPtr = ignore1; 057 } 058 protected IBuffer(long cPtr, boolean cMemoryOwn, 059 java.util.concurrent.atomic.AtomicLong ref) 060 { 061 super(FerryJNI.IBuffer_SWIGUpcast(cPtr), 062 cMemoryOwn, ref); 063 swigCPtr = cPtr; 064 } 065 066 /** 067 * Internal Only. Not part of public API. 068 * 069 * Get the raw value of the native object that obj is proxying for. 070 * 071 * @param obj The java proxy object for a native object. 072 * @return The raw pointer obj is proxying for. 073 */ 074 public static long getCPtr(IBuffer obj) { 075 if (obj == null) return 0; 076 return obj.getMyCPtr(); 077 } 078 079 /** 080 * Internal Only. Not part of public API. 081 * 082 * Get the raw value of the native object that we're proxying for. 083 * 084 * @return The raw pointer we're proxying for. 085 */ 086 public long getMyCPtr() { 087 if (swigCPtr == 0) throw new IllegalStateException("underlying native object already deleted"); 088 return swigCPtr; 089 } 090 091 /** 092 * Releases ths instance of IBuffer and frees any underlying 093 * native memory. 094 * <p> 095 * {@inheritDoc} 096 * </p> 097 */ 098 @Override 099 public void delete() 100 { 101 do {} while(false); // remove a warning 102 super.delete(); 103 } 104 105 /** 106 * Create a new IBuffer object that is actually referring to the 107 * exact same underlying Native object. 108 * 109 * @return the new Java object. 110 */ 111 @Override 112 public IBuffer copyReference() { 113 if (swigCPtr == 0) 114 return null; 115 else 116 return new IBuffer(swigCPtr, swigCMemOwn, getJavaRefCount()); 117 } 118 119 /** 120 * Compares two values, returning true if the underlying objects in native code are the same object. 121 * 122 * That means you can have two different Java objects, but when you do a comparison, you'll find out 123 * they are the EXACT same object. 124 * 125 * @return True if the underlying native object is the same. False otherwise. 126 */ 127 public boolean equals(Object obj) { 128 boolean equal = false; 129 if (obj instanceof IBuffer) 130 equal = (((IBuffer)obj).swigCPtr == this.swigCPtr); 131 return equal; 132 } 133 134 /** 135 * Get a hashable value for this object. 136 * 137 * @return the hashable value. 138 */ 139 public int hashCode() { 140 return (int)swigCPtr; 141 } 142 143 144 private void validateArgs(Object array, int arrayLength, 145 int arrayPos, 146 int bufferSize, 147 int bufferPos, 148 int length) 149 { 150 if (arrayPos < 0) 151 throw new IndexOutOfBoundsException(); 152 if (bufferPos < 0) 153 throw new IndexOutOfBoundsException(); 154 if (length < 0) 155 throw new IndexOutOfBoundsException(); 156 if (arrayPos+length > arrayLength) 157 throw new IndexOutOfBoundsException(); 158 if (bufferPos + length > bufferSize) 159 throw new IndexOutOfBoundsException(); 160 } 161 162 /** 163 * Absolute bulk put method. 164 * <p> 165 * This method transfers bytes into this buffer from the given source array. 166 * If there are more bytes to be copied from the array than there is 167 * space remaining at the specified destination offset, 168 * then no bytes are transferred and a java.nio.BufferOverflowException is thrown. 169 * </p> 170 * <p> 171 * This method is equivalent to calling {@link #getByteBuffer(int, int)} 172 * yourself and copying the bytes over, but is more efficient in 173 * the {@link JNIMemoryManager.MemoryModel#NATIVE_BUFFERS} memory model. 174 * </p> 175 * 176 * @param src The array from which bytes are to be read. Must be non null. 177 * @param srcPos The offset within <code>src</code> of the first byte to be read; 178 * must be non-negative and less than <code>src.length</code> 179 * @param destPos The offset in the IBuffer where you want to copy 180 * data to. Must be non-negative and less than <code>getBufferSize()</code> 181 * @param length The number of bytes to be read from <code>src</code>; 182 * must be non-negative and no larger than <code>src.length - srcPos</code> 183 * 184 * @throws NullPointerException if <code>src</code> is null. 185 * @throws IndexOutOfBoundsException if the preconditions on the arguments 186 * mentioned above are not honored. 187 * @throws java.nio.BufferOverflowException if there is insufficient space 188 * in this {@link IBuffer}. 189 * 190 */ 191 public void put(byte[] src, int srcPos, int destPos, int length) 192 { 193 java.util.concurrent.atomic.AtomicReference<JNIReference> ref = 194 new java.util.concurrent.atomic.AtomicReference<JNIReference>(); 195 java.nio.ByteBuffer buffer = this.getByteBuffer(0, this.getBufferSize(), 196 ref); 197 198 try 199 { 200 if (buffer == null) 201 return; 202 buffer.clear(); 203 validateArgs(src, src.length, srcPos, buffer.limit(), destPos, length); 204 205 buffer.position(destPos); 206 buffer.put(src, srcPos, length); 207 return; 208 } 209 finally 210 { 211 if (ref.get() != null) 212 ref.get().delete(); 213 } 214 } 215 216 /** 217 * Absolute bulk get method. 218 * <p> 219 * This method transfers bytes from this {@link IBuffer} into the given 220 * <code>dest</code> 221 * array. If there are fewer bytes in the {@link IBuffer} starting 222 * at position <code>srcPos</code> than are required 223 * to satisfy the request, then no bytes are 224 * transferred and a BufferUnderflowException is thrown. 225 * </p> 226 * <p> 227 * This method is equivalent to calling {@link #getByteBuffer(int, int)} 228 * yourself and reading the bytes out, but is more efficient in the 229 * {@link JNIMemoryManager.MemoryModel#NATIVE_BUFFERS} memory model. 230 * </p> 231 * 232 * @param srcPos The offset in the IBuffer where you want to start 233 * copying data from. 234 * Must be non-negative and less than <code>getBufferSize()</code> 235 * @param dest The array to which bytes are to be written. Must be non null. 236 * @param destPos The offset within <code>dest</code> of the first byte to be 237 * written; must be non-negative and less than <code>dest.length</code> 238 * @param length The number of bytes to be copied into <code>dest</code>; must be 239 * non-negative and no larger than <code>dest.length - destPos</code> 240 * 241 * @throws NullPointerException if <code>dest</code> is null. 242 * @throws IndexOutOfBoundsException if the preconditions on the arguments 243 * mentioned above are not honored. 244 * @throws java.nio.BufferOverflowException if there is insufficient data in this 245 * {@link IBuffer} to satisfy the request. 246 * 247 */ 248 public void get(int srcPos, byte[] dest, int destPos, int length) 249 { 250 java.util.concurrent.atomic.AtomicReference<JNIReference> ref = 251 new java.util.concurrent.atomic.AtomicReference<JNIReference>(); 252 java.nio.ByteBuffer buffer = this.getByteBuffer(0, this.getBufferSize(), 253 ref); 254 255 try 256 { 257 if (buffer == null) 258 return; 259 validateArgs(dest, dest.length, destPos, buffer.limit(), srcPos, length); 260 261 buffer.position(srcPos); 262 buffer.get(dest, destPos, length); 263 return; 264 } 265 finally 266 { 267 if (ref.get() != null) 268 ref.get().delete(); 269 } 270 } 271 272 /** 273 * Absolute bulk put method. 274 * <p> 275 * This method transfers shorts into this buffer from the given source array. 276 * If there are more shorts to be copied from the array than there is 277 * space remaining at the specified destination offset, 278 * then no shorts are transferred and a java.nio.BufferOverflowException is thrown. 279 * </p> 280 * <p> 281 * This method is equivalent to calling {@link #getByteBuffer(int, int)} 282 * yourself and copying the bytes over, but is more efficient in 283 * the {@link JNIMemoryManager.MemoryModel#NATIVE_BUFFERS} memory model. 284 * </p> 285 * 286 * @param src The array from which shorts are to be read. Must be non null. 287 * @param srcPos The offset within <code>src</code> of the first short to be read; 288 * must be non-negative and less than <code>src.length</code> 289 * @param destPos The offset in the IBuffer where you want to copy 290 * data to. Must be non-negative and less than <code>getBufferSize()</code> 291 * @param length The number of shorts to be read from <code>src</code>; 292 * must be non-negative and no larger than <code>src.length - srcPos</code> 293 * 294 * @throws NullPointerException if <code>src</code> is null. 295 * @throws IndexOutOfBoundsException if the preconditions on the arguments 296 * mentioned above are not honored. 297 * @throws java.nio.BufferOverflowException if there is insufficient space 298 * in this {@link IBuffer}. 299 * 300 */ 301 public void put(short[] src, int srcPos, int destPos, int length) 302 { 303 java.util.concurrent.atomic.AtomicReference<JNIReference> ref = 304 new java.util.concurrent.atomic.AtomicReference<JNIReference>(); 305 java.nio.ByteBuffer bbuffer = this.getByteBuffer(0, this.getBufferSize(), 306 ref); 307 308 309 try 310 { 311 if (bbuffer == null) 312 return; 313 java.nio.ShortBuffer buffer = bbuffer.asShortBuffer(); 314 buffer.clear(); 315 validateArgs(src, src.length, srcPos, buffer.limit(), destPos, length); 316 buffer.position(destPos); 317 buffer.put(src, srcPos, length); 318 return; 319 } 320 finally 321 { 322 if (ref.get() != null) 323 ref.get().delete(); 324 } 325 } 326 327 /** 328 * Absolute bulk get method. 329 * <p> 330 * This method transfers shorts from this {@link IBuffer} into the given 331 * <code>dest</code> 332 * array. If there are fewer shorts in the {@link IBuffer} starting 333 * at position <code>srcPos</code> than are required 334 * to satisfy the request, then no shorts are 335 * transferred and a BufferUnderflowException is thrown. 336 * </p> 337 * <p> 338 * This method is equivalent to calling {@link #getByteBuffer(int, int)} 339 * yourself and reading the bytes out, but is more efficient in the 340 * {@link JNIMemoryManager.MemoryModel#NATIVE_BUFFERS} memory model. 341 * </p> 342 * 343 * @param srcPos The offset in the IBuffer where you want to start 344 * copying data from. 345 * Must be non-negative and less than <code>getBufferSize()</code> 346 * @param dest The array to which shorts are to be written. Must be non null. 347 * @param destPos The offset within <code>dest</code> of the first short to be 348 * written; must be non-negative and less than <code>dest.length</code> 349 * @param length The number of shorts to be copied into <code>dest</code>; must be 350 * non-negative and no larger than <code>dest.length - destPos</code> 351 * 352 * @throws NullPointerException if <code>dest</code> is null. 353 * @throws IndexOutOfBoundsException if the preconditions on the arguments 354 * mentioned above are not honored. 355 * @throws java.nio.BufferOverflowException if there is insufficient data in this 356 * {@link IBuffer} to satisfy the request. 357 * 358 */ 359 public void get(int srcPos, short[] dest, int destPos, int length) 360 { 361 java.util.concurrent.atomic.AtomicReference<JNIReference> ref = 362 new java.util.concurrent.atomic.AtomicReference<JNIReference>(); 363 java.nio.ByteBuffer bbuffer = this.getByteBuffer(0, this.getBufferSize(), 364 ref); 365 366 try 367 { 368 if (bbuffer == null) 369 return; 370 java.nio.ShortBuffer buffer = bbuffer.asShortBuffer(); 371 validateArgs(dest, dest.length, destPos, buffer.limit(), srcPos, length); 372 buffer.position(srcPos); 373 buffer.get(dest, destPos, length); 374 return; 375 } 376 finally 377 { 378 if (ref.get() != null) 379 ref.get().delete(); 380 } 381 } 382 383 384 /** 385 * Absolute bulk put method. 386 * <p> 387 * This method transfers ints into this buffer from the given source array. 388 * If there are more ints to be copied from the array than there is 389 * space remaining at the specified destination offset, 390 * then no ints are transferred and a java.nio.BufferOverflowException is thrown. 391 * </p> 392 * <p> 393 * This method is equivalent to calling {@link #getByteBuffer(int, int)} 394 * yourself and copying the bytes over, but is more efficient in 395 * the {@link JNIMemoryManager.MemoryModel#NATIVE_BUFFERS} memory model. 396 * </p> 397 * 398 * @param src The array from which ints are to be read. Must be non null. 399 * @param srcPos The offset within <code>src</code> of the first int to be read; 400 * must be non-negative and less than <code>src.length</code> 401 * @param destPos The offset in the IBuffer where you want to copy 402 * data to. Must be non-negative and less than <code>getBufferSize()</code> 403 * @param length The number of ints to be read from <code>src</code>; 404 * must be non-negative and no larger than <code>src.length - srcPos</code> 405 * 406 * @throws NullPointerException if <code>src</code> is null. 407 * @throws IndexOutOfBoundsException if the preconditions on the arguments 408 * mentioned above are not honored. 409 * @throws java.nio.BufferOverflowException if there is insufficient space 410 * in this {@link IBuffer}. 411 * 412 */ 413 public void put(int[] src, int srcPos, int destPos, int length) 414 { 415 java.util.concurrent.atomic.AtomicReference<JNIReference> ref = 416 new java.util.concurrent.atomic.AtomicReference<JNIReference>(); 417 java.nio.ByteBuffer bbuffer = this.getByteBuffer(0, this.getBufferSize(), 418 ref); 419 420 421 try 422 { 423 if (bbuffer == null) 424 return; 425 java.nio.IntBuffer buffer = bbuffer.asIntBuffer(); 426 buffer.clear(); 427 validateArgs(src, src.length, srcPos, buffer.limit(), destPos, length); 428 buffer.position(destPos); 429 buffer.put(src, srcPos, length); 430 return; 431 } 432 finally 433 { 434 if (ref.get() != null) 435 ref.get().delete(); 436 } 437 } 438 439 /** 440 * Absolute bulk get method. 441 * <p> 442 * This method transfers ints from this {@link IBuffer} into the given 443 * <code>dest</code> 444 * array. If there are fewer ints in the {@link IBuffer} starting 445 * at position <code>srcPos</code> than are required 446 * to satisfy the request, then no ints are 447 * transferred and a BufferUnderflowException is thrown. 448 * </p> 449 * <p> 450 * This method is equivalent to calling {@link #getByteBuffer(int, int)} 451 * yourself and reading the bytes out, but is more efficient in the 452 * {@link JNIMemoryManager.MemoryModel#NATIVE_BUFFERS} memory model. 453 * </p> 454 * 455 * @param srcPos The offset in the IBuffer where you want to start 456 * copying data from. 457 * Must be non-negative and less than <code>getBufferSize()</code> 458 * @param dest The array to which ints are to be written. Must be non null. 459 * @param destPos The offset within <code>dest</code> of the first int to be 460 * written; must be non-negative and less than <code>dest.length</code> 461 * @param length The number of ints to be copied into <code>dest</code>; must be 462 * non-negative and no larger than <code>dest.length - destPos</code> 463 * 464 * @throws NullPointerException if <code>dest</code> is null. 465 * @throws IndexOutOfBoundsException if the preconditions on the arguments 466 * mentioned above are not honored. 467 * @throws java.nio.BufferOverflowException if there is insufficient data in this 468 * {@link IBuffer} to satisfy the request. 469 * 470 */ 471 public void get(int srcPos, int[] dest, int destPos, int length) 472 { 473 java.util.concurrent.atomic.AtomicReference<JNIReference> ref = 474 new java.util.concurrent.atomic.AtomicReference<JNIReference>(); 475 java.nio.ByteBuffer bbuffer = this.getByteBuffer(0, this.getBufferSize(), 476 ref); 477 478 try 479 { 480 if (bbuffer == null) 481 return; 482 java.nio.IntBuffer buffer = bbuffer.asIntBuffer(); 483 validateArgs(dest, dest.length, destPos, buffer.limit(), srcPos, length); 484 buffer.position(srcPos); 485 buffer.get(dest, destPos, length); 486 return; 487 } 488 finally 489 { 490 if (ref.get() != null) 491 ref.get().delete(); 492 } 493 } 494 495 496 /** 497 * Absolute bulk put method. 498 * <p> 499 * This method transfers longs into this buffer from the given source array. 500 * If there are more longs to be copied from the array than there is 501 * space remaining at the specified destination offset, 502 * then no longs are transferred and a java.nio.BufferOverflowException is thrown. 503 * </p> 504 * <p> 505 * This method is equivalent to calling {@link #getByteBuffer(int, int)} 506 * yourself and copying the bytes over, but is more efficient in 507 * the {@link JNIMemoryManager.MemoryModel#NATIVE_BUFFERS} memory model. 508 * </p> 509 * 510 * @param src The array from which longs are to be read. Must be non null. 511 * @param srcPos The offset within <code>src</code> of the first long to be read; 512 * must be non-negative and less than <code>src.length</code> 513 * @param destPos The offset in the IBuffer where you want to copy 514 * data to. Must be non-negative and less than <code>getBufferSize()</code> 515 * @param length The number of longs to be read from <code>src</code>; 516 * must be non-negative and no larger than <code>src.length - srcPos</code> 517 * 518 * @throws NullPointerException if <code>src</code> is null. 519 * @throws IndexOutOfBoundsException if the preconditions on the arguments 520 * mentioned above are not honored. 521 * @throws java.nio.BufferOverflowException if there is insufficient space 522 * in this {@link IBuffer}. 523 * 524 */ 525 public void put(long[] src, int srcPos, int destPos, int length) 526 { 527 java.util.concurrent.atomic.AtomicReference<JNIReference> ref = 528 new java.util.concurrent.atomic.AtomicReference<JNIReference>(); 529 java.nio.ByteBuffer bbuffer = this.getByteBuffer(0, this.getBufferSize(), 530 ref); 531 532 533 try 534 { 535 if (bbuffer == null) 536 return; 537 java.nio.LongBuffer buffer = bbuffer.asLongBuffer(); 538 buffer.clear(); 539 validateArgs(src, src.length, srcPos, buffer.limit(), destPos, length); 540 buffer.position(destPos); 541 buffer.put(src, srcPos, length); 542 return; 543 } 544 finally 545 { 546 if (ref.get() != null) 547 ref.get().delete(); 548 } 549 } 550 551 /** 552 * Absolute bulk get method. 553 * <p> 554 * This method transfers longs from this {@link IBuffer} into the given 555 * <code>dest</code> 556 * array. If there are fewer longs in the {@link IBuffer} starting 557 * at position <code>srcPos</code> than are required 558 * to satisfy the request, then no longs are 559 * transferred and a BufferUnderflowException is thrown. 560 * </p> 561 * <p> 562 * This method is equivalent to calling {@link #getByteBuffer(int, int)} 563 * yourself and reading the bytes out, but is more efficient in the 564 * {@link JNIMemoryManager.MemoryModel#NATIVE_BUFFERS} memory model. 565 * </p> 566 * 567 * @param srcPos The offset in the IBuffer where you want to start 568 * copying data from. 569 * Must be non-negative and less than <code>getBufferSize()</code> 570 * @param dest The array to which longs are to be written. Must be non null. 571 * @param destPos The offset within <code>dest</code> of the first long to be 572 * written; must be non-negative and less than <code>dest.length</code> 573 * @param length The number of longs to be copied into <code>dest</code>; must be 574 * non-negative and no larger than <code>dest.length - destPos</code> 575 * 576 * @throws NullPointerException if <code>dest</code> is null. 577 * @throws IndexOutOfBoundsException if the preconditions on the arguments 578 * mentioned above are not honored. 579 * @throws java.nio.BufferOverflowException if there is insufficient data in this 580 * {@link IBuffer} to satisfy the request. 581 * 582 */ 583 public void get(int srcPos, long[] dest, int destPos, int length) 584 { 585 java.util.concurrent.atomic.AtomicReference<JNIReference> ref = 586 new java.util.concurrent.atomic.AtomicReference<JNIReference>(); 587 java.nio.ByteBuffer bbuffer = this.getByteBuffer(0, this.getBufferSize(), 588 ref); 589 590 try 591 { 592 if (bbuffer == null) 593 return; 594 java.nio.LongBuffer buffer = bbuffer.asLongBuffer(); 595 validateArgs(dest, dest.length, destPos, buffer.limit(), srcPos, length); 596 buffer.position(srcPos); 597 buffer.get(dest, destPos, length); 598 return; 599 } 600 finally 601 { 602 if (ref.get() != null) 603 ref.get().delete(); 604 } 605 } 606 607 /** 608 * Absolute bulk put method. 609 * <p> 610 * This method transfers doubles into this buffer from the given source array. 611 * If there are more doubles to be copied from the array than there is 612 * space remaining at the specified destination offset, 613 * then no doubles are transferred and a java.nio.BufferOverflowException is thrown. 614 * </p> 615 * <p> 616 * This method is equivalent to calling {@link #getByteBuffer(int, int)} 617 * yourself and copying the bytes over, but is more efficient in 618 * the {@link JNIMemoryManager.MemoryModel#NATIVE_BUFFERS} memory model. 619 * </p> 620 * 621 * @param src The array from which doubles are to be read. Must be non null. 622 * @param srcPos The offset within <code>src</code> of the first double to be read; 623 * must be non-negative and less than <code>src.length</code> 624 * @param destPos The offset in the IBuffer where you want to copy 625 * data to. Must be non-negative and less than <code>getBufferSize()</code> 626 * @param length The number of doubles to be read from <code>src</code>; 627 * must be non-negative and no larger than <code>src.length - srcPos</code> 628 * 629 * @throws NullPointerException if <code>src</code> is null. 630 * @throws IndexOutOfBoundsException if the preconditions on the arguments 631 * mentioned above are not honored. 632 * @throws java.nio.BufferOverflowException if there is insufficient space 633 * in this {@link IBuffer}. 634 * 635 */ 636 public void put(double[] src, int srcPos, int destPos, int length) 637 { 638 java.util.concurrent.atomic.AtomicReference<JNIReference> ref = 639 new java.util.concurrent.atomic.AtomicReference<JNIReference>(); 640 java.nio.ByteBuffer bbuffer = this.getByteBuffer(0, this.getBufferSize(), 641 ref); 642 643 644 try 645 { 646 if (bbuffer == null) 647 return; 648 java.nio.DoubleBuffer buffer = bbuffer.asDoubleBuffer(); 649 buffer.clear(); 650 validateArgs(src, src.length, srcPos, buffer.limit(), destPos, length); 651 buffer.position(destPos); 652 buffer.put(src, srcPos, length); 653 return; 654 } 655 finally 656 { 657 if (ref.get() != null) 658 ref.get().delete(); 659 } 660 } 661 662 /** 663 * Absolute bulk get method. 664 * <p> 665 * This method transfers doubles from this {@link IBuffer} into the given 666 * <code>dest</code> 667 * array. If there are fewer doubles in the {@link IBuffer} starting 668 * at position <code>srcPos</code> than are required 669 * to satisfy the request, then no doubles are 670 * transferred and a BufferUnderflowException is thrown. 671 * </p> 672 * <p> 673 * This method is equivalent to calling {@link #getByteBuffer(int, int)} 674 * yourself and reading the bytes out, but is more efficient in the 675 * {@link JNIMemoryManager.MemoryModel#NATIVE_BUFFERS} memory model. 676 * </p> 677 * 678 * @param srcPos The offset in the IBuffer where you want to start 679 * copying data from. 680 * Must be non-negative and less than <code>getBufferSize()</code> 681 * @param dest The array to which doubles are to be written. Must be non null. 682 * @param destPos The offset within <code>dest</code> of the first double to be 683 * written; must be non-negative and less than <code>dest.length</code> 684 * @param length The number of doubles to be copied into <code>dest</code>; must be 685 * non-negative and no larger than <code>dest.length - destPos</code> 686 * 687 * @throws NullPointerException if <code>dest</code> is null. 688 * @throws IndexOutOfBoundsException if the preconditions on the arguments 689 * mentioned above are not honored. 690 * @throws java.nio.BufferOverflowException if there is insufficient data in this 691 * {@link IBuffer} to satisfy the request. 692 * 693 */ 694 public void get(int srcPos, double[] dest, int destPos, int length) 695 { 696 java.util.concurrent.atomic.AtomicReference<JNIReference> ref = 697 new java.util.concurrent.atomic.AtomicReference<JNIReference>(); 698 java.nio.ByteBuffer bbuffer = this.getByteBuffer(0, this.getBufferSize(), 699 ref); 700 701 try 702 { 703 if (bbuffer == null) 704 return; 705 java.nio.DoubleBuffer buffer = bbuffer.asDoubleBuffer(); 706 validateArgs(dest, dest.length, destPos, buffer.limit(), srcPos, length); 707 buffer.position(srcPos); 708 buffer.get(dest, destPos, length); 709 return; 710 } 711 finally 712 { 713 if (ref.get() != null) 714 ref.get().delete(); 715 } 716 } 717 718 /** 719 * Absolute bulk put method. 720 * <p> 721 * This method transfers floats into this buffer from the given source array. 722 * If there are more floats to be copied from the array than there is 723 * space remaining at the specified destination offset, 724 * then no floats are transferred and a java.nio.BufferOverflowException is thrown. 725 * </p> 726 * <p> 727 * This method is equivalent to calling {@link #getByteBuffer(int, int)} 728 * yourself and copying the bytes over, but is more efficient in 729 * the {@link JNIMemoryManager.MemoryModel#NATIVE_BUFFERS} memory model. 730 * </p> 731 * 732 * @param src The array from which floats are to be read. Must be non null. 733 * @param srcPos The offset within <code>src</code> of the first float to be read; 734 * must be non-negative and less than <code>src.length</code> 735 * @param destPos The offset in the IBuffer where you want to copy 736 * data to. Must be non-negative and less than <code>getBufferSize()</code> 737 * @param length The number of floats to be read from <code>src</code>; 738 * must be non-negative and no larger than <code>src.length - srcPos</code> 739 * 740 * @throws NullPointerException if <code>src</code> is null. 741 * @throws IndexOutOfBoundsException if the preconditions on the arguments 742 * mentioned above are not honored. 743 * @throws java.nio.BufferOverflowException if there is insufficient space 744 * in this {@link IBuffer}. 745 * 746 */ 747 public void put(float[] src, int srcPos, int destPos, int length) 748 { 749 java.util.concurrent.atomic.AtomicReference<JNIReference> ref = 750 new java.util.concurrent.atomic.AtomicReference<JNIReference>(); 751 java.nio.ByteBuffer bbuffer = this.getByteBuffer(0, this.getBufferSize(), 752 ref); 753 754 755 try 756 { 757 if (bbuffer == null) 758 return; 759 java.nio.FloatBuffer buffer = bbuffer.asFloatBuffer(); 760 buffer.clear(); 761 validateArgs(src, src.length, srcPos, buffer.limit(), destPos, length); 762 buffer.position(destPos); 763 buffer.put(src, srcPos, length); 764 return; 765 } 766 finally 767 { 768 if (ref.get() != null) 769 ref.get().delete(); 770 } 771 } 772 773 /** 774 * Absolute bulk get method. 775 * <p> 776 * This method transfers floats from this {@link IBuffer} into the given 777 * <code>dest</code> 778 * array. If there are fewer floats in the {@link IBuffer} starting 779 * at position <code>srcPos</code> than are required 780 * to satisfy the request, then no floats are 781 * transferred and a BufferUnderflowException is thrown. 782 * </p> 783 * <p> 784 * This method is equivalent to calling {@link #getByteBuffer(int, int)} 785 * yourself and reading the bytes out, but is more efficient in the 786 * {@link JNIMemoryManager.MemoryModel#NATIVE_BUFFERS} memory model. 787 * </p> 788 * 789 * @param srcPos The offset in the IBuffer where you want to start 790 * copying data from. 791 * Must be non-negative and less than <code>getBufferSize()</code> 792 * @param dest The array to which floats are to be written. Must be non null. 793 * @param destPos The offset within <code>dest</code> of the first float to be 794 * written; must be non-negative and less than <code>dest.length</code> 795 * @param length The number of floats to be copied into <code>dest</code>; must be 796 * non-negative and no larger than <code>dest.length - destPos</code> 797 * 798 * @throws NullPointerException if <code>dest</code> is null. 799 * @throws IndexOutOfBoundsException if the preconditions on the arguments 800 * mentioned above are not honored. 801 * @throws java.nio.BufferOverflowException if there is insufficient data in this 802 * {@link IBuffer} to satisfy the request. 803 * 804 */ 805 public void get(int srcPos, float[] dest, int destPos, int length) 806 { 807 java.util.concurrent.atomic.AtomicReference<JNIReference> ref = 808 new java.util.concurrent.atomic.AtomicReference<JNIReference>(); 809 java.nio.ByteBuffer bbuffer = this.getByteBuffer(0, this.getBufferSize(), 810 ref); 811 812 try 813 { 814 if (bbuffer == null) 815 return; 816 java.nio.FloatBuffer buffer = bbuffer.asFloatBuffer(); 817 validateArgs(dest, dest.length, destPos, buffer.limit(), srcPos, length); 818 buffer.position(srcPos); 819 buffer.get(dest, destPos, length); 820 return; 821 } 822 finally 823 { 824 if (ref.get() != null) 825 ref.get().delete(); 826 } 827 } 828 829 /** 830 * Absolute bulk put method. 831 * <p> 832 * This method transfers chars into this buffer from the given source array. 833 * If there are more chars to be copied from the array than there is 834 * space remaining at the specified destination offset, 835 * then no chars are transferred and a java.nio.BufferOverflowException is thrown. 836 * </p> 837 * <p> 838 * This method is equivalent to calling {@link #getByteBuffer(int, int)} 839 * yourself and copying the bytes over, but is more efficient in 840 * the {@link JNIMemoryManager.MemoryModel#NATIVE_BUFFERS} memory model. 841 * </p> 842 * 843 * @param src The array from which chars are to be read. Must be non null. 844 * @param srcPos The offset within <code>src</code> of the first char to be read; 845 * must be non-negative and less than <code>src.length</code> 846 * @param destPos The offset in the IBuffer where you want to copy 847 * data to. Must be non-negative and less than <code>getBufferSize()</code> 848 * @param length The number of chars to be read from <code>src</code>; 849 * must be non-negative and no larger than <code>src.length - srcPos</code> 850 * 851 * @throws NullPointerException if <code>src</code> is null. 852 * @throws IndexOutOfBoundsException if the preconditions on the arguments 853 * mentioned above are not honored. 854 * @throws java.nio.BufferOverflowException if there is insufficient space 855 * in this {@link IBuffer}. 856 * 857 */ 858 public void put(char[] src, int srcPos, int destPos, int length) 859 { 860 java.util.concurrent.atomic.AtomicReference<JNIReference> ref = 861 new java.util.concurrent.atomic.AtomicReference<JNIReference>(); 862 java.nio.ByteBuffer bbuffer = this.getByteBuffer(0, this.getBufferSize(), 863 ref); 864 865 866 try 867 { 868 if (bbuffer == null) 869 return; 870 java.nio.CharBuffer buffer = bbuffer.asCharBuffer(); 871 buffer.clear(); 872 validateArgs(src, src.length, srcPos, buffer.limit(), destPos, length); 873 buffer.position(destPos); 874 buffer.put(src, srcPos, length); 875 return; 876 } 877 finally 878 { 879 if (ref.get() != null) 880 ref.get().delete(); 881 } 882 } 883 884 /** 885 * Absolute bulk get method. 886 * <p> 887 * This method transfers chars from this {@link IBuffer} into the given 888 * <code>dest</code> 889 * array. If there are fewer chars in the {@link IBuffer} starting 890 * at position <code>srcPos</code> than are required 891 * to satisfy the request, then no chars are 892 * transferred and a BufferUnderflowException is thrown. 893 * </p> 894 * <p> 895 * This method is equivalent to calling {@link #getByteBuffer(int, int)} 896 * yourself and reading the bytes out, but is more efficient in the 897 * {@link JNIMemoryManager.MemoryModel#NATIVE_BUFFERS} memory model. 898 * </p> 899 * 900 * @param srcPos The offset in the IBuffer where you want to start 901 * copying data from. 902 * Must be non-negative and less than <code>getBufferSize()</code> 903 * @param dest The array to which chars are to be written. Must be non null. 904 * @param destPos The offset within <code>dest</code> of the first char to be 905 * written; must be non-negative and less than <code>dest.length</code> 906 * @param length The number of chars to be copied into <code>dest</code>; must be 907 * non-negative and no larger than <code>dest.length - destPos</code> 908 * 909 * @throws NullPointerException if <code>dest</code> is null. 910 * @throws IndexOutOfBoundsException if the preconditions on the arguments 911 * mentioned above are not honored. 912 * @throws java.nio.BufferOverflowException if there is insufficient data in this 913 * {@link IBuffer} to satisfy the request. 914 * 915 */ 916 public void get(int srcPos, char[] dest, int destPos, int length) 917 { 918 java.util.concurrent.atomic.AtomicReference<JNIReference> ref = 919 new java.util.concurrent.atomic.AtomicReference<JNIReference>(); 920 java.nio.ByteBuffer bbuffer = this.getByteBuffer(0, this.getBufferSize(), 921 ref); 922 923 try 924 { 925 if (bbuffer == null) 926 return; 927 java.nio.CharBuffer buffer = bbuffer.asCharBuffer(); 928 validateArgs(dest, dest.length, destPos, buffer.limit(), srcPos, length); 929 buffer.position(srcPos); 930 buffer.get(dest, destPos, length); 931 return; 932 } 933 finally 934 { 935 if (ref.get() != null) 936 ref.get().delete(); 937 } 938 } 939 940 941 /** 942 * Returns up to length bytes, starting at offset in the underlying 943 * buffer we're managing. 944 * 945 * <p> 946 * 947 * The buffer position, mark are initialized to zero and limit 948 * is set to the maximum capacity of this buffer. For some 949 * IBuffer contents, the actual usable data in this buffer will 950 * be less that the limit. 951 * 952 * </p> 953 * <p> 954 * If you want to control exactly when the underlying memory 955 * beyind the returned {@link java.nio.ByteBuffer} is released, 956 * use {@link #getByteBuffer(int, int, java.util.concurrent.atomic.AtomicReference)}. 957 * </p> 958 * @see #getByteBuffer(int, int, java.util.concurrent.atomic.AtomicReference) 959 */ 960 public java.nio.ByteBuffer getByteBuffer(int offset, int length) 961 { 962 return getByteBuffer(offset, length, null); 963 } 964 965 966 967 /** 968 * Returns up to length bytes, starting at offset in the underlying 969 * buffer we're managing, and also passed back a {@link JNIReference} 970 * that can optionally be used by the caller to free the underlying 971 * native memory. 972 * 973 * <p> 974 * 975 * The buffer position, mark are initialized to zero and limit 976 * is set to the maximum capacity of this buffer. For some 977 * IBuffer contents, the actual usable data in this buffer will 978 * be less that the limit. 979 * 980 * </p> 981 * <p> 982 * 983 * If you use this method you are accessing the direct native 984 * memory associated with this buffer. That means changes you make 985 * to this buffer are immediately reflected in the underlying 986 * memory. 987 * 988 * </p> 989 * <p> 990 * 991 * Once you call this method, 992 * the underlying native memory allocated will not be released until 993 * all references to the returned ByteBuffer are no longer reachable and 994 * at least one call to {@link JNIMemoryManager#gc()} has been 995 * performed. You can force the memory to be collect earlier 996 * by using the {@link JNIReference} value returned when you 997 * call this method. 998 * </p><p> 999 * The {@link JNIMemoryManager#gc()} is called whenever 1000 * core tries to allocate new memory for any AVPKit interface, 1001 * so normally you don't need to care about this. If for some 1002 * reason no other AVPKit object is ever allocated, every 1003 * AVPKit object has 1004 * a finalizer as well that will do the right thing. 1005 * 1006 * </p> 1007 * <p> 1008 * 1009 * You can also start up 1010 * a separate thread to do continuously do Ferry garabage 1011 * collections by calling 1012 * {@link JNIMemoryManager#startCollectionThread()}. This thread 1013 * will only wake up when it has work to do, so the overhead 1014 * is very low. We don't turn it on by default since in 1015 * 99.999% of cases you don't need to worry about it. 1016 * 1017 * </p> 1018 * 1019 * @param offset The offset (in bytes) into the buffer managed by 1020 * this IBuffer 1021 * @param length The requested length (in bytes) you want to access. 1022 * The buffer returned may actually be longer than length. 1023 * @param referenceReturn If non null, on exit 1024 * calling {@link java.util.concurrent.atomic.AtomicReference#get()} 1025 * on this value will return a {@link JNIReference} you can use 1026 * for explicitly de-allocating the underlying native store 1027 * of the {@link java.nio.ByteBuffer}. Call 1028 * {@link JNIReference#delete()} to do that. <strong>Warning:</strong> 1029 * if you do call {@link JNIReference#delete()} on the 1030 * value returned in this parameter, then the returned byte buffer 1031 * will be immediately invalid. 1032 * @return A java.nio.ByteBuffer that directly accesses 1033 * the native memory this IBuffer manages, or null if 1034 * error. 1035 */ 1036 public java.nio.ByteBuffer getByteBuffer(int offset, int length, 1037 java.util.concurrent.atomic.AtomicReference<JNIReference> referenceReturn) 1038 { 1039 java.nio.ByteBuffer retval = this.java_getByteBuffer(offset, length); 1040 if (retval != null) 1041 { 1042 // increment the ref count of this class to reflect the 1043 // byte buffer 1044 java.util.concurrent.atomic.AtomicLong refCount = 1045 this.getJavaRefCount(); 1046 refCount.incrementAndGet(); 1047 1048 // and use the byte buffer as the reference to track 1049 JNIReference ref = JNIReference.createNonFerryReference( 1050 this, 1051 retval, swigCPtr, refCount); 1052 if (referenceReturn != null) 1053 referenceReturn.set(ref); 1054 1055 // and tell Java this byte buffer is in native order 1056 retval.order(java.nio.ByteOrder.nativeOrder()); 1057 } 1058 return retval; 1059 } 1060 1061 /** 1062 * Prints the same as {@link Object#toString()} but appends 1063 * the maximum number of bytes that will fit in this 1064 * {@link IBuffer}, the type of the {@link IBuffer}, and the maximum 1065 * size in units of {@link IBuffer.Type} that will fit in the 1066 * {@link IBuffer}. 1067 * {@inheritDoc} 1068 */ 1069 @Override 1070 public String toString() 1071 { 1072 final StringBuilder builder = new StringBuilder(); 1073 builder.append(super.toString()); 1074 builder.append("["); 1075 builder.append("bytes=").append(getBufferSize()).append(";"); 1076 builder.append("type=").append(getType()).append(";"); 1077 builder.append("size=").append(getSize()).append(";"); 1078 builder.append("]"); 1079 return builder.toString(); 1080 } 1081 1082 // <<<<<<<<<<<<<<<<<<<<<<<<<<< 1083 // IBuffer.swg 1084 1085 /** 1086 * Get the current maximum number of bytes that can<br> 1087 * be safely placed in this buffer.<br> 1088 * <br> 1089 * @return Maximum number of bytes this buffer can manage. 1090 */ 1091 public int getBufferSize() { 1092 return FerryJNI.IBuffer_getBufferSize(swigCPtr, this); 1093 } 1094 1095 /** 1096 * Allocate a new buffer of at least bufferSize.<br> 1097 * <br> 1098 * @param requestor An optional value telling the IBuffer class what object requested it. This is used for debugging memory leaks; it's a marker for the FERRY object (e.g. IPacket) that actually requested the buffer. If you're not an FERRY object, pass in null here.<br> 1099 * @param bufferSize The minimum buffer size you're requesting in bytes; a buffer with a larger size may be returned.<br> 1100 * <br> 1101 * @return A new buffer, or null on error. 1102 */ 1103 public static IBuffer make(RefCounted requestor, int bufferSize) { 1104 long cPtr = FerryJNI.IBuffer_make__SWIG_0(RefCounted.getCPtr(requestor), requestor, bufferSize); 1105 return (cPtr == 0) ? null : new IBuffer(cPtr, false); 1106 } 1107 1108 /** 1109 * Get the type this buffer was created as.<br> 1110 * <p><br> 1111 * A type is really just a hint. Like<br> 1112 * {java.nio.ByteBuffer objects},<br> 1113 * {IBuffer} objects can be cast to and from any type.<br> 1114 * </p><br> 1115 * @return the type 1116 */ 1117 public IBuffer.Type getType() { 1118 return IBuffer.Type.swigToEnum(FerryJNI.IBuffer_getType(swigCPtr, this)); 1119 } 1120 1121 /** 1122 * Reset the buffer type to a new type.<br> 1123 * <p><br> 1124 * This method does not do any data conversion, it<br> 1125 * just changes the reported type (so changing from<br> 1126 * {Type#IBUFFER_UINT8} to {Type#IBUFFER_SINT16}<br> 1127 * is really just a "cast" operation).<br> 1128 * </p><br> 1129 * @param type the type to set to. 1130 */ 1131 public void setType(IBuffer.Type type) { 1132 FerryJNI.IBuffer_setType(swigCPtr, this, type.swigValue()); 1133 } 1134 1135 /** 1136 * Returns the size, in bytes, of elements of given Type.<br> 1137 * <br> 1138 * @return the size in bytes. 1139 */ 1140 public static int getTypeSize(IBuffer.Type type) { 1141 return FerryJNI.IBuffer_getTypeSize(type.swigValue()); 1142 } 1143 1144 /** 1145 * Returns the size, in units of {#getType()} of<br> 1146 * this buffer.<br> 1147 * <br> 1148 * @return number of items of type {#getType()} that<br> 1149 * will fit in this buffer. 1150 */ 1151 public int getSize() { 1152 return FerryJNI.IBuffer_getSize(swigCPtr, this); 1153 } 1154 1155 /** 1156 * Allocate a new buffer of at least bufferSize.<br> 1157 * <br> 1158 * @param requestor An optional value telling the IBuffer class what object requested it. This is used for debugging memory leaks; it's a marker for the FERRY object (e.g. IPacket) that actually requested the buffer. If you're not an FERRY object, pass in null here.<br> 1159 * @param type The type of buffer.<br> 1160 * @param numElements The minimum number of elements of the specified<br> 1161 * type you will put in this buffer.<br> 1162 * @param zero If true, we will guarantee the buffer contains<br> 1163 * only zeros. If false, we will not (it is <br> 1164 * faster to not, but then the buffer will have<br> 1165 * garbage-data in it).<br> 1166 * <br> 1167 * @return A new buffer, or null on error. 1168 */ 1169 public static IBuffer make(RefCounted requestor, IBuffer.Type type, int numElements, boolean zero) { 1170 long cPtr = FerryJNI.IBuffer_make__SWIG_1(RefCounted.getCPtr(requestor), requestor, type.swigValue(), numElements, zero); 1171 return (cPtr == 0) ? null : new IBuffer(cPtr, false); 1172 } 1173 1174 public java.nio.ByteBuffer java_getByteBuffer(int offset, int length) { 1175 return FerryJNI.IBuffer_java_getByteBuffer(swigCPtr, this, offset, length); 1176 } 1177 1178 /** 1179 * Returns up to length bytes, starting at offset in the<br> 1180 * underlying buffer we're managing.<br> 1181 * <p> <br> 1182 * This method COPIES the data into the byte array being<br> 1183 * returned..<br> 1184 * </p><p><br> 1185 * If you don't NEED the direct access that getByteBuffer<br> 1186 * offers (and most programs can in fact take the performance<br> 1187 * hit of the copy), we recommend you use this method.<br> 1188 * It's much harder to accidentally leave native memory lying<br> 1189 * around waiting for cleanup then.<br> 1190 * </p><br> 1191 * <br> 1192 * @param offset The offset (in bytes) into the buffer managed by this IBuffer<br> 1193 * @param length The requested length (in bytes) you want to access. The buffer returned may<br> 1194 * actually be longer than length.<br> 1195 * <br> 1196 * @return A copy of the data that is in this IBuffer, or null<br> 1197 * if error. 1198 */ 1199 public byte[] getByteArray(int offset, int length) { 1200 return FerryJNI.IBuffer_getByteArray(swigCPtr, this, offset, length); 1201 } 1202 1203 /** 1204 * Allocate a new IBuffer, and copy the data in buffer into<br> 1205 * the new IBuffer object.<br> 1206 * <br> 1207 * @param requestor An optional value telling the IBuffer class<br> 1208 * what object requested it. This is used for debugging memory leaks;<br> 1209 * it's a marker for the FERRY object (e.g. IPacket) that actually<br> 1210 * requested the buffer. If you're not an FERRY object, pass in null here.<br> 1211 * @param buffer A java byte buffer for the data containing the<br> 1212 * data you want to copy.<br> 1213 * @param offset The starting offset in buffer where you want<br> 1214 * to start copying.<br> 1215 * @param length The total number of bytes you want to copy from buffer.<br> 1216 * <br> 1217 * @return a new IBuffer object with a copy of the data in buffer,<br> 1218 * or null on failure. 1219 */ 1220 public static IBuffer make(RefCounted requestor, byte[] buffer, int offset, int length) { 1221 long cPtr = FerryJNI.IBuffer_make__SWIG_2(RefCounted.getCPtr(requestor), requestor, buffer, offset, length); 1222 return (cPtr == 0) ? null : new IBuffer(cPtr, false); 1223 } 1224 1225 /** 1226 * Create a new IBuffer object that uses the direct byte buffer<br> 1227 * passed in by reference (i.e. it directly uses the bytes in<br> 1228 * the direct byte buffer).<br> 1229 * <br> 1230 * @param requestor An optional value telling the IBuffer class<br> 1231 * what object requested it. This is used for debugging memory leaks;<br> 1232 * it's a marker for the FERRY object (e.g. IPacket) that actually<br> 1233 * requested the buffer. If you're not an FERRY object, pass in null here.<br> 1234 * @param directByteBuffer A direct {java.nio.ByteBuffer} object<br> 1235 * you want to use for your memory. This must be a direct object --<br> 1236 * non direct objects will result in an JVM-dependent exception<br> 1237 * being thrown. <br> 1238 * @param offset The starting offset in directByteBuffer where you want<br> 1239 * to start copying.<br> 1240 * @param length The total number of bytes you want to copy from<br> 1241 * directByteBuffer.<br> 1242 * <br> 1243 * @return a new IBuffer object that is using directByteBuffer<br> 1244 * behind the scenes, or null on failure. 1245 */ 1246 public static IBuffer make(RefCounted requestor, java.nio.ByteBuffer directByteBuffer, int offset, int length) { 1247 long cPtr = FerryJNI.IBuffer_make__SWIG_3(RefCounted.getCPtr(requestor), requestor, directByteBuffer, offset, length); 1248 return (cPtr == 0) ? null : new IBuffer(cPtr, false); 1249 } 1250 1251 public enum Type { 1252 IBUFFER_UINT8, 1253 IBUFFER_SINT8, 1254 IBUFFER_UINT16, 1255 IBUFFER_SINT16, 1256 IBUFFER_UINT32, 1257 IBUFFER_SINT32, 1258 IBUFFER_UINT64, 1259 IBUFFER_SINT64, 1260 IBUFFER_FLT32, 1261 IBUFFER_DBL64, 1262 IBUFFER_NB; 1263 1264 public final int swigValue() { 1265 return swigValue; 1266 } 1267 1268 public static Type swigToEnum(int swigValue) { 1269 Type[] swigValues = Type.class.getEnumConstants(); 1270 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) 1271 return swigValues[swigValue]; 1272 for (Type swigEnum : swigValues) 1273 if (swigEnum.swigValue == swigValue) 1274 return swigEnum; 1275 throw new IllegalArgumentException("No enum " + Type.class + " with value " + swigValue); 1276 } 1277 1278 @SuppressWarnings("unused") 1279 private Type() { 1280 this.swigValue = SwigNext.next++; 1281 } 1282 1283 @SuppressWarnings("unused") 1284 private Type(int swigValue) { 1285 this.swigValue = swigValue; 1286 SwigNext.next = swigValue+1; 1287 } 1288 1289 @SuppressWarnings("unused") 1290 private Type(Type swigEnum) { 1291 this.swigValue = swigEnum.swigValue; 1292 SwigNext.next = this.swigValue+1; 1293 } 1294 1295 private final int swigValue; 1296 1297 private static class SwigNext { 1298 private static int next = 0; 1299 } 1300 } 1301 1302}