Java 8 BufferUnderflowException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 BufferUnderflowException class.

This code example shows how to use the following methods:getCause, getLocalizedMessage, getMessage
     
    /** 
     *@tests {@link java.nio.BufferUnderflowException#BufferUnderflowException()} 
     */ 
    public void test_Constructor() { 
        BufferUnderflowException exception = new BufferUnderflowException();
        assertNull(exception.getMessage());
        assertNull(exception.getLocalizedMessage());
        assertNull(exception.getCause());
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getCause, getLocalizedMessage, getMessage
     
    /** 
     *@tests {@link java.nio.BufferUnderflowException#BufferUnderflowException()} 
     */ 
    public void test_Constructor() { 
        BufferUnderflowException exception = new BufferUnderflowException();
        assertNull(exception.getMessage());
        assertNull(exception.getLocalizedMessage());
        assertNull(exception.getCause());
    } 
} 
6
CodeRank
This code example shows how to use the following methods:initCause
        catch ( IndexOutOfBoundsException e ) {
            // 
            // Morph an IndexOutOfBoundsException to a BufferUnderflowException 
            // for consistency. 
            // 
            final BufferUnderflowException bue = new BufferUnderflowException();
            bue.initCause( e );
            throw bue;
        } 
    } 
 
    /** 
     * Gets the given chunk reading it into memory from disk if necessary. 
     * 
     * @param c The chunk index. 
     * @return Returns said chunk. 
     * @throws IllegalArgumentException if <code>c</code> is negative or 
     * greater than the number of chunks comprising the file. 
     */ 
    private synchronized ByteBuffer getChunk( int c ) throws IOException {
5
CodeRank
This code example shows how to use the following methods:initCause
			if (DEBUG) System.out.print("Reading "+ sourceOffset + " x "+ count + "... ");
			file.seek(sourceOffset);
			file.read(buffer, 0, count);
			if (DEBUG) System.out.println("done");
		} catch (IOException e) {
			BufferUnderflowException be = new BufferUnderflowException();
			be.initCause(e);
			throw be;
		} 
	} 
 
	/* (non-Javadoc) 
	 * @see org.eclipse.cdt.debug.edc.internal.StreamBufferBase#createSubBuffer(long, long) 
	 */ 
	@Override 
	protected IStreamBuffer createSubBuffer(long offset, long size) {
		return new FileStreamBuffer(file, order, offset, size);
	} 
} 
5
CodeRank
This code example shows how to use the following methods:
    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();
    } 
 
    // commit any characters up to the beginning of the replacement 
    out.write(in, inPos, startReplace - inPos);
 
    // commit the replacement 
    out.write(replaceWith, 0, replaceWith.length);
 
    // skip over the replaced characters 
    inPos = endReplace;
  } 
5
CodeRank
This code example shows how to use the following methods:
    } 
 
    private static int getArray0(ByteBuffer bb, int position, Object array) {
        final int size = getArraySize(array);
        if (bb.limit() - position < size)
            throw new BufferUnderflowException();
 
        if (!bb.isDirect())
            unsafe.copyMemory(bb.array(), base + bb.arrayOffset() + position, array, getArrayBase(array), size);
        else 
            unsafe.copyMemory(null, ((DirectBuffer) bb).address() + position, array, getArrayBase(array), size);
        return size;
    } 
 
    private static int getArrayBase(Object array) { 
        return unsafe.arrayBaseOffset(array.getClass());
    } 
 
    private static int getArraySize(Object array) { 
        return Array.getLength(array) * getArrayScale(array);
3
CodeRank
This code example shows how to use the following methods:
    } 
 
    @Override 
    public byte get() { 
        if (!hasRemaining()) { 
            throw new BufferUnderflowException();
        } 
        return heap[offset + pos++];
    } 
 
    @Override 
    public byte get(int index) {
        if (index < 0 || index >= lim) {
            throw new IndexOutOfBoundsException();
        } 
        return heap[offset + index];
    } 
 
    @Override 
    public HeapBuffer put(byte b) {
2
CodeRank
This code example shows how to use the following methods:
        if (length < 1) {
            throw new IndexOutOfBoundsException();
        } 
 
        if (bb.remaining() < length) {
            throw new BufferUnderflowException();
        } 
    } 
 
    @Override 
    public byte[] toLexBytes(ClassAndField_IdKey key) throws Exception {
        checkNotNull(key);
        byte[] classNameBytes = key.getClassName().getBytes(UTF8);
        byte[] fieldNameBytes = key.getFieldName().getBytes(UTF8);
        byte[] objectIdBytes = key.getObjectId().toLexBytes().array();
        ByteBuffer bb = ByteBuffer.allocate(4 + classNameBytes.length + 4 + fieldNameBytes.length + objectIdBytes.length);
        bb.putInt(classNameBytes.length);
        bb.put(classNameBytes);
        bb.putInt(fieldNameBytes.length);
        bb.put(fieldNameBytes);
3
CodeRank
This code example shows how to use the following methods:
    public Buffer get(final ByteBuffer dst) {
        checkDispose(); 
        final int length = dst.remaining();
         
        if (visible.remaining() < length) {
            throw new BufferUnderflowException();
        } 
         
        final int srcPos = visible.position();
        final int oldSrcLim = visible.limit();
        try { 
            visible.limit(srcPos + length);
            dst.put(visible);
        } finally { 
            visible.limit(oldSrcLim);
        } 
         
        return this;
    } 
 
2
CodeRank
This code example shows how to use the following methods:

Related Java 8 BufferUnderflowException Questions & Answers:

See Code Examples for Java 8 BufferUnderflowException Methods: