public class StringOps
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.nio.charset.Charset |
charset |
static java.nio.charset.CharsetEncoder |
encoder |
Constructor and Description |
---|
StringOps() |
Modifier and Type | Method and Description |
---|---|
static boolean |
charContained(char c,
char[] charArray)
Tells whether or not the given character is contained in the given array.
|
static boolean |
charContained(char c,
char[] charArray,
int minCheckIndex)
Tells whether or not the given character is contained in the given array.
|
static java.lang.String |
className(java.lang.String classPath)
Returns the class name of the given class.
|
static java.lang.String |
fillZeros(long number,
int stringLength)
Returns a string representation of the given number in which a minimum string length is hold.
|
static char |
getChar(java.lang.String string,
int pos)
Returns the character of the given string at the given position.
|
static char |
getChar(java.lang.String string,
int pos,
char defaultChar)
Returns the character of the given string at the given position.
|
java.lang.String |
getKeySubString(java.lang.String input,
char splitAt,
java.lang.Object key,
char keyValueSeparator,
char[] spaceChars,
char[] spaceLnChars)
Extracts a string from an input string.
|
static int |
getStringWidth(java.awt.Graphics gfx,
java.lang.String string,
java.awt.Font font)
Computes the width of a written string.
|
static byte |
hexCharToByte(char c)
Returns the byte value of one single character containing a hexadecimal digit.
|
static int |
hexStringToInt(java.lang.String hex,
boolean littleEndian)
Returns the number which is represented by the given string containing a hexadecimal number.
|
static int |
hexToByte(java.lang.String hex,
int pos)
Returns the byte which is represented by two hexadecimal characters in the given string at the given position.
|
static java.lang.String |
intToStr(int integer)
Returns a string representation of the given integer.
|
static boolean |
isNextString(java.lang.String string,
int pos,
java.lang.String nextString)
Tells whether or not a given string is contained in another given string at a given position.
|
static java.lang.String |
iterableToLines(java.lang.Iterable<?> iterable)
Returns a user-readable line wise string representation of the given Iterable.
|
static java.lang.String |
iterableToString(java.lang.Iterable<?> iterable,
java.lang.String separator,
java.lang.String empty)
Returns a user-readable string representation of the given Iterable.
|
static java.lang.String |
limitStringWidth(java.lang.String string,
int maxWidth,
java.lang.String newLine)
Inserts line breaks into the string in order that the width of one line does not exceed the given maximum width.
|
static int |
skipSpace(java.lang.String text,
int pos,
char[] spaceChars)
Returns the next position of the given string at which the character is not contained in the given array.
|
static java.io.BufferedReader |
stringToBuffer(java.lang.String string)
Converts the given string into a buffered reader in order that respective reading operations can be done on it.
|
static java.nio.ByteBuffer |
stringToByteBuffer(java.lang.String string)
Converts the given string into a byte buffer in order that respective byte buffer operations can be done on it.
|
public static java.nio.charset.Charset charset
public static java.nio.charset.CharsetEncoder encoder
public static int getStringWidth(java.awt.Graphics gfx, java.lang.String string, java.awt.Font font)
gfx
- the Graphics with which the string would be written.string
- the string to compute the width.font
- the font with which the string would be written.public static java.nio.ByteBuffer stringToByteBuffer(java.lang.String string)
string
- the string to convert.public static java.io.BufferedReader stringToBuffer(java.lang.String string)
string
- the string to convert.public static byte hexCharToByte(char c) throws HexParseException
c
- a character which can be '0' to '9', 'a' to 'f' or 'A' to 'F'.HexParseException
- if c is an invalid character.public static int hexToByte(java.lang.String hex, int pos) throws HexParseException
hex
- the string containing the hexadecimal number.pos
- the position where the number is located in the string.HexParseException
- if the characters or the position are invalid.public static int hexStringToInt(java.lang.String hex, boolean littleEndian) throws HexParseException
littleEndian
- if true, the string is assumed to represent the number in little endian order.HexParseException
- if the string contains at least one invalid characterpublic java.lang.String getKeySubString(java.lang.String input, char splitAt, java.lang.Object key, char keyValueSeparator, char[] spaceChars, char[] spaceLnChars)
input
- the input string.splitAt
- the split character. Initially, the input will be splitted at this character and the sub strings are enumerated.key
- the key object. If the key is an Integer, then the sub string with the key as index will be returned. If it is a String, then the sub string which starts with the key is returned.keyValueSeparator
- the separator which separates the keys from the values.spaceChars
- the characters to be ignored when searching keys.spaceLnChars
- the line break characters.public static java.lang.String intToStr(int integer)
integer
- the integer.public static java.lang.String className(java.lang.String classPath)
classPath
- the class name. The package path can be included.public static java.lang.String limitStringWidth(java.lang.String string, int maxWidth, java.lang.String newLine)
string
- the source string.maxWidth
- the maximum width of one line.newLine
- the line break to insert.public static java.lang.String iterableToString(java.lang.Iterable<?> iterable, java.lang.String separator, java.lang.String empty)
iterable
- the iterable object.separator
- the separator to separate two entries.empty
- the string which is to be returned, if the iterator has no element.public static java.lang.String iterableToLines(java.lang.Iterable<?> iterable)
iterable
- the iterable object.public static char getChar(java.lang.String string, int pos, char defaultChar)
string
- the string from which to read the character.pos
- the position at where to read the character from the string.defaultChar
- the default character which is to be returned, if the given position is out of range.public static char getChar(java.lang.String string, int pos)
string
- the string from which to read the character.pos
- the position at where to read the character from the string.public static boolean charContained(char c, char[] charArray, int minCheckIndex)
c
- the character to check.charArray
- the array to check the occurrence of c.minCheckIndex
- an offset for the charArray. All indices below minCheckIndex will be ignored.public static boolean charContained(char c, char[] charArray)
c
- the character to check.charArray
- the array to check the occurrence of c.public static boolean isNextString(java.lang.String string, int pos, java.lang.String nextString)
string
- the string which might contain nextString.pos
- the position where to check.nextString
- the string which might be the sub string at the given position.public static int skipSpace(java.lang.String text, int pos, char[] spaceChars)
text
- the text string.pos
- the position where to start skipping.spaceChars
- the characters to skip.public static java.lang.String fillZeros(long number, int stringLength)
number
- the number.stringLength
- the minimum length of the string representation.