Package org.eclipse.jgit.ignore.internal
Class Strings
- java.lang.Object
-
- org.eclipse.jgit.ignore.internal.Strings
-
public class Strings extends java.lang.ObjectVariousStringrelated utility methods, written mostly to avoid generation of new String objects (e.g. via splitting Strings etc).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classStrings.PatternState
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringDL(package private) static java.util.List<java.lang.String>JAVA_CHAR_CLASSES(package private) static java.util.List<java.lang.String>POSIX_CHAR_CLASSES(package private) static java.util.regex.PatternUNSUPPORTED
-
Constructor Summary
Constructors Constructor Description Strings()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.StringcheckPosixCharClass(char[] buffer)(package private) static Strings.PatternStatecheckWildCards(java.lang.String pattern)(package private) static java.util.regex.PatternconvertGlob(java.lang.String 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.(package private) static intcount(java.lang.String s, char c, boolean ignoreFirstLast)(package private) static java.lang.StringdeleteBackslash(java.lang.String s)private static booleanescapedByBackslash(char nextChar)(package private) static chargetPathSeparator(java.lang.Character pathSeparator)private static booleanisComplexWildcard(java.lang.String pattern)static booleanisDirectoryPattern(java.lang.String pattern)Check if pattern is a directory pattern ending with a path separator(package private) static booleanisWildCard(java.lang.String pattern)private static charlookAhead(java.lang.String pattern, int i)private static charlookBehind(java.lang.StringBuilder buffer)private static voidreset(char[] buffer)private static voidsetNext(char[] buffer, char c)static java.util.List<java.lang.String>split(java.lang.String pattern, char slash)Splits given string to substrings by given separatorstatic java.lang.StringstripTrailing(java.lang.String pattern, char c)Strip trailing charactersstatic java.lang.StringstripTrailingWhitespace(java.lang.String pattern)Strip trailing whitespace characters
-
-
-
Field Detail
-
POSIX_CHAR_CLASSES
static final java.util.List<java.lang.String> POSIX_CHAR_CLASSES
-
DL
private static final java.lang.String DL
- See Also:
- Constant Field Values
-
JAVA_CHAR_CLASSES
static final java.util.List<java.lang.String> JAVA_CHAR_CLASSES
-
UNSUPPORTED
static final java.util.regex.Pattern UNSUPPORTED
-
-
Method Detail
-
getPathSeparator
static char getPathSeparator(java.lang.Character pathSeparator)
-
stripTrailing
public static java.lang.String stripTrailing(java.lang.String pattern, char c)Strip trailing characters- Parameters:
pattern- non nullc- character to remove- Returns:
- new string with all trailing characters removed
-
stripTrailingWhitespace
public static java.lang.String stripTrailingWhitespace(java.lang.String pattern)
Strip trailing whitespace characters- Parameters:
pattern- non null- Returns:
- new string with all trailing whitespace removed
-
isDirectoryPattern
public static boolean isDirectoryPattern(java.lang.String pattern)
Check if pattern is a directory pattern ending with a path separator- Parameters:
pattern- non null- Returns:
trueif the last character, which is not whitespace, is a path separator
-
count
static int count(java.lang.String s, char c, boolean ignoreFirstLast)
-
split
public static java.util.List<java.lang.String> split(java.lang.String pattern, char slash)Splits given string to substrings by given separator- Parameters:
pattern- non nullslash- separator char- Returns:
- list of substrings
-
isWildCard
static boolean isWildCard(java.lang.String pattern)
-
isComplexWildcard
private static boolean isComplexWildcard(java.lang.String pattern)
-
escapedByBackslash
private static boolean escapedByBackslash(char nextChar)
-
checkWildCards
static Strings.PatternState checkWildCards(java.lang.String pattern)
-
convertGlob
static java.util.regex.Pattern convertGlob(java.lang.String pattern) throws InvalidPatternExceptionConversion 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- non null pattern- Returns:
- Java regex pattern corresponding to given glob pattern
- Throws:
InvalidPatternException
-
lookBehind
private static char lookBehind(java.lang.StringBuilder buffer)
- Parameters:
buffer-- Returns:
- zero of the buffer is empty, otherwise the last character from buffer
-
lookAhead
private static char lookAhead(java.lang.String pattern, int i)- Parameters:
pattern-i- current pointer in the pattern- Returns:
- zero of the index is out of range, otherwise the next character from given position
-
setNext
private static void setNext(char[] buffer, char c)
-
reset
private static void reset(char[] buffer)
-
checkPosixCharClass
private static java.lang.String checkPosixCharClass(char[] buffer)
-
deleteBackslash
static java.lang.String deleteBackslash(java.lang.String s)
-
-