< prev index next >

src/java.base/share/classes/java/lang/StringConcatHelper.java

Print this page

        

*** 142,152 **** * into higher bits. * @param buf buffer to append to * @param value boolean value to encode * @return updated index (coder value retained) */ ! static long prepend(long indexCoder, byte[] buf, boolean value) { int index = (int)indexCoder; if (indexCoder < UTF16) { if (value) { buf[--index] = 'e'; buf[--index] = 'u'; --- 142,152 ---- * into higher bits. * @param buf buffer to append to * @param value boolean value to encode * @return updated index (coder value retained) */ ! private static long prepend(long indexCoder, byte[] buf, boolean value) { int index = (int)indexCoder; if (indexCoder < UTF16) { if (value) { buf[--index] = 'e'; buf[--index] = 'u';
*** 176,196 **** return index | UTF16; } } /** ! * Prepends the stringly representation of byte value into buffer, * given the coder and final index. Index is measured in chars, not in bytes! * * @param indexCoder final char index in the buffer, along with coder packed * into higher bits. * @param buf buffer to append to ! * @param value byte value to encode * @return updated index (coder value retained) */ ! static long prepend(long indexCoder, byte[] buf, byte value) { ! return prepend(indexCoder, buf, (int)value); } /** * Prepends the stringly representation of char value into buffer, * given the coder and final index. Index is measured in chars, not in bytes! --- 176,220 ---- return index | UTF16; } } /** ! * Prepends constant and the stringly representation of value into buffer, * given the coder and final index. Index is measured in chars, not in bytes! * * @param indexCoder final char index in the buffer, along with coder packed * into higher bits. * @param buf buffer to append to ! * @param prefix a constant to prepend before value ! * @param value boolean value to encode ! * @param suffix a constant to prepend after value ! * @return updated index (coder value retained) ! */ ! static long prepend(long indexCoder, byte[] buf, String prefix, boolean value, String suffix) { ! if (suffix != null) indexCoder = prepend(indexCoder, buf, suffix); ! indexCoder = prepend(indexCoder, buf, value); ! if (prefix != null) indexCoder = prepend(indexCoder, buf, prefix); ! return indexCoder; ! } ! ! /** ! * Prepends constant and the stringly representation of value into buffer, ! * given the coder and final index. Index is measured in chars, not in bytes! ! * ! * @param indexCoder final char index in the buffer, along with coder packed ! * into higher bits. ! * @param buf buffer to append to ! * @param prefix a constant to prepend before value ! * @param value boolean value to encode ! * @param suffix a constant to prepend after value * @return updated index (coder value retained) */ ! static long prepend(long indexCoder, byte[] buf, String prefix, byte value, String suffix) { ! if (suffix != null) indexCoder = prepend(indexCoder, buf, suffix); ! indexCoder = prepend(indexCoder, buf, (int)value); ! if (prefix != null) indexCoder = prepend(indexCoder, buf, prefix); ! return indexCoder; } /** * Prepends the stringly representation of char value into buffer, * given the coder and final index. Index is measured in chars, not in bytes!
*** 199,229 **** * into higher bits. * @param buf buffer to append to * @param value char value to encode * @return updated index (coder value retained) */ ! static long prepend(long indexCoder, byte[] buf, char value) { if (indexCoder < UTF16) { buf[(int)(--indexCoder)] = (byte) (value & 0xFF); } else { StringUTF16.putChar(buf, (int)(--indexCoder), value); } return indexCoder; } /** ! * Prepends the stringly representation of short value into buffer, * given the coder and final index. Index is measured in chars, not in bytes! * * @param indexCoder final char index in the buffer, along with coder packed * into higher bits. * @param buf buffer to append to ! * @param value short value to encode * @return updated index (coder value retained) */ ! static long prepend(long indexCoder, byte[] buf, short value) { ! return prepend(indexCoder, buf, (int)value); } /** * Prepends the stringly representation of integer value into buffer, * given the coder and final index. Index is measured in chars, not in bytes! --- 223,277 ---- * into higher bits. * @param buf buffer to append to * @param value char value to encode * @return updated index (coder value retained) */ ! private static long prepend(long indexCoder, byte[] buf, char value) { if (indexCoder < UTF16) { buf[(int)(--indexCoder)] = (byte) (value & 0xFF); } else { StringUTF16.putChar(buf, (int)(--indexCoder), value); } return indexCoder; } /** ! * Prepends constant and the stringly representation of value into buffer, ! * given the coder and final index. Index is measured in chars, not in bytes! ! * ! * @param indexCoder final char index in the buffer, along with coder packed ! * into higher bits. ! * @param buf buffer to append to ! * @param prefix a constant to prepend before value ! * @param value boolean value to encode ! * @param suffix a constant to prepend after value ! * @return updated index (coder value retained) ! */ ! static long prepend(long indexCoder, byte[] buf, String prefix, char value, String suffix) { ! if (suffix != null) indexCoder = prepend(indexCoder, buf, suffix); ! indexCoder = prepend(indexCoder, buf, value); ! if (prefix != null) indexCoder = prepend(indexCoder, buf, prefix); ! return indexCoder; ! } ! ! /** ! * Prepends constant and the stringly representation of value into buffer, * given the coder and final index. Index is measured in chars, not in bytes! * * @param indexCoder final char index in the buffer, along with coder packed * into higher bits. * @param buf buffer to append to ! * @param prefix a constant to prepend before value ! * @param value boolean value to encode ! * @param suffix a constant to prepend after value * @return updated index (coder value retained) */ ! static long prepend(long indexCoder, byte[] buf, String prefix, short value, String suffix) { ! if (suffix != null) indexCoder = prepend(indexCoder, buf, suffix); ! indexCoder = prepend(indexCoder, buf, (int)value); ! if (prefix != null) indexCoder = prepend(indexCoder, buf, prefix); ! return indexCoder; } /** * Prepends the stringly representation of integer value into buffer, * given the coder and final index. Index is measured in chars, not in bytes!
*** 232,288 **** * into higher bits. * @param buf buffer to append to * @param value integer value to encode * @return updated index (coder value retained) */ ! static long prepend(long indexCoder, byte[] buf, int value) { if (indexCoder < UTF16) { return Integer.getChars(value, (int)indexCoder, buf); } else { return StringUTF16.getChars(value, (int)indexCoder, buf) | UTF16; } } /** * Prepends the stringly representation of long value into buffer, * given the coder and final index. Index is measured in chars, not in bytes! * * @param indexCoder final char index in the buffer, along with coder packed * into higher bits. * @param buf buffer to append to * @param value long value to encode * @return updated index (coder value retained) */ ! static long prepend(long indexCoder, byte[] buf, long value) { if (indexCoder < UTF16) { return Long.getChars(value, (int)indexCoder, buf); } else { return StringUTF16.getChars(value, (int)indexCoder, buf) | UTF16; } } /** * Prepends the stringly representation of String value into buffer, * given the coder and final index. Index is measured in chars, not in bytes! * * @param indexCoder final char index in the buffer, along with coder packed * into higher bits. * @param buf buffer to append to * @param value String value to encode * @return updated index (coder value retained) */ ! static long prepend(long indexCoder, byte[] buf, String value) { indexCoder -= value.length(); if (indexCoder < UTF16) { value.getBytes(buf, (int)indexCoder, String.LATIN1); } else { value.getBytes(buf, (int)indexCoder, String.UTF16); } return indexCoder; } /** * Instantiates the String with given buffer and coder * @param buf buffer to use * @param indexCoder remaining index (should be zero) and coder * @return String resulting string */ --- 280,393 ---- * into higher bits. * @param buf buffer to append to * @param value integer value to encode * @return updated index (coder value retained) */ ! private static long prepend(long indexCoder, byte[] buf, int value) { if (indexCoder < UTF16) { return Integer.getChars(value, (int)indexCoder, buf); } else { return StringUTF16.getChars(value, (int)indexCoder, buf) | UTF16; } } /** + * Prepends constant and the stringly representation of value into buffer, + * given the coder and final index. Index is measured in chars, not in bytes! + * + * @param indexCoder final char index in the buffer, along with coder packed + * into higher bits. + * @param buf buffer to append to + * @param prefix a constant to prepend before value + * @param value boolean value to encode + * @param suffix a constant to prepend after value + * @return updated index (coder value retained) + */ + static long prepend(long indexCoder, byte[] buf, String prefix, int value, String suffix) { + if (suffix != null) indexCoder = prepend(indexCoder, buf, suffix); + indexCoder = prepend(indexCoder, buf, value); + if (prefix != null) indexCoder = prepend(indexCoder, buf, prefix); + return indexCoder; + } + + /** * Prepends the stringly representation of long value into buffer, * given the coder and final index. Index is measured in chars, not in bytes! * * @param indexCoder final char index in the buffer, along with coder packed * into higher bits. * @param buf buffer to append to * @param value long value to encode * @return updated index (coder value retained) */ ! private static long prepend(long indexCoder, byte[] buf, long value) { if (indexCoder < UTF16) { return Long.getChars(value, (int)indexCoder, buf); } else { return StringUTF16.getChars(value, (int)indexCoder, buf) | UTF16; } } /** + * Prepends constant and the stringly representation of value into buffer, + * given the coder and final index. Index is measured in chars, not in bytes! + * + * @param indexCoder final char index in the buffer, along with coder packed + * into higher bits. + * @param buf buffer to append to + * @param prefix a constant to prepend before value + * @param value boolean value to encode + * @param suffix a constant to prepend after value + * @return updated index (coder value retained) + */ + static long prepend(long indexCoder, byte[] buf, String prefix, long value, String suffix) { + if (suffix != null) indexCoder = prepend(indexCoder, buf, suffix); + indexCoder = prepend(indexCoder, buf, value); + if (prefix != null) indexCoder = prepend(indexCoder, buf, prefix); + return indexCoder; + } + + /** * Prepends the stringly representation of String value into buffer, * given the coder and final index. Index is measured in chars, not in bytes! * * @param indexCoder final char index in the buffer, along with coder packed * into higher bits. * @param buf buffer to append to * @param value String value to encode * @return updated index (coder value retained) */ ! private static long prepend(long indexCoder, byte[] buf, String value) { indexCoder -= value.length(); if (indexCoder < UTF16) { value.getBytes(buf, (int)indexCoder, String.LATIN1); } else { value.getBytes(buf, (int)indexCoder, String.UTF16); } return indexCoder; } /** + * Prepends constant and the stringly representation of value into buffer, + * given the coder and final index. Index is measured in chars, not in bytes! + * + * @param indexCoder final char index in the buffer, along with coder packed + * into higher bits. + * @param buf buffer to append to + * @param prefix a constant to prepend before value + * @param value boolean value to encode + * @param suffix a constant to prepend after value + * @return updated index (coder value retained) + */ + static long prepend(long indexCoder, byte[] buf, String prefix, String value, String suffix) { + if (suffix != null) indexCoder = prepend(indexCoder, buf, suffix); + indexCoder = prepend(indexCoder, buf, value); + if (prefix != null) indexCoder = prepend(indexCoder, buf, prefix); + return indexCoder; + } + + /** * Instantiates the String with given buffer and coder * @param buf buffer to use * @param indexCoder remaining index (should be zero) and coder * @return String resulting string */
< prev index next >