/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*/
{
private volatile boolean isOpen = true;
if (!isOpen)
throw new IOException("Stream closed");
}
// In order to handle surrogates properly we must never try to produce
// fewer than two characters at a time. If we're only asked to return one
// character then the other is saved here to be returned later.
//
private boolean haveLeftoverChar = false;
private char leftoverChar;
// Factories for java.io.InputStreamReader
throws UnsupportedEncodingException
{
try {
} catch (IllegalCharsetNameException x) { }
throw new UnsupportedEncodingException (csn);
}
{
}
{
}
// Factory for java.nio.channels.Channels.newReader
int minBufferCap)
{
}
// -- Public methods corresponding to those in InputStreamReader --
// methods; the concrete stream-decoder subclasses defined below need not
// do any such checking.
if (isOpen())
return encodingName();
return null;
}
return read0();
}
synchronized (lock) {
// Return the leftover char, if there is one
if (haveLeftoverChar) {
haveLeftoverChar = false;
return leftoverChar;
}
// Convert more bytes
char cb[] = new char[2];
switch (n) {
case -1:
return -1;
case 2:
haveLeftoverChar = true;
// FALL THROUGH
case 1:
return cb[0];
default:
assert false : n;
return -1;
}
}
}
synchronized (lock) {
ensureOpen();
throw new IndexOutOfBoundsException();
}
if (len == 0)
return 0;
int n = 0;
if (haveLeftoverChar) {
// Copy the leftover char into the buffer
haveLeftoverChar = false;
n = 1;
// Return now if this is all we can produce w/o blocking
return n;
}
if (len == 1) {
// Treat single-character array reads just like read()
int c = read0();
if (c == -1)
return (n == 0) ? -1 : n;
return n + 1;
}
}
}
synchronized (lock) {
ensureOpen();
return haveLeftoverChar || implReady();
}
}
synchronized (lock) {
if (!isOpen)
return;
implClose();
isOpen = false;
}
}
private boolean isOpen() {
return isOpen;
}
// -- Charset-based stream decoder impl --
// In the early stages of the build we haven't yet built the NIO native
// code, so guard against that by catching the first UnsatisfiedLinkError
// and setting this flag so that later attempts fail quickly.
//
private static volatile boolean channelsAvailable = true;
if (!channelsAvailable)
return null;
try {
return in.getChannel();
} catch (UnsatisfiedLinkError x) {
channelsAvailable = false;
return null;
}
}
// Exactly one of these is non-null
cs.newDecoder()
}
super(lock);
// This path disabled until direct buffers are faster
if (false && in instanceof FileInputStream) {
}
}
}
: (mbc < MIN_BYTE_BUFFER_SIZE
: mbc));
}
try {
// Read from the channel
if (n < 0)
return n;
} else {
// Read from the input stream, and then update the buffer
assert rem > 0;
if (n < 0)
return n;
if (n == 0)
throw new IOException("Underlying input stream returned zero bytes");
}
} finally {
// Flip even when an IOException is thrown,
// otherwise the stream will stutter
}
return rem;
}
// In order to handle surrogate pairs, this method requires that
// the invoker attempt to read at least two characters. Saving the
// extra character, if any, at a higher level is easier than trying
// to deal with it here.
// Ensure that cb[0] == cbuf[off]
boolean eof = false;
for (;;) {
if (cr.isUnderflow()) {
if (eof)
break;
if (!cb.hasRemaining())
break;
break; // Block at most once
int n = readBytes();
if (n < 0) {
eof = true;
break;
}
continue;
}
if (cr.isOverflow()) {
break;
}
cr.throwException();
}
if (eof) {
// ## Need to flush decoder
}
if (eof)
return -1;
assert false;
}
}
return ((cs instanceof HistoricallyNamedCharset)
}
private boolean inReady() {
try {
} catch (IOException x) {
return false;
}
}
boolean implReady() {
}
else
}
}