Package java.nio

Examples of java.nio.BufferUnderflowException


     */
    @Override
    public String getPrefixedString(int prefixLength, CharsetDecoder decoder)
            throws CharacterCodingException {
        if (!prefixedDataAvailable(prefixLength)) {
            throw new BufferUnderflowException();
        }

        int fieldSize = 0;

        switch (prefixLength) {
        case 1:
            fieldSize = getUnsigned();
            break;
        case 2:
            fieldSize = getUnsignedShort();
            break;
        case 4:
            fieldSize = getInt();
            break;
        }

        if (fieldSize == 0) {
            return "";
        }

        boolean utf16 = decoder.charset().name().startsWith("UTF-16");

        if (utf16 && (fieldSize & 1) != 0) {
            throw new BufferDataException(
                    "fieldSize is not even for a UTF-16 string.");
        }

        int oldLimit = limit();
        int end = position() + fieldSize;

        if (oldLimit < end) {
            throw new BufferUnderflowException();
        }

        limit(end);
        decoder.reset();

View Full Code Here


     */
    @Override
    public Object getObject(final ClassLoader classLoader)
            throws ClassNotFoundException {
        if (!prefixedDataAvailable(4)) {
            throw new BufferUnderflowException();
        }

        int length = getInt();
        if (length <= 4) {
            throw new BufferDataException(
View Full Code Here

    this.in = in;
  }

  public void commit(char[] replaceWith, int startReplace, int endReplace) {
    if (startReplace < inPos) {
      throw new BufferUnderflowException();
    }
    if (endReplace > in.length) {
      throw new BufferOverflowException();
    }
View Full Code Here

            if ((offset | length | (offset + length) | (array.length - (offset + length))) < 0)
                throw new IndexOutOfBoundsException();

            if (length > remaining())
                throw new BufferUnderflowException();

            for (ByteBuffer buffer : bufferList) {
                int remaining = buffer.remaining();
                if (remaining > 0) {
                    if (length > remaining) {
View Full Code Here

   */
    @Override
    public String getPrefixedString(int prefixLength, CharsetDecoder decoder)
            throws CharacterCodingException {
                if (!prefixedDataAvailable(prefixLength)) {
                    throw new BufferUnderflowException();
                }

                int fieldSize = 0;

                switch (prefixLength) {
                case 1:
                    fieldSize = getUnsigned();
                    break;
                case 2:
                    fieldSize = getUnsignedShort();
                    break;
                case 4:
                    fieldSize = getInt();
                    break;
                }

                if (fieldSize == 0) {
                    return "";
                }

                boolean utf16 = decoder.charset().name().startsWith("UTF-16");

                if (utf16 && (fieldSize & 1) != 0) {
                    throw new BufferDataException(
                            "fieldSize is not even for a UTF-16 string.");
                }

                int oldLimit = limit();
                int end = position() + fieldSize;

                if (oldLimit < end) {
                    throw new BufferUnderflowException();
                }

                limit(end);
                decoder.reset();

View Full Code Here

    }

    @Override
    public Object getObject(final ClassLoader classLoader) throws ClassNotFoundException {
        if (!prefixedDataAvailable(4)) {
            throw new BufferUnderflowException();
        }

        int length = getInt();
        if (length <= 4) {
            throw new BufferDataException(
View Full Code Here

                int oldPos = position();
                int oldLimit = limit();
                int end = oldPos + fieldSize;

                if (oldLimit < end) {
                    throw new BufferUnderflowException();
                }

                int i;

                if (!utf16) {
View Full Code Here

   * @param position The position fromo which the byte will be read
   * @return The byte at the given position
   * @see java.nio.ByteBuffer#get(int)
   */
  public byte get(int position){
    if(position >= limit) throw new BufferUnderflowException();
    if(position < firstLimit) return firstBuffer.get(position);
    else return secondBuffer.get(position - firstLimit);
  }
View Full Code Here

   * @param offset The offset within the array of the first byte to be
   * written; must be non-negative and no larger than dst.length
   * @return This buffer
   */
  public DoubleHalfBuffer get(byte[] dst, int offset, int length){
    if(remaining() < length) throw new BufferUnderflowException();
    if(offset < 0 || length < 0 || offset + length > dst.length) throw new IndexOutOfBoundsException();
    if(position >= firstLimit){
      secondBuffer.position(position - firstLimit);
      secondBuffer.get(dst, offset, length);
      secondBuffer.rewind();
View Full Code Here

        int oldPos = position();
        int oldLimit = limit();
        int end = position() + fieldSize;

        if (oldLimit < end) {
            throw new BufferUnderflowException();
        }

        int i;

        if (!utf16) {
View Full Code Here

TOP

Related Classes of java.nio.BufferUnderflowException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.