GlueGen: com.jogamp.common.util.StringUtil Class Reference

GlueGen v2.6.0 GlueGen, Native Binding Generator for Java™ (public API).

Static Public Member Functions | Static Public Attributes | List of all members
com.jogamp.common.util.StringUtil Class Reference

Basic utility functions for `String` and `CharSequence` in general. More...

Collaboration diagram for com.jogamp.common.util.StringUtil:

## Static Public Member Functions

static boolean | isWhitespace (final int cp)
| Return true if given codepoint in included within `WHITESPACE`. More...
static boolean | isFullwidth (final int cp)
| Returns true if given codepoint is a fullwidth unicode character. More...
static boolean | isHalfwidth (final int cp)
| Returns true if given codepoint is a halfwidth unicode character. More...
static boolean | hasSpace (final int cp)
| Returns true if given codepoint is either `isFullwidth(int)`, `isHalfwidth(int)` or `isWhitespace(int)`. More...
static int | getLineCount (final CharSequence s)
| Returns number of lines, i.e. More...
static int | indexOf (final String hay, final int needle, final int start)
| Calls `String#indexOf(int, int)`. More...
static int | indexOf (final CharSequence hay, final int needle, final int start)
| Naive implementation of `String#indexOf(int, int)` for type `CharSequence`. More...
static String | trim (final String text, final String separators, final String replacement)
| Remove all leading, trailing and duplicate-within `separators` unicode character from the `text`. More...
static List< String > | split (final String text, final int lineCount, final String separators)
| Returns an array of split `text` at `separators` or `whitespace`. More...
static String | split (final String text, final int lineCount, final String separators, final String lineSeparator)
| Returns a multi-line string of split `text` at `separators` or `whitespace` glued with given `lineSeparator`. More...

## Static Public Attributes

static final char | LF = '\n'
| Linefeed character unicode `'\n'`, 0x000A. More...
static final char | CR = '\r'
| CR character unicode `'\r'`, 0x000D. More...
static final char | SPACE = ' '
| Space character unicode `' '`, 0x0020. More...
static final String | WHITESPACE
| List of ASCII & Unicode space separator, aka `Whitespace`. More...

## Detailed Description

Basic utility functions for `String` and `CharSequence` in general.

Definition at line 34 of file StringUtil.java.

## Member Function Documentation

## ◆ getLineCount()

static int com.jogamp.common.util.StringUtil.getLineCount | ( | final CharSequence | s | ) |

static

Returns number of lines, i.e.

number of non-empty lines, separated by `LF`.

Definition at line 102 of file StringUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ hasSpace()

static boolean com.jogamp.common.util.StringUtil.hasSpace | ( | final int | cp | ) |

static

Returns true if given codepoint is either `isFullwidth(int)`, `isHalfwidth(int)` or `isWhitespace(int)`.

Definition at line 97 of file StringUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ indexOf() [1/2]

static int com.jogamp.common.util.StringUtil.indexOf | ( | final CharSequence | hay,
|  | final int | needle,
|  | final int | start
| ) |  |

static

Naive implementation of `String#indexOf(int, int)` for type `CharSequence`.

Uses `String#indexOf(int, int)` if `hay` is of type `String`, otherwise

Parameters

  hay | the unicode character string to search in from `fromIdx`
  needle | the unicode code point character to search
  start | index to start searching

Returns
  `-1` if not found, otherwise [0..`String#length()`-1].

See also
  #indexOf(String, char, int)
  String::indexOf(int, int)

Definition at line 150 of file StringUtil.java.

## ◆ indexOf() [2/2]

static int com.jogamp.common.util.StringUtil.indexOf | ( | final String | hay,
|  | final int | needle,
|  | final int | start
| ) |  |

static

Calls `String#indexOf(int, int)`.

Parameters

  hay | the unicode character string to search in from `fromIdx`
  needle | the unicode code point character to search
  start | index to start searching

Returns
  `-1` if not found, otherwise [0..`String#length()`-1].

See also
  indexOf(CharSequence, int, int)
  String::indexOf(int, int)

Definition at line 131 of file StringUtil.java.

Here is the caller graph for this function:

## ◆ isFullwidth()

static boolean com.jogamp.common.util.StringUtil.isFullwidth | ( | final int | cp | ) |

static

Returns true if given codepoint is a fullwidth unicode character.

See also
  https://www.compart.com/en/unicode/block/U+FF00

Definition at line 85 of file StringUtil.java.

Here is the caller graph for this function:

## ◆ isHalfwidth()

static boolean com.jogamp.common.util.StringUtil.isHalfwidth | ( | final int | cp | ) |

static

Returns true if given codepoint is a halfwidth unicode character.

See also
  https://www.compart.com/en/unicode/block/U+FF00

Definition at line 92 of file StringUtil.java.

Here is the caller graph for this function:

## ◆ isWhitespace()

static boolean com.jogamp.common.util.StringUtil.isWhitespace | ( | final int | cp | ) |

static

Return true if given codepoint in included within `WHITESPACE`.

Definition at line 77 of file StringUtil.java.

## ◆ split() [1/2]

static List< String > com.jogamp.common.util.StringUtil.split | ( | final String | text,
|  | final int | lineCount,
|  | final String | separators
| ) |  |

