public final class Utils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
baseClassname(String type) |
static Pattern |
createPattern(String pattern)
Helper method to create a regular expression.
|
static boolean |
fileExtensionMatches(File file,
String[] fileExtensions)
Returns whether the file extension matches what we are meant to
process.
|
static boolean |
isPatternValid(String pattern)
Validates whether passed string is a valid pattern or not.
|
static int |
lengthExpandedTabs(String string,
int toIdx,
int tabWidth)
Returns the length of a String prefix with tabs expanded.
|
static int |
lengthMinusTrailingWhitespace(String line)
Returns the length of a string ignoring all trailing whitespace.
|
static String |
relativizeAndNormalizePath(String baseDirectory,
String path)
Constructs a normalized relative path between base directory and a given path.
|
static boolean |
whitespaceBefore(int index,
String line)
Returns whether the specified string contains only whitespace up to the
specified index.
|
public static boolean fileExtensionMatches(File file, String[] fileExtensions)
file
- the file to be checked.fileExtensions
- files extensions, empty property in config makes it matches to all.public static boolean whitespaceBefore(int index, String line)
index
- index to check up toline
- the line to checkpublic static int lengthMinusTrailingWhitespace(String line)
line
- the string to processpublic static int lengthExpandedTabs(String string, int toIdx, int tabWidth)
string
- the input StringtoIdx
- index in string (exclusive) where the calculation stopstabWidth
- the distance between tab stop position.public static boolean isPatternValid(String pattern)
pattern
- string to validatepublic static Pattern createPattern(String pattern) throws org.apache.commons.beanutils.ConversionException
pattern
- the pattern to matchorg.apache.commons.beanutils.ConversionException
- if unable to create Pattern object.public static String baseClassname(String type)
type
- the fully qualified name. Cannot be nullpublic static String relativizeAndNormalizePath(String baseDirectory, String path)
baseDirectory
- the base path to which given path is relativizedpath
- the path to relativize against base directoryCopyright © 2001–2015. All rights reserved.