Top Description Inners Fields Constructors Methods
org.eclipse.jgit.ignore.internal

public Class Strings

extends Object
Class Inheritance
Static Imports
java.lang.Character.isLetter

Various java.lang.String related utility methods, written mostly to avoid generation of new String objects (e.g. via splitting Strings etc).

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum

Field Summary

Modifier and TypeField and Description
private static final String
pack-priv static final List<String>
pack-priv static final List<String>
pack-priv static final Pattern

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static String
checkPosixCharClass(char[] buffer)

pack-priv static Strings.PatternState
pack-priv static Pattern

Returns:

Java regex pattern corresponding to given glob pattern
convertGlob
(String
non null pattern
pattern
)

Conversion from glob to Java regex following two sources:

  • http://man7.org/linux/man-pages/man7/glob.7.html
  • org.eclipse.jgit.fnmatch.FileNameMatcher.java Seems that there are various ways to define what "glob" can be.
pack-priv static int
count(String s, char c, boolean ignoreFirstLast)

pack-priv static String
private static boolean
escapedByBackslash(char nextChar)

pack-priv static char
getPathSeparator(Character pathSeparator)

private static boolean
public static boolean

Returns:

true if the last character, which is not whitespace, is a path separator
isDirectoryPattern
(String
non null
pattern
)

Check if pattern is a directory pattern ending with a path separator

pack-priv static boolean
isWildCard(String pattern)

private static char

Returns:

zero if the index is out of range, otherwise the next character from given position
lookAhead
(String
the pattern
pattern
,
int
current pointer in the pattern
i
)

Lookahead next character after given index in pattern

private static char

Returns:

zero of the buffer is empty, otherwise the last character from buffer
lookBehind
(StringBuilder
buffer
buffer
)

private static void
reset(char[] buffer)

private static void
setNext(char[] buffer, char c)

public static List<String>

Returns:

list of substrings
split
(String
non null
pattern
,
char
separator char
slash
)

Splits given string to substrings by given separator

public static String

Returns:

new string with all trailing characters removed
stripTrailing
(String
non null
pattern
,
char
character to remove
c
)

Strip trailing characters

public static String

Returns:

new string with all trailing whitespace removed
stripTrailingWhitespace
(String
non null
pattern
)

Strip trailing whitespace characters

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DLback to summary
private static final String DL
JAVA_CHAR_CLASSESback to summary
pack-priv static final List<String> JAVA_CHAR_CLASSES
POSIX_CHAR_CLASSESback to summary
pack-priv static final List<String> POSIX_CHAR_CLASSES
UNSUPPORTEDback to summary
pack-priv static final Pattern UNSUPPORTED

Constructor Detail

Stringsback to summary
public Strings()

Method Detail

checkPosixCharClassback to summary
private static String checkPosixCharClass(char[] buffer)
checkWildCardsback to summary
pack-priv static Strings.PatternState checkWildCards(String pattern)
convertGlobback to summary
pack-priv static Pattern convertGlob(String pattern) throws InvalidPatternException

Conversion from glob to Java regex following two sources:

  • http://man7.org/linux/man-pages/man7/glob.7.html
  • org.eclipse.jgit.fnmatch.FileNameMatcher.java Seems that there are various ways to define what "glob" can be.
Parameters
pattern:String

non null pattern

Returns:Pattern

Java regex pattern corresponding to given glob pattern

Exceptions
InvalidPatternException:
if pattern is invalid
countback to summary
pack-priv static int count(String s, char c, boolean ignoreFirstLast)
deleteBackslashback to summary
pack-priv static String deleteBackslash(String s)
escapedByBackslashback to summary
private static boolean escapedByBackslash(char nextChar)
getPathSeparatorback to summary
pack-priv static char getPathSeparator(Character pathSeparator)
isComplexWildcardback to summary
private static boolean isComplexWildcard(String pattern)
isDirectoryPatternback to summary
public static boolean isDirectoryPattern(String pattern)

Check if pattern is a directory pattern ending with a path separator

Parameters
pattern:String

non null

Returns:boolean

true if the last character, which is not whitespace, is a path separator

isWildCardback to summary
pack-priv static boolean isWildCard(String pattern)
lookAheadback to summary
private static char lookAhead(String pattern, int i)

Lookahead next character after given index in pattern

Parameters
pattern:String

the pattern

i:int

current pointer in the pattern

Returns:char

zero if the index is out of range, otherwise the next character from given position

lookBehindback to summary
private static char lookBehind(StringBuilder buffer)
Parameters
buffer:StringBuilder

buffer

Returns:char

zero of the buffer is empty, otherwise the last character from buffer

resetback to summary
private static void reset(char[] buffer)
setNextback to summary
private static void setNext(char[] buffer, char c)
splitback to summary
public static List<String> split(String pattern, char slash)

Splits given string to substrings by given separator

Parameters
pattern:String

non null

slash:char

separator char

Returns:List<String>

list of substrings

stripTrailingback to summary
public static String stripTrailing(String pattern, char c)

Strip trailing characters

Parameters
pattern:String

non null

c:char

character to remove

Returns:String

new string with all trailing characters removed

stripTrailingWhitespaceback to summary
public static String stripTrailingWhitespace(String pattern)

Strip trailing whitespace characters

Parameters
pattern:String

non null

Returns:String

new string with all trailing whitespace removed

org.eclipse.jgit.ignore.internal back to summary

pack-priv final Enum Strings.PatternState

extends Enum<Strings.PatternState>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final Strings.PatternState
public static final Strings.PatternState
public static final Strings.PatternState
public static final Strings.PatternState

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Strings.PatternState
public static Strings.PatternState[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

COMPLEXback to summary
public static final Strings.PatternState COMPLEX
LEADING_ASTERISK_ONLYback to summary
public static final Strings.PatternState LEADING_ASTERISK_ONLY
NONEback to summary
public static final Strings.PatternState NONE
TRAILING_ASTERISK_ONLYback to summary
public static final Strings.PatternState TRAILING_ASTERISK_ONLY

Constructor Detail

PatternStateback to summary
private PatternState()

Method Detail

valueOfback to summary
public static Strings.PatternState valueOf(String name)
valuesback to summary
public static Strings.PatternState[] values()