static

Returns an array of split `text` at `separators` or `whitespace`.

Each line's cutting point is the first `separator` or `whitespace` occurrence starting at `text.length() / lineCount * 0.9`.

The separator or `whitespace` character at the cutting point is skipped in the resulting array of the split parts, i.e. lines.

Parameters

  text | the text to be split, `null` results in an empty list
  lineCount | number of resulting lines
  separators | separator unicode characters, pass `null` for `whitespace`. Consider using `WHITESPACE` to cover all unicode space character.

See also
  split(String, int, String, String)

Definition at line 254 of file StringUtil.java.

Here is the caller graph for this function:

## ◆ split() [2/2]

static String com.jogamp.common.util.StringUtil.split | ( | final String | text,
|  | final int | lineCount,
|  | final String | separators,
|  | final String | lineSeparator
| ) |  |

static

Returns a multi-line string of split `text` at `separators` or `whitespace` glued with given `lineSeparator`.

Each line's cutting point is the first `separator` or `whitespace` occurrence starting at `text.length() / lineCount * 0.9`.

The separator character or `whitespace` at the cutting point is skipped in the string of glued split parts, i.e. lines.

Parameters

  text | the text to be split, `null` results in an empty list
  lineCount | number of resulting lines
  separators | separator unicode characters, pass `null` for `whitespace`. Consider using `WHITESPACE` to cover all unicode space character.
  lineSeparator | the glue placed between the split lines in the concatenated result

See also
  split(String, int, String)

Definition at line 315 of file StringUtil.java.

Here is the call graph for this function:

## ◆ trim()

static String com.jogamp.common.util.StringUtil.trim | ( | final String | text,
|  | final String | separators,
|  | final String | replacement
| ) |  |

static

Remove all leading, trailing and duplicate-within `separators` unicode character from the `text`.

Duplicate `separators` unicode character within the `text` are reduced to one occurrence and might be replaced with `replacement` if not `null`.

Parameters

  text | the source text
  separators | separator unicode characters, pass `null` for `whitespace`. Consider using `WHITESPACE` to cover all unicode space character.
  replacement | optional replacement string for matched separator within sequence removing duplicated. If `null`, the first found separator is used.

Returns
  stripped text

Definition at line 192 of file StringUtil.java.

Here is the caller graph for this function:

## Member Data Documentation

## ◆ CR

final char com.jogamp.common.util.StringUtil.CR = '\r'

static

CR character unicode `'\r'`, 0x000D.

Definition at line 38 of file StringUtil.java.

## ◆ LF

final char com.jogamp.common.util.StringUtil.LF = '\n'

static

Linefeed character unicode `'\n'`, 0x000A.

Definition at line 36 of file StringUtil.java.

## ◆ SPACE

final char com.jogamp.common.util.StringUtil.SPACE = ' '

static

Space character unicode `' '`, 0x0020.

Definition at line 40 of file StringUtil.java.

## ◆ WHITESPACE

final String com.jogamp.common.util.StringUtil.WHITESPACE

static

Initial value:
=
String.valueOf("\t")+
String.valueOf(LF)+
String.valueOf(Character.toChars(0x000B))+
String.valueOf(Character.toChars(0x000C))+
String.valueOf(CR)+
String.valueOf(SPACE)+
String.valueOf(Character.toChars(0x0085))+
String.valueOf(Character.toChars(0x00A0))+
String.valueOf(Character.toChars(0x1680))+
String.valueOf(Character.toChars(0x2000))+
String.valueOf(Character.toChars(0x2001))+
String.valueOf(Character.toChars(0x2002))+
String.valueOf(Character.toChars(0x2003))+
String.valueOf(Character.toChars(0x2004))+
String.valueOf(Character.toChars(0x2005))+
String.valueOf(Character.toChars(0x2006))+
String.valueOf(Character.toChars(0x2007))+
String.valueOf(Character.toChars(0x2008))+
String.valueOf(Character.toChars(0x2009))+
String.valueOf(Character.toChars(0x200A))+
String.valueOf(Character.toChars(0x202F))+
String.valueOf(Character.toChars(0x205F))+
String.valueOf(Character.toChars(0x3000))
com.jogamp.common.util.StringUtil.LF
static final char LF
Linefeed character unicode '\n', 0x000A.
Definition: StringUtil.java:36
com.jogamp.common.util.StringUtil.SPACE
static final char SPACE
Space character unicode ' ', 0x0020.
Definition: StringUtil.java:40
com.jogamp.common.util.StringUtil.CR
static final char CR
CR character unicode '\r', 0x000D.
Definition: StringUtil.java:38

List of ASCII & Unicode space separator, aka `Whitespace`.

See also
  https://www.compart.com/en/unicode/category/Zs
  https://en.wikipedia.org/wiki/Whitespace_character
  https://www.unicode.org/reports/tr44/#General_Category_Values
  ftp://ftp.unicode.org/Public/UNIDATA/Scripts.txt
  https://www.w3schools.com/charsets/ref_utf_punctuation.asp

Definition at line 50 of file StringUtil.java.

The documentation for this class was generated from the following file:

- src/java/com/jogamp/common/util/StringUtil.java