public int length() { return buffer.length(); }
public ArrayList<String> readUTF8String(String word) throws IOException { CharBuffer cbuf = CharBuffer.wrap(word); ArrayList<String> utf8CharList = new ArrayList<String>(); for (int i = 0; i < cbuf.length(); i++) { char ch = cbuf.get(i); utf8CharList.add(toHex4((int) ch)); } return utf8CharList; }
/** * Reads characters and puts them into the {@code target} character buffer. * * @param target * the destination character buffer. * @return the number of characters put into {@code target} or -1 if the end * of this reader has been reached before a character has been read. * @throws IOException * if any I/O error occurs while reading from this reader. * @throws NullPointerException * if {@code target} is {@code null}. * @throws ReadOnlyBufferException * if {@code target} is read-only. */ public int read(CharBuffer target) throws IOException { int length = target.length(); char[] buf = new char[length]; length = Math.min(length, read(buf)); if (length > 0) { target.put(buf, 0, length); } return length; } }
/** * Sets the contents of this string to the contents of the given <tt>CharBuffer</tt>. * The characters between the buffer's current position (inclusive) and the buffer's * limit (exclusive) will be stored in this string. * * @param buffer The character buffer to read the characters from. */ public void setValue(CharBuffer buffer) { checkNotNull(buffer); final int len = buffer.length(); ensureSize(len); buffer.get(this.value, 0, len); this.len = len; this.hashCode = 0; }
private int compareNumerically(final CharBuffer b1, final CharBuffer b2) { final int diff = b1.length() - b2.length(); if (diff != 0) { return diff; } for (int i = 0; i < b1.remaining() && i < b2.remaining(); ++i) { final int result = Character.compare(b1.charAt(i), b2.charAt(i)); if (result != 0) { return result; } } return 0; }
/** * Invokes the delegate's <code>read(CharBuffer)</code> method. * @param target the char buffer to read the characters into * @return the number of characters read or -1 if the end of stream * @throws IOException if an I/O error occurs * @since 2.0 */ @Override public int read(final CharBuffer target) throws IOException { try { beforeRead(target != null ? target.length() : 0); final int n = in.read(target); afterRead(n); return n; } catch (final IOException e) { handleIOException(e); return EOF; } }
@Override public Memory valueOfIndex(TraceInfo trace, boolean index) { int _index = index ? 1 : 0; if (_index >= 0 && _index < buffer.length()) return new BinaryMemory(buffer.charAt(_index)); else return CONST_EMPTY_STRING; }
@Override public Memory valueOfIndex(TraceInfo trace, long index) { int _index = (int)index; if (_index >= 0 && _index < buffer.length()) return getChar(buffer.charAt(_index)); else return CONST_EMPTY_STRING; }
@Override public Memory valueOfIndex(TraceInfo trace, long index) { int _index = (int)index; if (_index >= 0 && _index < buffer.length()) { return new BinaryMemory(buffer.charAt(_index)); } else return CONST_EMPTY_STRING; }
@Override public Memory valueOfIndex(TraceInfo trace, double index) { int _index = (int)index; if (_index >= 0 && _index < buffer.length()) return new BinaryMemory(buffer.charAt(_index)); else return CONST_EMPTY_STRING; }
@Override public Memory valueOfIndex(TraceInfo trace, double index) { int _index = (int)index; if (_index >= 0 && _index < buffer.length()) return getChar(buffer.charAt(_index)); else return CONST_EMPTY_STRING; }
@Override public Memory valueOfIndex(TraceInfo trace, boolean index) { int _index = index ? 1 : 0; if (_index >= 0 && _index < buffer.length()) return getChar(buffer.charAt(_index)); else return CONST_EMPTY_STRING; }
int size = cb.length();
final int maxLength = (int) ((double) len * decoder.maxCharsPerByte()); CharBuffer dst = CHAR_BUFFERS.get(); if (dst.length() < maxLength) { dst = CharBuffer.allocate(maxLength); CHAR_BUFFERS.set(dst);
charBuffer.flip(); if (charBuffer.length() == 0) { LOGGER.log(POILogger.WARN, "couldn't create char for: " + Integer.toString((leading & 0xff), 16)
@Override public Memory valueOfIndex(TraceInfo trace, String index) { int _index = -1; Memory tmp = StringMemory.toLong(index); if (tmp != null) _index = tmp.toInteger(); if (_index >= 0 && _index < buffer.length()) return new BinaryMemory(buffer.charAt(_index)); else return CONST_EMPTY_STRING; }
@Override public Memory valueOfIndex(TraceInfo trace, String index) { int _index = -1; Memory tmp = StringMemory.toLong(index); if (tmp != null) _index = tmp.toInteger(); if (_index >= 0 && _index < buffer.length()) return getChar(buffer.charAt(_index)); else return CONST_EMPTY_STRING; }
final int maxLength = (int) ((double) len * decoder.maxCharsPerByte()); CharBuffer dst = CHAR_BUFFERS.get(); if (dst.length() < maxLength) { dst = CharBuffer.allocate(maxLength); if (maxLength <= MAX_CHAR_BUFFER_SIZE) {
@Override public Memory valueOfIndex(TraceInfo trace, Memory index) { int _index = -1; switch (index.type){ case STRING: Memory tmp = StringMemory.toLong(index.toString()); if (tmp != null) _index = tmp.toInteger(); break; case REFERENCE: return valueOfIndex(index.toValue()); default: _index = index.toInteger(); } if (_index < buffer.length() && _index >= 0) return getChar(buffer.charAt(_index)); else return CONST_EMPTY_STRING; }