|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sourceforge.jsxe.util.MiscUtilities
Path name manipulation, string manipulation, and more.
String comparison:
A compareStrings(String,String,boolean) method that unlike
This class also defines several inner classes for use with the sorting features of the Java collections API:
For example, you might call:
Arrays.sort(myListOfStrings,
new MiscUtilities.StringICaseCompare());
| Nested Class Summary | |
static class |
MiscUtilities.MenuItemCompare
Compares menu item labels. |
static class |
MiscUtilities.StringCompare
Compares strings. |
static class |
MiscUtilities.StringICaseCompare
Compares strings ignoring case. |
| Field Summary | |
static String |
UTF_8_Y
This encoding is not supported by Java, yet it is useful. |
| Method Summary | |
static String |
buildToVersion(String build)
Converts an internal version number (build) into a `human-readable' form. |
static String |
canonPath(String path)
Returns the canonical form of the specified path name. |
static String |
charactersToEntities(String s,
Map hash)
Converts characters to entities. |
static String |
charsToEscapes(String str)
Escapes newlines, tabs, backslashes, and quotes in the specified string. |
static String |
charsToEscapes(String str,
String toEscape)
Escapes the specified characters in the specified string. |
static String |
classToFile(String name)
Converts a class name to a file name. |
static int |
compareStrings(String str1,
String str2,
boolean ignoreCase)
Compares two strings. |
static String |
concatPath(String parent,
String path)
Like #constructPath, except path will be
appended to parent even if it is absolute. |
static String |
createWhiteSpace(int len,
int tabSize)
Creates a string of white space with the specified length. |
static String |
entitiesToCharacters(String s,
Map hash)
Converts entities to characters |
static boolean |
equals(Object a,
Object b)
Determines if object a equals object b. |
static String |
escapesToChars(String str)
Converts "\n" and "\t" escapes in the specified string to newlines and tabs. |
static String |
fileToClass(String name)
Converts a file name to a class name. |
static String |
getFileExtension(String name)
Returns the extension of the specified filename, or an empty string if there is none. |
static String |
getFileName(String path)
Returns the last component of the specified path. |
static int |
getLeadingWhiteSpace(String str)
Returns the number of leading white space characters in the specified string. |
static int |
getLeadingWhiteSpaceWidth(String str,
int tabSize)
Returns the width of the leading white space in the specified string. |
static String |
getLocalNameFromQualifiedName(String qualifiedName)
Extracts the XML local name from a qualified name |
static String |
getNSPrefixFromQualifiedName(String qualifiedName)
Extracts an XML namespace prefix from a qualified name. |
static int |
getOffsetOfVirtualColumn(Segment seg,
int tabSize,
int column,
int[] totalVirtualWidth)
Returns the array offset of a virtual column number (taking tabs into account) in the segment. |
static String |
getParentOfPath(String path)
Returns the parent of the specified path. |
static String |
getProtocolOfURL(String url)
Returns the protocol specified by a URL. |
static String[] |
getSupportedEncodings()
Returns a list of supported character encodings. |
static int |
getTrailingWhiteSpace(String str)
Returns the number of trailing whitespace characters in the specified string. |
static int |
getVirtualWidth(Segment seg,
int tabSize)
Returns the virtual column number (taking tabs into account) of the specified offset in the segment. |
static String |
globToRE(String glob)
Converts a Unix-style glob to a regular expression. |
static boolean |
isAbsolutePath(String path)
Returns if the specified path name is an absolute path or URL. |
static boolean |
isSupportedEncoding(String encoding)
Returns if the given character encoding is supported. |
static boolean |
isTrue(String str)
Returns true if the value of the string is true |
static boolean |
isURL(String str)
Checks if the specified string is a URL. |
static Properties |
mergeProperties(Properties props1,
Properties props2)
Merges two Properties sets together into a new Properties object giving precidence to the properties in the first argument. |
static int |
parsePermissions(String s)
Parse a Unix-style permission string (rwxrwxrwx). |
static void |
quicksort(List list,
Comparator compare)
Sorts the specified list. |
static void |
quicksort(Object[] obj,
Comparator compare)
Sorts the specified array. |
static void |
quicksort(Vector vector,
Comparator compare)
Sorts the specified vector. |
static String |
resolveSymlinks(String path)
|
static void |
saveBackup(File file,
int backups,
String backupPrefix,
String backupSuffix,
String backupDirectory)
Saves a backup (optionally numbered) of a file. |
static boolean |
stringsEqual(String s1,
String s2)
Returns if two strings are equal. |
static String |
uriToFile(String uri)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String UTF_8_Y
| Method Detail |
public static String canonPath(String path)
~. For local path names
only.
path - The path namepublic static boolean isAbsolutePath(String path)
public static String concatPath(String parent,
String path)
#constructPath, except path will be
appended to parent even if it is absolute.
path - parent - public static String getFileExtension(String name)
name - The file namepublic static String getFileName(String path)
path - The path namepublic static String getParentOfPath(String path)
path - The path namepublic static String getProtocolOfURL(String url)
url - The URLpublic static boolean isURL(String str)
str - The string to check
public static void saveBackup(File file,
int backups,
String backupPrefix,
String backupSuffix,
String backupDirectory)
file - A local filebackups - The number of backups. Must be >= 1. If > 1, backup
files will be numbered.backupPrefix - The backup file name prefixbackupSuffix - The backup file name suffixbackupDirectory - The directory where to save backups; if null,
they will be saved in the same directory as the file itself.public static String fileToClass(String name)
name - The file namepublic static String classToFile(String name)
name - The class namepublic static String resolveSymlinks(String path)
public static int getLeadingWhiteSpace(String str)
str - The stringpublic static int getTrailingWhiteSpace(String str)
str - The string
public static int getLeadingWhiteSpaceWidth(String str,
int tabSize)
str - The stringtabSize - The tab size
public static int getVirtualWidth(Segment seg,
int tabSize)
seg - The segmenttabSize - The tab size
public static int getOffsetOfVirtualColumn(Segment seg,
int tabSize,
int column,
int[] totalVirtualWidth)
seg - The segmenttabSize - The tab sizecolumn - The virtual column numbertotalVirtualWidth - If this array is non-null, the total
virtual width will be stored in its first location if this method
returns -1.
public static String createWhiteSpace(int len,
int tabSize)
To get a whitespace string tuned to the current buffer's settings, call this method as follows:
myWhitespace = MiscUtilities.createWhiteSpace(myLength,
(buffer.getBooleanProperty("noTabs") ? 0
: buffer.getTabSize()));
len - The lengthtabSize - The tab size, or 0 if tabs are not to be usedpublic static String globToRE(String glob)
? becomes ., * becomes .*, {aa,bb} becomes (aa|bb).
glob - The glob patternpublic static String escapesToChars(String str)
str - The stringpublic static String charsToEscapes(String str)
str - The string
public static String charsToEscapes(String str,
String toEscape)
str - The string
public static int compareStrings(String str1,
String str2,
boolean ignoreCase)
Unlike
str1 - The first stringstr2 - The second stringignoreCase - If true, case will be ignored
public static boolean stringsEqual(String s1,
String s2)
s1.equals(s2).
public static void quicksort(Object[] obj,
Comparator compare)
Arrays.sort().
obj - The arraycompare - Compares the objects
public static void quicksort(Vector vector,
Comparator compare)
vector - The vectorcompare - Compares the objects
public static void quicksort(List list,
Comparator compare)
list - The listcompare - Compares the objectspublic static String buildToVersion(String build)
build - The buildpublic static int parsePermissions(String s)
public static String getLocalNameFromQualifiedName(String qualifiedName)
qualifiedName - the qualified name
public static String getNSPrefixFromQualifiedName(String qualifiedName)
qualifiedName - the qualified name
public static String charactersToEntities(String s,
Map hash)
s - The string in which to convert characters to entitieshash - a Map containing character to entity name mappings
public static String entitiesToCharacters(String s,
Map hash)
s - The string in which to convert characters to entitieshash - a Map containing entity name to character mappingspublic static String uriToFile(String uri)
public static boolean isSupportedEncoding(String encoding)
public static String[] getSupportedEncodings()
public static Properties mergeProperties(Properties props1,
Properties props2)
props1 - the first Properties object whose properties are given
precidence.props2 - the second Properties object whose properties are merged
with that of the first.public static boolean isTrue(String str)
str - the boolean string
public static boolean equals(Object a,
Object b)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||