/** Reads the length and string of UTF8 characters, or null. This can read strings written by * {@link Output#writeString(String)} , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}. * @return May be null. */ public String readString () { int available = require(1); int b = buffer[position++]; if ((b & 0x80) == 0) return readAscii(); // ASCII. // Null, empty, or UTF8. int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b); switch (charCount) { case 0: return null; case 1: return ""; } charCount--; if (chars.length < charCount) chars = new char[charCount]; readUtf8(charCount); return new String(chars, 0, charCount); }
/** Reads the length and string of UTF8 characters, or null. This can read strings written by * {@link Output#writeString(String)} , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}. * @return May be null. */ public String readString () { int available = require(1); int b = buffer[position++]; if ((b & 0x80) == 0) return readAscii(); // ASCII. // Null, empty, or UTF8. int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b); switch (charCount) { case 0: return null; case 1: return ""; } charCount--; if (chars.length < charCount) chars = new char[charCount]; readUtf8(charCount); return new String(chars, 0, charCount); }
/** Reads the length and string of UTF8 characters, or null. This can read strings written by {@link Output#writeString(String)} * , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}. * @return May be null. */ public String readString () { int available = require(1); int b = buffer[position++]; if ((b & 0x80) == 0) return readAscii(); // ASCII. // Null, empty, or UTF8. int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b); switch (charCount) { case 0: return null; case 1: return ""; } charCount--; if (chars.length < charCount) chars = new char[charCount]; readUtf8(charCount); return new String(chars, 0, charCount); }
/** Reads the length and string of UTF8 characters, or null. This can read strings written by {@link Output#writeString(String)} * , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}. * @return May be null. */ public StringBuilder readStringBuilder () { int available = require(1); int b = buffer[position++]; if ((b & 0x80) == 0) return new StringBuilder(readAscii()); // ASCII. // Null, empty, or UTF8. int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b); switch (charCount) { case 0: return null; case 1: return new StringBuilder(""); } charCount--; if (chars.length < charCount) chars = new char[charCount]; readUtf8(charCount); StringBuilder builder = new StringBuilder(charCount); builder.append(chars, 0, charCount); return builder; }
/** Reads the length and string of UTF8 characters, or null. This can read strings written by {@link Output#writeString(String)} * , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}. * @return May be null. */ public String readString () { int available = require(1); int b = buffer[position++]; if ((b & 0x80) == 0) return readAscii(); // ASCII. // Null, empty, or UTF8. int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b); switch (charCount) { case 0: return null; case 1: return ""; } charCount--; if (chars.length < charCount) chars = new char[charCount]; readUtf8(charCount); return new String(chars, 0, charCount); }
/** Reads the length and string of UTF8 characters, or null. This can read strings written by * {@link Output#writeString(String)} , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}. * @return May be null. */ public StringBuilder readStringBuilder () { int available = require(1); int b = buffer[position++]; if ((b & 0x80) == 0) return new StringBuilder(readAscii()); // ASCII. // Null, empty, or UTF8. int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b); switch (charCount) { case 0: return null; case 1: return new StringBuilder(""); } charCount--; if (chars.length < charCount) chars = new char[charCount]; readUtf8(charCount); StringBuilder builder = new StringBuilder(charCount); builder.append(chars, 0, charCount); return builder; }
/** Reads the length and string of UTF8 characters, or null. This can read strings written by {@link Output#writeString(String)} * , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}. * @return May be null. */ public StringBuilder readStringBuilder () { int available = require(1); int b = buffer[position++]; if ((b & 0x80) == 0) return new StringBuilder(readAscii()); // ASCII. // Null, empty, or UTF8. int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b); switch (charCount) { case 0: return null; case 1: return new StringBuilder(""); } charCount--; if (chars.length < charCount) chars = new char[charCount]; readUtf8(charCount); StringBuilder builder = new StringBuilder(charCount); builder.append(chars, 0, charCount); return builder; }
/** Reads the length and string of UTF8 characters, or null. This can read strings written by * {@link Output#writeString(String)} , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}. * @return May be null. */ public StringBuilder readStringBuilder () { int available = require(1); int b = buffer[position++]; if ((b & 0x80) == 0) return new StringBuilder(readAscii()); // ASCII. // Null, empty, or UTF8. int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b); switch (charCount) { case 0: return null; case 1: return new StringBuilder(""); } charCount--; if (chars.length < charCount) chars = new char[charCount]; readUtf8(charCount); StringBuilder builder = new StringBuilder(charCount); builder.append(chars, 0, charCount); return builder; }