/** * Tests if there are bytes remaining in the read buffer. * * @return <tt>true</tt> if there are bytes available in the read buffer. */ private final boolean hasBufferedInputBytes() { return reading && (buffer.hasRemaining() || hasUngotChars()); }
/** * Tests if there are bytes remaining in the read buffer. * * @return <tt>true</tt> if there are bytes available in the read buffer. */ private final boolean hasBufferedInputBytes() { return reading && (buffer.hasRemaining() || hasUngotChars()); }
/** * Tests if there are bytes remaining in the read buffer. * * @return <tt>true</tt> if there are bytes available in the read buffer. */ private final boolean hasBufferedInputBytes() { return reading && (buffer.hasRemaining() || hasUngotChars()); }
/** * Tests if there are bytes remaining in the read buffer. * * @return <tt>true</tt> if there are bytes available in the read buffer. */ private final boolean hasBufferedInputBytes() { return reading && (buffer.hasRemaining() || hasUngotChars()); }
public boolean readDataBuffered() { return reading && (hasUngotChars() || buffer.hasRemaining()); }
public boolean readDataBuffered() { return reading && (hasUngotChars() || buffer.hasRemaining()); }
/** * Copies bytes from the channel buffer into a destination <tt>ByteBuffer</tt> * * @param dst A <tt>ByteBuffer</tt> to place the data in. * @return The number of bytes copied. */ private final int copyBufferedBytes(byte[] dst, int off, int len) { int bytesCopied = 0; if (hasUngotChars() && len > 0) { for(int i = 0; i < ungotChars.length(); i++){ byte ungotc = (byte) ungotChars.get(i); dst[off++] = ungotc; ++bytesCopied; } clearUngotChars(); } final int n = Math.min(len - bytesCopied, buffer.remaining()); buffer.get(dst, off, n); bytesCopied += n; return bytesCopied; }
/** * Copies bytes from the channel buffer into a destination <tt>ByteBuffer</tt> * * @param dst A <tt>ByteBuffer</tt> to place the data in. * @return The number of bytes copied. */ private final int copyBufferedBytes(byte[] dst, int off, int len) { int bytesCopied = 0; if (hasUngotChars() && len > 0) { for(int i = 0; i < ungotChars.length(); i++){ byte ungotc = (byte) ungotChars.get(i); dst[off++] = ungotc; ++bytesCopied; } clearUngotChars(); } final int n = Math.min(len - bytesCopied, buffer.remaining()); buffer.get(dst, off, n); bytesCopied += n; return bytesCopied; }
/** * Copies bytes from the channel buffer into a destination <tt>ByteBuffer</tt> * * @param dst A <tt>ByteBuffer</tt> to place the data in. * @return The number of bytes copied. */ private final int copyBufferedBytes(byte[] dst, int off, int len) { int bytesCopied = 0; if (hasUngotChars() && len > 0) { for(int i = 0; i < ungotChars.length(); i++){ byte ungotc = (byte) ungotChars.get(i); dst[off++] = ungotc; ++bytesCopied; } clearUngotChars(); } final int n = Math.min(len - bytesCopied, buffer.remaining()); buffer.get(dst, off, n); bytesCopied += n; return bytesCopied; }
/** * Copies bytes from the channel buffer into a destination <tt>ByteBuffer</tt> * * @param dst A <tt>ByteBuffer</tt> to place the data in. * @return The number of bytes copied. */ private final int copyBufferedBytes(byte[] dst, int off, int len) { int bytesCopied = 0; if (hasUngotChars() && len > 0) { for(int i = 0; i < ungotChars.length(); i++){ byte ungotc = (byte) ungotChars.get(i); dst[off++] = ungotc; ++bytesCopied; } clearUngotChars(); } final int n = Math.min(len - bytesCopied, buffer.remaining()); buffer.get(dst, off, n); bytesCopied += n; return bytesCopied; }
/** * @throws IOException */ public synchronized long fgetpos() throws IOException, PipeException, InvalidValueException, BadDescriptorException { // Correct position for read / write buffering (we could invalidate, but expensive) if (descriptor.isSeekable()) { FileChannel fileChannel = (FileChannel)descriptor.getChannel(); long pos = fileChannel.position(); // Adjust for buffered data if (reading) { pos -= buffer.remaining(); return pos - (pos > 0 && hasUngotChars() ? ungotChars.length() : 0); } else { return pos + buffer.position(); } } else if (descriptor.isNull()) { return 0; } else { throw new PipeException(); } }
/** * Copies bytes from the channel buffer into a destination <tt>ByteBuffer</tt> * * @param dst A <tt>ByteList</tt> to place the data in. * @param len The maximum number of bytes to copy. * @return The number of bytes copied. */ private final int copyBufferedBytes(ByteList dst, int len) { int bytesCopied = 0; dst.ensure(Math.min(len, bufferedInputBytesRemaining())); if (hasUngotChars() && hasUngotChars()) { for(int i = 0; i < ungotChars.length(); i++){ byte ungotc = (byte) ungotChars.get(i); ++bytesCopied; dst.append(ungotc); } clearUngotChars(); } // // Copy out any buffered bytes // if (bytesCopied < len && buffer.hasRemaining()) { int n = Math.min(buffer.remaining(), len - bytesCopied); dst.append(buffer, n); bytesCopied += n; } return bytesCopied; }
/** * @throws IOException */ public synchronized long fgetpos() throws IOException, PipeException, InvalidValueException, BadDescriptorException { // Correct position for read / write buffering (we could invalidate, but expensive) if (descriptor.isSeekable()) { FileChannel fileChannel = (FileChannel)descriptor.getChannel(); long pos = fileChannel.position(); // Adjust for buffered data if (reading) { pos -= buffer.remaining(); return pos - (pos > 0 && hasUngotChars() ? ungotChars.length() : 0); } else { return pos + buffer.position(); } } else if (descriptor.isNull()) { return 0; } else { throw new PipeException(); } }
public synchronized int read() throws IOException, BadDescriptorException { try { descriptor.checkOpen(); if (hasUngotChars()) { int c = ungotChars.get(0); ungotChars.delete(0,1); return c; } return bufferedRead(); } catch (EOFException e) { eof = true; return -1; } }
/** * Copies bytes from the channel buffer into a destination <tt>ByteBuffer</tt> * * @param dst A <tt>ByteList</tt> to place the data in. * @param len The maximum number of bytes to copy. * @return The number of bytes copied. */ private final int copyBufferedBytes(ByteList dst, int len) { int bytesCopied = 0; dst.ensure(Math.min(len, bufferedInputBytesRemaining())); if (hasUngotChars()) { for(int i = 0; i < ungotChars.length(); i++){ byte ungotc = (byte) ungotChars.get(i); ++bytesCopied; dst.append(ungotc); } clearUngotChars(); } // // Copy out any buffered bytes // if (bytesCopied < len && buffer.hasRemaining()) { int n = Math.min(buffer.remaining(), len - bytesCopied); dst.append(buffer, n); bytesCopied += n; } return bytesCopied; }
public synchronized int read() throws IOException, BadDescriptorException { try { descriptor.checkOpen(); if (hasUngotChars()) { int c = ungotChars.get(0); ungotChars.delete(0,1); return c; } return bufferedRead(); } catch (EOFException e) { eof = true; return -1; } }
public synchronized int read() throws IOException, BadDescriptorException { try { descriptor.checkOpen(); if (hasUngotChars()) { int c = ungotChars.get(0); ungotChars.delete(0,1); return c; } return bufferedRead(); } catch (EOFException e) { eof = true; return -1; } }
public synchronized int read() throws IOException, BadDescriptorException { try { descriptor.checkOpen(); if (hasUngotChars()) { int c = ungotChars.get(0); ungotChars.delete(0,1); return c; } return bufferedRead(); } catch (EOFException e) { eof = true; return -1; } }
/** * @throws IOException */ public synchronized long fgetpos() throws IOException, PipeException, InvalidValueException, BadDescriptorException { // Correct position for read / write buffering (we could invalidate, but expensive) if (descriptor.isSeekable()) { SeekableByteChannel fileChannel = (SeekableByteChannel) descriptor.getChannel(); long pos = fileChannel.position(); // Adjust for buffered data if (reading) { pos -= buffer.remaining(); return pos - (pos > 0 && hasUngotChars() ? ungotChars.length() : 0); } else { return pos + buffer.position(); } } else if (descriptor.isNull()) { return 0; } else { throw new PipeException(); } }
/** * @throws IOException */ public synchronized long fgetpos() throws IOException, PipeException, InvalidValueException, BadDescriptorException { // Correct position for read / write buffering (we could invalidate, but expensive) if (descriptor.isSeekable()) { SeekableByteChannel fileChannel = (SeekableByteChannel) descriptor.getChannel(); long pos = fileChannel.position(); // Adjust for buffered data if (reading) { pos -= buffer.remaining(); return pos - (pos > 0 && hasUngotChars() ? ungotChars.length() : 0); } else { return pos + buffer.position(); } } else if (descriptor.isNull()) { return 0; } else { throw new PipeException(); } }