/*
(non-Javadoc)
@see javax.jms.StreamMessage#readChar()
483998
@Override
	public char readChar() throws JMSException
    {
    	backupState();
    	try
    	{
    		return MessageConvertTools.asChar(internalReadObject());
    	}
    	catch (JMSException e)
    	{
    		restoreState();
    		throw e;	
    	}
    	catch (RuntimeException e)
    	{
    		restoreState();
    		throw e;
    	}
    }
758936
@Override
	public String readString() throws JMSException
    {
    	backupState();
		try
		{
			return MessageConvertTools.asString(internalReadObject());
		}
    	catch (JMSException e)
    	{
    		restoreState();
    		throw e;	
    	}
    	catch (RuntimeException e)
    	{
    		restoreState();
    		throw e;
    	}
    }
994928
@Override
    public String readString() {
        final char[] text0 = this.text;
        int currpos = this.position;
        char expected = text0[++currpos];
        if (expected <= ' ') {
            for (;;) {
                expected = text0[++currpos];
                if (expected > ' ') break;
            }
        }
        if (expected != '"' && expected != '\'') {
            if (expected == 'n' && text0.length > currpos + 3 && (text0[1 + currpos] == 'u' && text0[2 + currpos] == 'l' && text0[3 + currpos] == 'l')) {
                if (text0[++currpos] == 'u' && text0[++currpos] == 'l' && text0[++currpos] == 'l') {
                    this.position = currpos;
                    if (text0.length > currpos + 4) {
                        char ch = text0[currpos + 1];
                        if (ch == ',' || ch <= ' ' || ch == '}' || ch == ']' || ch == ':') return null;
                        final int start = currpos - 3;
                        for (;;) {
                            if (currpos >= text0.length) break;
                            ch = text0[currpos];
                            if (ch == ',' || ch <= ' ' || ch == '}' || ch == ']' || ch == ':') break;
                            currpos++;
                        }
                        if (currpos == start) throw new ConvertException("expected a string after a key but '" + text0[position] + "' (position = " + position + ") in (" + new String(this.text) + ")");
                        this.position = currpos - 1;
                        return new String(text0, start, currpos - start);
                    } else {
                        return null;
                    }
                }
            } else {
                final int start = currpos;
                for (;;) {
                    if (currpos >= text0.length) break;
                    char ch = text0[currpos];
                    if (ch == ',' || ch <= ' ' || ch == '}' || ch == ']' || ch == ':') break;
                    currpos++;
                }
                if (currpos == start) throw new ConvertException("expected a string after a key but '" + text0[position] + "' (position = " + position + ") in (" + new String(this.text) + ")");
                this.position = currpos - 1;
                return new String(text0, start, currpos - start);
            }
            this.position = currpos;
            throw new ConvertException("expected a ':' after a key but '" + text0[position] + "' (position = " + position + ") in (" + new String(this.text) + ")");
        }
        final int start = ++currpos;
        for (;;) {
            char ch = text0[currpos];
            if (ch == expected) {
                break;
            } else if (ch == '\\') {
                this.position = currpos - 1;
                return readEscapeValue(expected, start);
            }
            currpos++;
        }
        this.position = currpos;
        return new String(text0, start, currpos - start);
    }
1204924
protected String reportInvalidChar(DTDValidatorBase v, char c, String msg)
        throws XMLStreamException
    {
        reportValidationProblem(v, "Invalid character "+WstxInputData.getCharDesc(c)+": "+msg);
        return null;
    }
295935
private void _backupChar (final int c)
  {
    if (c != EOI)
      try
      {
        m_aReader.unread (c);
        m_nBackupChars++;
      }
      catch (final IOException ex)
      {
        throw new IllegalStateException ("Failed to unread character " + _getPrintableChar (c));
      }
  }
285546
private int readChar(Reader source) throws ParseException
    {
        int c;

        try {
            c = source.read();
        } catch (IOException e) {
            throw new ParseException("Failed to read input source", e);
        }

        return c;
    }
1167345
public int scanChar() throws IOException {

	// load more characters, if needed
	if (fCurrentEntity.position == fCurrentEntity.count) {
	    load(0, true);
	}

	// scan character
	int c = fCurrentEntity.ch[fCurrentEntity.position++];
	boolean external = false;
	if (c == '\n' ||
	    (c == '\r' && (external = fCurrentEntity.isExternal()))) {
	    fCurrentEntity.lineNumber++;
	    fCurrentEntity.columnNumber = 1;
	    if (fCurrentEntity.position == fCurrentEntity.count) {
		fCurrentEntity.ch[0] = (char)c;
		load(1, false);
	    }
	    if (c == '\r' && external) {
		if (fCurrentEntity.ch[fCurrentEntity.position++] != '\n') {
		    fCurrentEntity.position--;
		}
		c = '\n';
	    }
	}

	// return character that was scanned
	fCurrentEntity.columnNumber++;
	return c;
	
    }
728717
public static char decodeChar(byte[] src, int srcOffset)
        throws CorruptEncodingException
    {
        try {
            return (char)((src[srcOffset] << 8) | (src[srcOffset + 1] & 0xff));
        } catch (IndexOutOfBoundsException e) {
            throw new CorruptEncodingException(null, e);
        }
    }
572617
@Override
    public int read(char[] cbuf, int off, int len) throws IOException {
        int numChars = super.read(cbuf, off, len);
        replaceBadXmlCharactersBySpace(cbuf, off, len);
        return numChars;
    }
460476
public void read(Charset charset, Writer writer) throws IllegalStateException, IOException {
        writer.write(read(charset).toString());
    }
109485
public char read_char() throws OtpErlangDecodeException {
        final long l = this.read_long(true);
        final char i = (char) l;

        if (l != (i & 0xffffL)) {
            throw new OtpErlangDecodeException("Value does not fit in char: "
                    + l);
        }

        return i;
    }
1163522
@Override
  public int read(char[] chr) throws IOException {
    try {
      beforeRead(chr != null ? chr.length : 0);
      int n = in.read(chr);
      afterRead(n);
      return n;
    } catch (IOException e) {
      handleIOException(e);
      return -1;
    }
  }
927459
public String readString(final String charset) throws IOException {
        byte ch;
        int cnt = 0;
        final byte [] byteArrBuff = new byte[byteBuffer.remaining()];
        while (byteBuffer.remaining() > 0 && ((ch = byteBuffer.get()) != 0)) {
            byteArrBuff[cnt++] = ch;
        }
        return new String(byteArrBuff,0,cnt);
    }
483180
public static String read(InputStream in, String charset) throws IOException {
        if (in == null) {
            throw new IllegalArgumentException("input stream cannot be null");
        }
        InputStreamReader reader = null;
        try {
            reader = new InputStreamReader(in, charset);
            char[] buffer = new char[1024];
            StringBuilder sb = new StringBuilder();
            int len;
            while ((len = reader.read(buffer)) != -1) {
                sb.append(buffer, 0, len);
            }
            return sb.toString();
        } finally {
            closeQuietly(reader);
        }
    }
1359339
private char nextChar() throws IOException {
		if (missedChar != null) {
			// RETURNS THE PREVIOUS PARSED CHAR
			c = missedChar.charValue();
			missedChar = null;

		} else {
			c = (char) in.read();

			if (c == '\\') {
				char c2 = (char) in.read();
				if (c2 == 'u') {
					// DECODE UNICODE CHAR
					final StringBuilder buff = new StringBuilder();
					for (int i = 0; i < 4; ++i)
						buff.append((char) in.read());

					cursor += 6;

					return (char) Integer.parseInt(buff.toString(), 16);
				} else {
					// REMEMBER THE CURRENT CHAR TO RETURN NEXT TIME
					missedChar = c2;
				}
			}
		}

		cursor++;

		if (c == NEW_LINE) {
			++lineNumber;
			columnNumber = 0;
		} else
			++columnNumber;

		return c;
	}

	public char lastChar() {
		return c;
	}

	public String getValue() {
		return value;
	}

	public int getLineNumber() {
		return lineNumber;
	}

	public int getColumnNumber() {
		return columnNumber;
	}

	public boolean hasNext() throws IOException {
		return in.ready();
	}
}
514841
@Override
    public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException
    {
        checkParameterBounds(parameterIndex);
        throw SQLError.noSupport();
    }
204972
@Override
	public String read( final SocketChannel channel, final String charset, int bufferSize ) throws IOException {
		final ByteBuffer buffer = ByteBuffer.allocate( bufferSize );
		final ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
		while ( true ){
			final int readBytes = channel.read( buffer );
			if ( readBytes == -1 ) break;
			if ( readBytes > 0 ) {
				final byte[] bytes = readBytes == bufferSize ? buffer.array() : Arrays.copyOf(buffer.array(), readBytes);
				byteStream.write( bytes );
			}
			buffer.clear();
		}
		return new String( byteStream.toByteArray(), charset );
	}