/** * Reads a byte from the buffer without advancing the index pointer. * * @return byte from the buffer without advancing the index pointer * @throws IOException if something wrong happens */ public int peek() throws IOException { if (ensureBytes(1)) { return buffer[index] & 0xFF; } return -1; }
/** * Reads a byte from the buffer without advancing the index pointer. */ public int peek() throws IOException { if (ensureBytes(1)) { return buffer[index] & 0xFF; } return -1; }
/** * {@inheritDoc} */ public int read() throws IOException { if (ensureBytes(1)) { return buffer[index++] & 0xFF; } return -1; }
/** * {@inheritDoc} */ public int read() throws IOException { if (ensureBytes(1)) { return buffer[index++] & 0xFF; } return -1; }
ensureBytes(len); avail = endIndex - index;
ensureBytes(len); avail = endIndex - index;
/** * Receives a fixed-size string from the backend. * * @param len the length of the string to receive, in bytes. * @return the decoded string * @throws IOException if something wrong happens */ public String receiveString(int len) throws IOException { if (!pg_input.ensureBytes(len)) { throw new EOFException(); } String res = encoding.decode(pg_input.getBuffer(), pg_input.getIndex(), len); pg_input.skip(len); return res; }
/** * Receives a fixed-size string from the backend. * * @param len the length of the string to receive, in bytes. * @return the decoded string */ public String ReceiveString(int len) throws IOException { if (!pg_input.ensureBytes(len)) { throw new EOFException(); } String res = encoding.decode(pg_input.getBuffer(), pg_input.getIndex(), len); pg_input.skip(len); return res; }
/** * Receives a fixed-size string from the backend, and tries to avoid "UTF-8 decode failed" * errors. * * @param len the length of the string to receive, in bytes. * @return the decoded string * @throws IOException if something wrong happens */ public EncodingPredictor.DecodeResult receiveErrorString(int len) throws IOException { if (!pg_input.ensureBytes(len)) { throw new EOFException(); } EncodingPredictor.DecodeResult res; try { String value = encoding.decode(pg_input.getBuffer(), pg_input.getIndex(), len); // no autodetect warning as the message was converted on its own res = new EncodingPredictor.DecodeResult(value, null); } catch (IOException e) { res = EncodingPredictor.decode(pg_input.getBuffer(), pg_input.getIndex(), len); if (res == null) { Encoding enc = Encoding.defaultEncoding(); String value = enc.decode(pg_input.getBuffer(), pg_input.getIndex(), len); res = new EncodingPredictor.DecodeResult(value, enc.name()); } } pg_input.skip(len); return res; }
/** * Reads a byte from the buffer without advancing the index pointer. */ public int peek() throws IOException { if (ensureBytes(1)) { return buffer[index] & 0xFF; } return -1; }
/** * {@inheritDoc} */ public int read() throws IOException { if (ensureBytes(1)) { return buffer[index++] & 0xFF; } return -1; }
/** * {@inheritDoc} */ public int read() throws IOException { if (ensureBytes(1)) { return buffer[index++] & 0xFF; } return -1; }
ensureBytes(len); avail = endIndex - index;
ensureBytes(len); avail = endIndex - index;
/** * Receives a fixed-size string from the backend. * * @param len the length of the string to receive, in bytes. * @return the decoded string */ public String ReceiveString(int len) throws IOException { if (!pg_input.ensureBytes(len)) { throw new EOFException(); } String res = encoding.decode(pg_input.getBuffer(), pg_input.getIndex(), len); pg_input.skip(len); return res; }
/** * Receives a fixed-size string from the backend. * * @param len the length of the string to receive, in bytes. * @return the decoded string */ public String ReceiveString(int len) throws IOException { if (!pg_input.ensureBytes(len)) { throw new EOFException(); } String res = encoding.decode(pg_input.getBuffer(), pg_input.getIndex(), len); pg_input.skip(len); return res; }