Java Code Examples for java.nio.CharBuffer#hasArray()

The following examples show how to use java.nio.CharBuffer#hasArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChannelHelper.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * ByteChannelからchar配列を読み込む
 * @param channel
 * @return
 * @throws IOException
 */
public static char[] readCharArray(@NonNull final ByteChannel channel)
	throws IOException {
	
	final int n = readInt(channel);
	final ByteBuffer buf = ByteBuffer.allocate(n * 2).order(ByteOrder.BIG_ENDIAN);
	final int readBytes = channel.read(buf);
	if (readBytes != n * 2) throw new IOException();
	buf.clear();
	final CharBuffer result = buf.asCharBuffer();
	if (result.hasArray()) {
		return result.array();
	}  else {
		final char[] b = new char[n];
		result.get(b);
		return b;
	}
}
 
Example 2
Source File: EUC_TW.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst)
{
    if (src.hasArray() && dst.hasArray())
        return encodeArrayLoop(src, dst);
    else
        return encodeBufferLoop(src, dst);
}
 
Example 3
Source File: ISO2022_CN.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected CoderResult decodeLoop(ByteBuffer src,
                                 CharBuffer dst)
{
    if (src.hasArray() && dst.hasArray())
        return decodeArrayLoop(src, dst);
    else
        return decodeBufferLoop(src, dst);
}
 
Example 4
Source File: EUC_TW.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst)
{
    if (src.hasArray() && dst.hasArray())
        return encodeArrayLoop(src, dst);
    else
        return encodeBufferLoop(src, dst);
}
 
Example 5
Source File: EUC_TW.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected CoderResult decodeLoop(ByteBuffer src, CharBuffer dst)
{
    if (src.hasArray() && dst.hasArray())
        return decodeArrayLoop(src, dst);
    else
        return decodeBufferLoop(src, dst);
}
 
Example 6
Source File: ISO_8859_1.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected CoderResult encodeLoop(CharBuffer src,
                                 ByteBuffer dst)
{
    if (src.hasArray() && dst.hasArray())
        return encodeArrayLoop(src, dst);
    else
        return encodeBufferLoop(src, dst);
}
 
Example 7
Source File: US_ASCII.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected CoderResult decodeLoop(ByteBuffer src,
                                 CharBuffer dst)
{
    if (src.hasArray() && dst.hasArray())
        return decodeArrayLoop(src, dst);
    else
        return decodeBufferLoop(src, dst);
}
 
Example 8
Source File: ISO2022.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected CoderResult decodeLoop(ByteBuffer src,
                                 CharBuffer dst)
{
    if (src.hasArray() && dst.hasArray())
        return decodeArrayLoop(src, dst);
    else
        return decodeBufferLoop(src, dst);
}
 
Example 9
Source File: ISO2022.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected CoderResult encodeLoop(CharBuffer src,
                                 ByteBuffer dst)
{
    if (src.hasArray() && dst.hasArray())
        return encodeArrayLoop(src, dst);
    else
        return encodeBufferLoop(src, dst);
}
 
Example 10
Source File: ISCII91.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected CoderResult encodeLoop(CharBuffer src,
                                 ByteBuffer dst)
{
    if (src.hasArray() && dst.hasArray())
        return encodeArrayLoop(src, dst);
    else
        return encodeBufferLoop(src, dst);
}
 
Example 11
Source File: UTF_8.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected CoderResult decodeLoop(ByteBuffer src,
                                 CharBuffer dst)
{
    if (src.hasArray() && dst.hasArray())
        return decodeArrayLoop(src, dst);
    else
        return decodeBufferLoop(src, dst);
}
 
Example 12
Source File: CESU_8.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
protected final CoderResult encodeLoop(CharBuffer src,
                                       ByteBuffer dst)
{
    if (src.hasArray() && dst.hasArray())
        return encodeArrayLoop(src, dst);
    else
        return encodeBufferLoop(src, dst);
}
 
Example 13
Source File: UTF_8.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected CoderResult decodeLoop(ByteBuffer src,
                                 CharBuffer dst)
{
    if (src.hasArray() && dst.hasArray())
        return decodeArrayLoop(src, dst);
    else
        return decodeBufferLoop(src, dst);
}
 
Example 14
Source File: EUC_JP.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) {
    if (src.hasArray() && dst.hasArray())
        return decodeArrayLoop(src, dst);
    else
        return decodeBufferLoop(src, dst);
}
 
Example 15
Source File: DefaultCredentialManager.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
private static void scrub(final CharBuffer cb) {
  if (cb.hasArray()) {
    scrub(cb.array(), cb.arrayOffset(), cb.arrayOffset() + cb.position() + cb.remaining());
  }
}
 
Example 16
Source File: SJIS_0213.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) {
    if (src.hasArray() && dst.hasArray())
        return decodeArrayLoop(src, dst);
    else
        return decodeBufferLoop(src, dst);
}
 
Example 17
Source File: HKSCS.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) {
    if (src.hasArray() && dst.hasArray())
        return encodeArrayLoop(src, dst);
    else
        return encodeBufferLoop(src, dst);
}
 
Example 18
Source File: ISO2022_JP.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) {
    if (src.hasArray() && dst.hasArray())
        return decodeArrayLoop(src, dst);
    else
        return decodeBufferLoop(src, dst);
}
 
Example 19
Source File: DBCS_IBM_ASCII_Encoder.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) {
    if (true && src.hasArray() && dst.hasArray())
        return encodeArrayLoop(src, dst);
    else
        return encodeBufferLoop(src, dst);
}
 
Example 20
Source File: SingleByte.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) {
    if (src.hasArray() && dst.hasArray())
        return decodeArrayLoop(src, dst);
    else
        return decodeBufferLoop(src, dst);
}