Package io.bytestreams.codec.core.util
Class Strings
java.lang.Object
io.bytestreams.codec.core.util.Strings
Utility methods for string operations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intcodePointCount(String value) Returns the number of Unicode code points in the string.static inthexByteCount(int digits) Returns the number of bytes represented by the given number of hex digits (two digits per byte).static inthexByteCount(String value) Returns the number of bytes represented by the hex string (two hex digits per byte).static booleanisSingleByte(Charset charset) Returns whether the charset uses at most one byte per character.padEnd(char padding, int length) Returns a function that pads the end of a string with the specified character until it reaches the desired length.static StringPads the end of a string with the specified character until it reaches the desired length.padStart(char padding, int length) Returns a function that pads the start of a string with the specified character until it reaches the desired length.static StringPads the start of a string with the specified character until it reaches the desired length.static StringStrips trailing occurrences of the specified character from the string.static StringstripStart(String value, char padding) Strips leading occurrences of the specified character from the string.
-
Method Details
-
padStart
Pads the start of a string with the specified character until it reaches the desired length.- Parameters:
value- the string to padpadding- the character to use for paddinglength- the target length- Returns:
- the padded string, or the original string if already at or above the target length
-
padEnd
Pads the end of a string with the specified character until it reaches the desired length.- Parameters:
value- the string to padpadding- the character to use for paddinglength- the target length- Returns:
- the padded string, or the original string if already at or above the target length
-
padStart
Returns a function that pads the start of a string with the specified character until it reaches the desired length.- Parameters:
padding- the character to use for paddinglength- the target length- Returns:
- a function that pads strings on the left
-
padEnd
Returns a function that pads the end of a string with the specified character until it reaches the desired length.- Parameters:
padding- the character to use for paddinglength- the target length- Returns:
- a function that pads strings on the right
-
stripStart
Strips leading occurrences of the specified character from the string.- Parameters:
value- the string to strippadding- the character to strip- Returns:
- the stripped string
-
stripEnd
Strips trailing occurrences of the specified character from the string.- Parameters:
value- the string to strippadding- the character to strip- Returns:
- the stripped string
-
isSingleByte
Returns whether the charset uses at most one byte per character.- Parameters:
charset- the charset to check- Returns:
- true if the charset is single-byte
-
codePointCount
Returns the number of Unicode code points in the string.- Parameters:
value- the string to count code points in- Returns:
- the number of code points
-
hexByteCount
Returns the number of bytes represented by the hex string (two hex digits per byte).- Parameters:
value- the hex string to count bytes in- Returns:
- the number of bytes
-
hexByteCount
public static int hexByteCount(int digits) Returns the number of bytes represented by the given number of hex digits (two digits per byte).- Parameters:
digits- the number of hex digits- Returns:
- the number of bytes
-