コード例 #1
0
ファイル: ByteBuffer.java プロジェクト: Jchavez/j2objc
 /**
  * Creates a new byte buffer by wrapping the given byte array.
  *
  * <p>The new buffer's position will be {@code start}, limit will be {@code start + byteCount},
  * capacity will be the length of the array.
  *
  * @param array the byte array which the new buffer will be based on.
  * @param start the start index, must not be negative and not greater than {@code array.length}.
  * @param byteCount the length, must not be negative and not greater than {@code array.length -
  *     start}.
  * @return the created byte buffer.
  * @throws IndexOutOfBoundsException if either {@code start} or {@code byteCount} is invalid.
  */
 public static ByteBuffer wrap(byte[] array, int start, int byteCount) {
   Arrays.checkOffsetAndCount(array.length, start, byteCount);
   ByteBuffer buf = new ByteArrayBuffer(array);
   buf.position = start;
   buf.limit = start + byteCount;
   return buf;
 }
コード例 #2
0
ファイル: IntBuffer.java プロジェクト: BvbKoala/SourceCode
 /**
  * Creates a new int buffer by wrapping the given int array.
  *
  * <p>The new buffer's position will be {@code start}, limit will be {@code start + intCount},
  * capacity will be the length of the array.
  *
  * @param array the int array which the new buffer will be based on.
  * @param start the start index, must not be negative and not greater than {@code array.length}
  * @param intCount the length, must not be negative and not greater than {@code array.length -
  *     start}.
  * @return the created int buffer.
  * @exception IndexOutOfBoundsException if either {@code start} or {@code intCount} is invalid.
  */
 public static IntBuffer wrap(int[] array, int start, int intCount) {
   Arrays.checkOffsetAndCount(array.length, start, intCount);
   IntBuffer buf = new IntArrayBuffer(array);
   buf.position = start;
   buf.limit = start + intCount;
   return buf;
 }
コード例 #3
0
ファイル: Deflater.java プロジェクト: hambroperks/j2objc
 private synchronized int deflateImpl(byte[] buf, int offset, int byteCount, int flush) {
   checkOpen();
   Arrays.checkOffsetAndCount(buf.length, offset, byteCount);
   if (inputBuffer == null) {
     setInput(EmptyArray.BYTE);
   }
   return deflateImpl(buf, offset, byteCount, streamHandle, flush);
 }
コード例 #4
0
 /**
  * Writes {@code count} characters starting at {@code offset} in {@code buf} to this writer's
  * {@code StringBuffer}.
  *
  * @param chars the non-null character array to write.
  * @param offset the index of the first character in {@code chars} to write.
  * @param count the maximum number of characters to write.
  * @throws IndexOutOfBoundsException if {@code offset < 0} or {@code count < 0}, or if {@code
  *     offset + count} is greater than the size of {@code buf}.
  */
 @Override
 public void write(char[] chars, int offset, int count) {
   Arrays.checkOffsetAndCount(chars.length, offset, count);
   if (count == 0) {
     return;
   }
   buf.append(chars, offset, count);
 }
コード例 #5
0
ファイル: ByteBuffer.java プロジェクト: Jchavez/j2objc
 /**
  * Writes bytes in the given byte array, starting from the specified offset, to the current
  * position and increases the position by the number of bytes written.
  *
  * @param src the source byte array.
  * @param srcOffset the offset of byte array, must not be negative and not greater than {@code
  *     src.length}.
  * @param byteCount the number of bytes to write, must not be negative and not greater than {@code
  *     src.length - srcOffset}.
  * @return {@code this}
  * @throws BufferOverflowException if {@code remaining()} is less than {@code byteCount}.
  * @throws IndexOutOfBoundsException if either {@code srcOffset} or {@code byteCount} is invalid.
  * @throws ReadOnlyBufferException if no changes may be made to the contents of this buffer.
  */
 public ByteBuffer put(byte[] src, int srcOffset, int byteCount) {
   Arrays.checkOffsetAndCount(src.length, srcOffset, byteCount);
   if (byteCount > remaining()) {
     throw new BufferOverflowException();
   }
   for (int i = srcOffset; i < srcOffset + byteCount; ++i) {
     put(src[i]);
   }
   return this;
 }
コード例 #6
0
ファイル: ByteBuffer.java プロジェクト: Jchavez/j2objc
 /**
  * Reads bytes from the current position into the specified byte array, starting at the specified
  * offset, and increases the position by the number of bytes read.
  *
  * @param dst the target byte array.
  * @param dstOffset the offset of the byte array, must not be negative and not greater than {@code
  *     dst.length}.
  * @param byteCount the number of bytes to read, must not be negative and not greater than {@code
  *     dst.length - dstOffset}
  * @return {@code this}
  * @throws IndexOutOfBoundsException if {@code dstOffset < 0 || byteCount < 0}
  * @throws BufferUnderflowException if {@code byteCount > remaining()}
  */
 public ByteBuffer get(byte[] dst, int dstOffset, int byteCount) {
   Arrays.checkOffsetAndCount(dst.length, dstOffset, byteCount);
   if (byteCount > remaining()) {
     throw new BufferUnderflowException();
   }
   for (int i = dstOffset; i < dstOffset + byteCount; ++i) {
     dst[i] = get();
   }
   return this;
 }
コード例 #7
0
ファイル: Deflater.java プロジェクト: hambroperks/j2objc
 /**
  * Sets the input buffer the {@code Deflater} will use to extract uncompressed bytes for later
  * compression.
  */
 public synchronized void setInput(byte[] buf, int offset, int byteCount) {
   checkOpen();
   Arrays.checkOffsetAndCount(buf.length, offset, byteCount);
   inLength = byteCount;
   inRead = 0;
   if (inputBuffer == null) {
     setLevelsImpl(compressLevel, strategy, streamHandle);
   }
   inputBuffer = buf;
   setInputImpl(buf, offset, byteCount, streamHandle);
 }
コード例 #8
0
ファイル: IntBuffer.java プロジェクト: BvbKoala/SourceCode
 /**
  * Writes ints from the given int array, starting from the specified offset, to the current
  * position and increases the position by the number of ints written.
  *
  * @param src the source int array.
  * @param srcOffset the offset of int array, must not be negative and not greater than {@code
  *     src.length}.
  * @param intCount the number of ints to write, must be no less than zero and not greater than
  *     {@code src.length - srcOffset}.
  * @return this buffer.
  * @exception BufferOverflowException if {@code remaining()} is less than {@code intCount}.
  * @exception IndexOutOfBoundsException if either {@code srcOffset} or {@code intCount} is
  *     invalid.
  * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer.
  */
 public IntBuffer put(int[] src, int srcOffset, int intCount) {
   if (isReadOnly()) {
     throw new ReadOnlyBufferException();
   }
   Arrays.checkOffsetAndCount(src.length, srcOffset, intCount);
   if (intCount > remaining()) {
     throw new BufferOverflowException();
   }
   for (int i = srcOffset; i < srcOffset + intCount; ++i) {
     put(src[i]);
   }
   return this;
 }
コード例 #9
0
ファイル: Deflater.java プロジェクト: hambroperks/j2objc
 /**
  * Sets the dictionary to be used for compression by this {@code Deflater}. This method can only
  * be called if this {@code Deflater} supports the writing of ZLIB headers. This is the default,
  * but can be overridden using {@link #Deflater(int, boolean)}.
  */
 public synchronized void setDictionary(byte[] buf, int offset, int byteCount) {
   checkOpen();
   Arrays.checkOffsetAndCount(buf.length, offset, byteCount);
   setDictionaryImpl(buf, offset, byteCount, streamHandle);
 }