Package org.apache.groovy.json.internal
Class Chr
java.lang.Object
org.apache.groovy.json.internal.Chr
Character array helpers used by the JSON internals.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void_idx(char[] buffer, int location, byte[] chars) Copies a byte array into a character buffer.static void_idx(char[] buffer, int location, byte[] chars, int start, int end) Copies part of a byte array into a character buffer.static void_idx(char[] array, int startIndex, char[] input) Copies a character array into another array.static void_idx(char[] array, int startIndex, char[] input, int inputLength) Copies a fixed number of characters into another array.static char[]add(char[]... strings) Concatenates all non-null arrays.static char[]add(char[] array, char v) Appends a character to a new array copy.static char[]add(char[] array, char[] array2) Concatenates two character arrays.static char[]Appends a string to a new array copy.static char[]add(char[] array, StringBuilder stringBuilder) Appends aStringBuilderto a new array copy.static char[]array(char... array) Returns the supplied characters as an array literal helper.static char[]Converts a string to a character array.static booleancontains(char[] chars, char c, int start, int length) Tests whether the supplied range contains a character.static char[]copy(char[] array) Copies an entire character array.static char[]copy(char[] array, int offset, int length) Copies a character range into a new array.static char[]grow(char[] array) Doubles the size of an array.static char[]grow(char[] array, int size) Grows an array by the supplied increment.static booleanin(char value, char[] array) Tests whether the supplied character occurs in the array.static booleanin(char value, int offset, char[] array) Tests whether the supplied character occurs in the array from the given offset.static booleanin(char value, int offset, int end, char[] array) Tests whether the supplied character occurs in the specified array range.static booleanin(int value, char[] array) Tests whether the supplied character code occurs in the array.static char[]lpad(char[] in, int size, char pad) Left-pads a character array to the requested size.
-
Constructor Details
-
Chr
public Chr()
-
-
Method Details
-
array
public static char[] array(char... array) Returns the supplied characters as an array literal helper.- Parameters:
array- the characters to return- Returns:
- the supplied array
-
chars
Converts a string to a character array.- Parameters:
array- the string to convert- Returns:
- the string characters
-
in
public static boolean in(char value, char[] array) Tests whether the supplied character occurs in the array.- Parameters:
value- the character to findarray- the array to scan- Returns:
trueif the character is present
-
in
public static boolean in(int value, char[] array) Tests whether the supplied character code occurs in the array.- Parameters:
value- the character code to findarray- the array to scan- Returns:
trueif the character is present
-
in
public static boolean in(char value, int offset, char[] array) Tests whether the supplied character occurs in the array from the given offset.- Parameters:
value- the character to findoffset- the inclusive scan startarray- the array to scan- Returns:
trueif the character is present
-
in
public static boolean in(char value, int offset, int end, char[] array) Tests whether the supplied character occurs in the specified array range.- Parameters:
value- the character to findoffset- the inclusive scan startend- the exclusive scan endarray- the array to scan- Returns:
trueif the character is present
-
grow
public static char[] grow(char[] array, int size) Grows an array by the supplied increment.- Parameters:
array- the array to growsize- the number of extra slots to allocate- Returns:
- the grown array
-
grow
public static char[] grow(char[] array) Doubles the size of an array.- Parameters:
array- the array to grow- Returns:
- the grown array
-
copy
public static char[] copy(char[] array) Copies an entire character array.- Parameters:
array- the array to copy- Returns:
- the copied array
-
copy
public static char[] copy(char[] array, int offset, int length) Copies a character range into a new array.- Parameters:
array- the source arrayoffset- the inclusive start indexlength- the number of characters to copy- Returns:
- the copied range
-
add
public static char[] add(char[] array, char v) Appends a character to a new array copy.- Parameters:
array- the source arrayv- the character to append- Returns:
- the new array
-
add
Appends a string to a new array copy.- Parameters:
array- the source arraystr- the string to append- Returns:
- the new array
-
add
Appends aStringBuilderto a new array copy.- Parameters:
array- the source arraystringBuilder- the characters to append- Returns:
- the new array
-
add
public static char[] add(char[] array, char[] array2) Concatenates two character arrays.- Parameters:
array- the first arrayarray2- the second array- Returns:
- the concatenated array
-
lpad
public static char[] lpad(char[] in, int size, char pad) Left-pads a character array to the requested size.- Parameters:
in- the input arraysize- the target sizepad- the padding character- Returns:
- the padded array, or the input if no padding is needed
-
contains
public static boolean contains(char[] chars, char c, int start, int length) Tests whether the supplied range contains a character.- Parameters:
chars- the array to scanc- the character to findstart- the inclusive scan startlength- the number of characters to scan- Returns:
trueif the character is present
-
_idx
public static void _idx(char[] buffer, int location, byte[] chars) Copies a byte array into a character buffer.- Parameters:
buffer- the destination bufferlocation- the destination offsetchars- the bytes to copy
-
_idx
public static void _idx(char[] array, int startIndex, char[] input) Copies a character array into another array.- Parameters:
array- the destination arraystartIndex- the destination offsetinput- the characters to copy
-
_idx
public static void _idx(char[] array, int startIndex, char[] input, int inputLength) Copies a fixed number of characters into another array.- Parameters:
array- the destination arraystartIndex- the destination offsetinput- the source charactersinputLength- the number of characters to copy
-
_idx
public static void _idx(char[] buffer, int location, byte[] chars, int start, int end) Copies part of a byte array into a character buffer.- Parameters:
buffer- the destination bufferlocation- the destination offsetchars- the source bytesstart- the inclusive source startend- the exclusive source end
-
add
public static char[] add(char[]... strings) Concatenates all non-null arrays.- Parameters:
strings- the arrays to concatenate- Returns:
- the concatenated array
-