|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.puppycrawl.tools.checkstyle.api.Utils
public final class Utils
Contains utility methods.
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
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 check
public static int lengthMinusTrailingWhitespace(String aLine)
aLine
- the string to process
public 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 pattern
PatternSyntaxException
- 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 flags
PatternSyntaxException
- an invalid pattern was suppliedpublic static String[] getLines(String aFileName) throws IOException
aFileName
- the name of the file to load
IOException
- error occurredpublic static String[] getLines(String aFileName, String aCharsetName) throws IOException
aFileName
- the name of the file to loadaCharsetName
- the name of a supported charset
IOException
- error occurredpublic static Pattern createPattern(String aPattern) throws org.apache.commons.beanutils.ConversionException
aPattern
- the pattern to match
org.apache.commons.beanutils.ConversionException
- if unable to create Pattern object.public static String baseClassname(String aType)
aType
- the fully qualified name. Cannot be null
public static String getStrippedFileName(String aBasedir, String aFileName)
aBasedir
- the prefix to strip off the original filenameaFileName
- the original filename
public static File[] filterFilesByExtension(File[] aFiles, String[] aFileExtensions)
aFiles
- a set of filesaFileExtensions
- a set of file extension, like ".txt" or ".java"
|
Back to the Checkstyle Home Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |