325 * @param value String value to encode 326 * @return new index 327 */ 328 static int prepend(int index, byte[] buf, byte coder, String value) { 329 index -= value.length(); 330 value.getBytes(buf, index, coder); 331 return index; 332 } 333 334 /** 335 * Instantiates the String with given buffer and coder 336 * @param buf buffer to use 337 * @param coder coder to use 338 * @return String resulting string 339 */ 340 static String newString(byte[] buf, byte coder) { 341 // Use the private, non-copying constructor (unsafe!) 342 return new String(buf, coder); 343 } 344 345 } | 325 * @param value String value to encode 326 * @return new index 327 */ 328 static int prepend(int index, byte[] buf, byte coder, String value) { 329 index -= value.length(); 330 value.getBytes(buf, index, coder); 331 return index; 332 } 333 334 /** 335 * Instantiates the String with given buffer and coder 336 * @param buf buffer to use 337 * @param coder coder to use 338 * @return String resulting string 339 */ 340 static String newString(byte[] buf, byte coder) { 341 // Use the private, non-copying constructor (unsafe!) 342 return new String(buf, coder); 343 } 344 345 /** 346 * Provides the initial coder for the String. 347 * @return initial coder 348 */ 349 static byte initialCoder() { 350 return String.COMPACT_STRINGS ? String.LATIN1 : String.UTF16; 351 } 352 353 } |