public final class Utils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
baseClassname(String aType) |
static Pattern |
createPattern(String aPattern)
Helper method to create a regular expression.
|
static File[] |
filterFilesByExtension(File[] aFiles,
String[] aFileExtensions)
Filter a set of files by their extension.
|
static org.apache.commons.logging.Log |
getExceptionLogger()
Accessor for shared instance of logger which should be
used to log all exceptions occured during
FileSetCheck
work (debug() should be used). |
static String[] |
getLines(String aFileName)
Loads the contents of a file in a String array.
|
static String[] |
getLines(String aFileName,
String aCharsetName)
Loads the contents of a file in a String array using
the named charset.
|
static Pattern |
getPattern(String aPattern)
This is a factory method to return an Pattern object for the specified
regular expression.
|
static Pattern |
getPattern(String aPattern,
int aCompileFlags)
This is a factory method to return an Pattern object for the specified
regular expression and compile flags.
|
static String |
getStrippedFileName(String aBasedir,
String aFileName)
Create a stripped down version of a filename.
|
static int |
lengthExpandedTabs(String aString,
int aToIdx,
int aTabWidth)
Returns the length of a String prefix with tabs expanded.
|
static int |
lengthMinusTrailingWhitespace(String aLine)
Returns the length of a string ignoring all trailing whitespace.
|
static boolean |
whitespaceBefore(int aIndex,
String aLine)
Returns whether the specified string contains only whitespace up to the
specified index.
|
public static org.apache.commons.logging.Log getExceptionLogger()
FileSetCheck
work (debug()
should be used).public static boolean whitespaceBefore(int aIndex, String aLine)
aIndex
- index to check up toaLine
- the line to checkpublic static int lengthMinusTrailingWhitespace(String aLine)
aLine
- the string to processpublic static int lengthExpandedTabs(String aString, int aToIdx, int aTabWidth)
aString
- the input StringaToIdx
- index in aString (exclusive) where the calculation stopsaTabWidth
- the distance betweeen tab stop position.public static Pattern getPattern(String aPattern) throws PatternSyntaxException
getPattern(String, int)
with the
compile flags defaults to 0.aPattern
- the regular expression patternPatternSyntaxException
- an invalid pattern was suppliedpublic static Pattern getPattern(String aPattern, int aCompileFlags) throws PatternSyntaxException
This method is not MT safe, but neither are the returned Pattern objects.
aPattern
- the regular expression patternaCompileFlags
- the compilation flagsPatternSyntaxException
- an invalid pattern was suppliedpublic static String[] getLines(String aFileName) throws IOException
aFileName
- the name of the file to loadIOException
- error occurredpublic static String[] getLines(String aFileName, String aCharsetName) throws IOException
aFileName
- the name of the file to loadaCharsetName
- the name of a supported charsetIOException
- error occurredpublic static Pattern createPattern(String aPattern) throws org.apache.commons.beanutils.ConversionException
aPattern
- the pattern to matchorg.apache.commons.beanutils.ConversionException
- if unable to create Pattern object.public static String baseClassname(String aType)
aType
- the fully qualified name. Cannot be nullpublic static String getStrippedFileName(String aBasedir, String aFileName)
aBasedir
- the prefix to strip off the original filenameaFileName
- the original filenamepublic static File[] filterFilesByExtension(File[] aFiles, String[] aFileExtensions)
aFiles
- a set of filesaFileExtensions
- a set of file extension, like ".txt" or ".java"