|
|||||||||
| Home >> All >> org >> gjt >> sp >> [ jedit overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.gjt.sp.jedit
Class MiscUtilities

java.lang.Objectorg.gjt.sp.jedit.MiscUtilities
- public class MiscUtilities
- extends java.lang.Object
Path name manipulation, string manipulation, and more.
The most frequently used members of this class are:
Some path name methods:
String comparison:
A compareStrings(String,String,boolean) 55 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());
- Version:
- $Id: MiscUtilities.java,v 1.67 2003/11/18 20:51:57 spestov Exp $
| Nested Class Summary | |
static interface |
MiscUtilities.Compare
An interface for comparing objects. |
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 java.text.DecimalFormat |
KB_FORMAT
|
static java.text.DecimalFormat |
MB_FORMAT
|
static java.lang.String |
UTF_8_Y
This encoding is not supported by Java, yet it is useful. |
| Constructor Summary | |
private |
MiscUtilities()
|
| Method Summary | |
static java.lang.String |
buildToVersion(java.lang.String build)
Converts an internal version number (build) into a `human-readable' form. |
static java.lang.String |
canonPath(java.lang.String path)
Returns the canonical form of the specified path name. |
static java.lang.String |
charsToEntities(java.lang.String str)
Converts <, >, & in the string to their HTML entity equivalents. |
static java.lang.String |
charsToEscapes(java.lang.String str)
Escapes newlines, tabs, backslashes, and quotes in the specified string. |
static java.lang.String |
charsToEscapes(java.lang.String str,
java.lang.String toEscape)
Escapes the specified characters in the specified string. |
static java.lang.String |
classToFile(java.lang.String name)
Converts a class name to a file name. |
private static boolean |
compareChars(char ch1,
char ch2,
boolean ignoreCase)
should this be public? |
static int |
compareStrings(java.lang.String str1,
java.lang.String str2,
boolean ignoreCase)
Compares two strings. |
static int |
compareVersions(java.lang.String v1,
java.lang.String v2)
Deprecated. Call compareStrings() instead |
static java.lang.String |
concatPath(java.lang.String parent,
java.lang.String path)
Like constructPath(java.lang.String, java.lang.String) 55 , except path will be
appended to parent even if it is absolute. |
static java.lang.String |
constructPath(java.lang.String parent,
java.lang.String path)
Constructs an absolute path name from a directory and another path name. |
static java.lang.String |
constructPath(java.lang.String parent,
java.lang.String path1,
java.lang.String path2)
Constructs an absolute path name from three path components. |
static java.lang.String |
createWhiteSpace(int len,
int tabSize)
Creates a string of white space with the specified length. |
static java.lang.String |
createWhiteSpace(int len,
int tabSize,
int start)
Creates a string of white space with the specified length. |
static java.lang.String |
escapesToChars(java.lang.String str)
Converts "\n" and "\t" escapes in the specified string to newlines and tabs. |
static java.lang.String |
fileToClass(java.lang.String name)
Converts a file name to a class name. |
static java.lang.String |
formatFileSize(long length)
Formats the given file size into a nice string (123 bytes, 10.6 KB, 1.2 MB). |
static java.lang.String[] |
getEncodings()
Returns a list of supported character encodings. |
static java.lang.String |
getFileExtension(java.lang.String name)
Returns the extension of the specified filename, or an empty string if there is none. |
static java.lang.String |
getFileName(java.lang.String path)
Returns the last component of the specified path. |
static java.lang.String |
getFileNameNoExtension(java.lang.String path)
Returns the last component of the specified path name without the trailing extension (if there is one). |
static java.lang.String |
getFileParent(java.lang.String path)
Deprecated. Call getParentOfPath() instead |
static java.lang.String |
getFileProtocol(java.lang.String url)
Deprecated. Call getProtocolOfURL() instead |
static int |
getLeadingWhiteSpace(java.lang.String str)
Returns the number of leading white space characters in the specified string. |
static int |
getLeadingWhiteSpaceWidth(java.lang.String str,
int tabSize)
Returns the width of the leading white space in the specified string. |
static java.lang.String |
getLongestPrefix(java.util.List str,
boolean ignoreCase)
Returns the longest common prefix in the given set of strings. |
static java.lang.String |
getLongestPrefix(java.lang.Object[] str,
boolean ignoreCase)
Returns the longest common prefix in the given set of strings. |
static java.lang.String |
getLongestPrefix(java.lang.String[] str,
boolean ignoreCase)
Returns the longest common prefix in the given set of strings. |
static int |
getOffsetOfVirtualColumn(javax.swing.text.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 java.lang.String |
getParentOfPath(java.lang.String path)
Returns the parent of the specified path. |
static java.lang.String |
getProtocolOfURL(java.lang.String url)
Returns the protocol specified by a URL. |
static int |
getTrailingWhiteSpace(java.lang.String str)
Returns the number of trailing whitespace characters in the specified string. |
static int |
getVirtualWidth(javax.swing.text.Segment seg,
int tabSize)
Returns the virtual column number (taking tabs into account) of the specified offset in the segment. |
static java.lang.String |
globToRE(java.lang.String glob)
Converts a Unix-style glob to a regular expression. |
static boolean |
isAbsolutePath(java.lang.String path)
Returns if the specified path name is an absolute path or URL. |
static boolean |
isSupportedEncoding(java.lang.String encoding)
Returns if the given character encoding is supported. |
static boolean |
isToolsJarAvailable()
If on JDK 1.2 or higher, make sure that tools.jar is available. |
static boolean |
isURL(java.lang.String str)
Checks if the specified string is a URL. |
static boolean |
objectsEqual(java.lang.Object o1,
java.lang.Object o2)
Returns if two strings are equal. |
static int |
parsePermissions(java.lang.String s)
Parse a Unix-style permission string (rwxrwxrwx). |
static void |
quicksort(java.util.List list,
java.util.Comparator compare)
Sorts the specified list. |
static void |
quicksort(java.lang.Object[] obj,
java.util.Comparator compare)
Sorts the specified array. |
static void |
quicksort(java.lang.Object[] obj,
MiscUtilities.Compare compare)
Sorts the specified array. |
static void |
quicksort(java.util.Vector vector,
java.util.Comparator compare)
Sorts the specified vector. |
static void |
quicksort(java.util.Vector vector,
MiscUtilities.Compare compare)
Sorts the specified vector. |
static java.lang.String |
resolveSymlinks(java.lang.String path)
Resolves any symbolic links in the path name specified using File.getCanonicalPath(). |
static void |
saveBackup(java.io.File file,
int backups,
java.lang.String backupPrefix,
java.lang.String backupSuffix,
java.lang.String backupDirectory)
Saves a backup (optionally numbered) of a file. |
static void |
saveBackup(java.io.File file,
int backups,
java.lang.String backupPrefix,
java.lang.String backupSuffix,
java.lang.String backupDirectory,
int backupTimeDistance)
Saves a backup (optionally numbered) of a file. |
static boolean |
stringsEqual(java.lang.String s1,
java.lang.String s2)
Deprecated. Call objectsEqual() instead. |
static java.lang.String |
throwableToString(java.lang.Throwable t)
Returns a string containing the stack trace of the given throwable. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
UTF_8_Y
public static final java.lang.String UTF_8_Y
- This encoding is not supported by Java, yet it is useful.
A UTF-8 file that begins with 0xEFBBBF.
- See Also:
- Constant Field Values
KB_FORMAT
public static final java.text.DecimalFormat KB_FORMAT
MB_FORMAT
public static final java.text.DecimalFormat MB_FORMAT
| Constructor Detail |
MiscUtilities
private MiscUtilities()
| Method Detail |
canonPath
public static java.lang.String canonPath(java.lang.String path)
- Returns the canonical form of the specified path name. Currently
only expands a leading
~. For local path names only.- Since:
- jEdit 4.0pre2
resolveSymlinks
public static java.lang.String resolveSymlinks(java.lang.String path)
- Resolves any symbolic links in the path name specified
using
File.getCanonicalPath(). For local path names only.- Since:
- jEdit 4.2pre1
isAbsolutePath
public static boolean isAbsolutePath(java.lang.String path)
- Returns if the specified path name is an absolute path or URL.
- Since:
- jEdit 4.1pre11
constructPath
public static java.lang.String constructPath(java.lang.String parent, java.lang.String path)
- Constructs an absolute path name from a directory and another
path name. This method is VFS-aware.
constructPath
public static java.lang.String constructPath(java.lang.String parent, java.lang.String path1, java.lang.String path2)
- Constructs an absolute path name from three path components.
This method is VFS-aware.
concatPath
public static java.lang.String concatPath(java.lang.String parent, java.lang.String path)
- Like
constructPath(java.lang.String, java.lang.String)55 , exceptpathwill be appended toparenteven if it is absolute. For local path names only..
getFileExtension
public static java.lang.String getFileExtension(java.lang.String name)
- Returns the extension of the specified filename, or an empty
string if there is none.
getFileName
public static java.lang.String getFileName(java.lang.String path)
- Returns the last component of the specified path.
This method is VFS-aware.
getFileNameNoExtension
public static java.lang.String getFileNameNoExtension(java.lang.String path)
- Returns the last component of the specified path name without the
trailing extension (if there is one).
- Since:
- jEdit 4.0pre8
getFileParent
public static java.lang.String getFileParent(java.lang.String path)
- Deprecated. Call getParentOfPath() instead
getParentOfPath
public static java.lang.String getParentOfPath(java.lang.String path)
- Returns the parent of the specified path. This method is VFS-aware.
- Since:
- jEdit 2.6pre5
getFileProtocol
public static java.lang.String getFileProtocol(java.lang.String url)
- Deprecated. Call getProtocolOfURL() instead
getProtocolOfURL
public static java.lang.String getProtocolOfURL(java.lang.String url)
- Returns the protocol specified by a URL.
- Since:
- jEdit 2.6pre5
isURL
public static boolean isURL(java.lang.String str)
- Checks if the specified string is a URL.
saveBackup
public static void saveBackup(java.io.File file, int backups, java.lang.String backupPrefix, java.lang.String backupSuffix, java.lang.String backupDirectory)
- Saves a backup (optionally numbered) of a file.
- Since:
- jEdit 4.0pre1
saveBackup
public static void saveBackup(java.io.File file, int backups, java.lang.String backupPrefix, java.lang.String backupSuffix, java.lang.String backupDirectory, int backupTimeDistance)
- Saves a backup (optionally numbered) of a file.
- Since:
- jEdit 4.2pre5
fileToClass
public static java.lang.String fileToClass(java.lang.String name)
- Converts a file name to a class name. All slash characters are
replaced with periods and the trailing '.class' is removed.
classToFile
public static java.lang.String classToFile(java.lang.String name)
- Converts a class name to a file name. All periods are replaced
with slashes and the '.class' extension is added.
getLeadingWhiteSpace
public static int getLeadingWhiteSpace(java.lang.String str)
- Returns the number of leading white space characters in the
specified string.
getTrailingWhiteSpace
public static int getTrailingWhiteSpace(java.lang.String str)
- Returns the number of trailing whitespace characters in the
specified string.
- Since:
- jEdit 2.5pre5
getLeadingWhiteSpaceWidth
public static int getLeadingWhiteSpaceWidth(java.lang.String str, int tabSize)
- Returns the width of the leading white space in the specified
string.
getVirtualWidth
public static int getVirtualWidth(javax.swing.text.Segment seg, int tabSize)
- Returns the virtual column number (taking tabs into account) of the
specified offset in the segment.
- Since:
- jEdit 4.1pre1
getOffsetOfVirtualColumn
public static int getOffsetOfVirtualColumn(javax.swing.text.Segment seg, int tabSize, int column, int[] totalVirtualWidth)
- Returns the array offset of a virtual column number (taking tabs
into account) in the segment.
- Since:
- jEdit 4.1pre1
createWhiteSpace
public static java.lang.String createWhiteSpace(int len, int tabSize)
- Creates a string of white space with the specified length.
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()));
createWhiteSpace
public static java.lang.String createWhiteSpace(int len, int tabSize, int start)
- Creates a string of white space with the specified length.
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()));- Since:
- jEdit 4.2pre1
globToRE
public static java.lang.String globToRE(java.lang.String glob)
- Converts a Unix-style glob to a regular expression.
? becomes ., * becomes .*, {aa,bb} becomes (aa|bb).
escapesToChars
public static java.lang.String escapesToChars(java.lang.String str)
- Converts "\n" and "\t" escapes in the specified string to
newlines and tabs.
- Since:
- jEdit 2.3pre1
charsToEscapes
public static java.lang.String charsToEscapes(java.lang.String str)
- Escapes newlines, tabs, backslashes, and quotes in the specified
string.
- Since:
- jEdit 2.3pre1
charsToEscapes
public static java.lang.String charsToEscapes(java.lang.String str, java.lang.String toEscape)
- Escapes the specified characters in the specified string.
- Since:
- jEdit 4.1pre3
compareVersions
public static int compareVersions(java.lang.String v1, java.lang.String v2)
- Deprecated. Call
compareStrings()instead
compareStrings
public static int compareStrings(java.lang.String str1, java.lang.String str2, boolean ignoreCase)
- Compares two strings.
Unlike
String.compareTo() , this method correctly recognizes and handles embedded numbers. For example, it places "My file 2" before "My file 10".- Since:
- jEdit 4.0pre1
stringsEqual
public static boolean stringsEqual(java.lang.String s1, java.lang.String s2)
- Deprecated. Call
objectsEqual()instead.
objectsEqual
public static boolean objectsEqual(java.lang.Object o1, java.lang.Object o2)
- Returns if two strings are equal. This correctly handles null pointers,
as opposed to calling
o1.equals(o2).- Since:
- jEdit 4.2pre1
charsToEntities
public static java.lang.String charsToEntities(java.lang.String str)
- Converts <, >, & in the string to their HTML entity
equivalents.
- Since:
- jEdit 4.2pre1
formatFileSize
public static java.lang.String formatFileSize(long length)
- Formats the given file size into a nice string (123 bytes, 10.6 KB,
1.2 MB).
- Since:
- jEdit 4.2pre1
getLongestPrefix
public static java.lang.String getLongestPrefix(java.util.List str, boolean ignoreCase)
- Returns the longest common prefix in the given set of strings.
- Since:
- jEdit 4.2pre2
getLongestPrefix
public static java.lang.String getLongestPrefix(java.lang.String[] str, boolean ignoreCase)
- Returns the longest common prefix in the given set of strings.
- Since:
- jEdit 4.2pre2
getLongestPrefix
public static java.lang.String getLongestPrefix(java.lang.Object[] str, boolean ignoreCase)
- Returns the longest common prefix in the given set of strings.
- Since:
- jEdit 4.2pre6
quicksort
public static void quicksort(java.lang.Object[] obj, java.util.Comparator compare)
- Sorts the specified array. Equivalent to calling
Arrays.sort().- Since:
- jEdit 4.0pre4
quicksort
public static void quicksort(java.util.Vector vector, java.util.Comparator compare)
- Sorts the specified vector.
- Since:
- jEdit 4.0pre4
quicksort
public static void quicksort(java.util.List list, java.util.Comparator compare)
- Sorts the specified list.
- Since:
- jEdit 4.0pre4
quicksort
public static void quicksort(java.lang.Object[] obj, MiscUtilities.Compare compare)
- Sorts the specified array. Equivalent to calling
Arrays.sort().
quicksort
public static void quicksort(java.util.Vector vector, MiscUtilities.Compare compare)
- Sorts the specified vector.
buildToVersion
public static java.lang.String buildToVersion(java.lang.String build)
- Converts an internal version number (build) into a
`human-readable' form.
isToolsJarAvailable
public static boolean isToolsJarAvailable()
- If on JDK 1.2 or higher, make sure that tools.jar is available.
This method should be called by plugins requiring the classes
in this library.
tools.jar is searched for in the following places:
- the classpath that was used when jEdit was started,
- jEdit's jars folder in the user's home,
- jEdit's system jars folder,
- java.home/lib/. In this case, tools.jar is added to jEdit's list of known jars using jEdit.addPluginJAR(), so that it gets loaded through JARClassLoader.
On older JDK's this method does not perform any checks, and returns
true(even though there is no tools.jar).- Since:
- jEdit 3.2.2
parsePermissions
public static int parsePermissions(java.lang.String s)
- Parse a Unix-style permission string (rwxrwxrwx).
- Since:
- jEdit 4.1pre8
getEncodings
public static java.lang.String[] getEncodings()
- Returns a list of supported character encodings.
On Java 1.3, returns a fixed list.
On Java 1.4, uses reflection to call an NIO API.
- Since:
- jEdit 4.2pre5
isSupportedEncoding
public static boolean isSupportedEncoding(java.lang.String encoding)
- Returns if the given character encoding is supported.
Uses reflection to call a Java 1.4 API on Java 1.4, and always
returns true on Java 1.3.
- Since:
- jEdit 4.2pre7
throwableToString
public static java.lang.String throwableToString(java.lang.Throwable t)
- Returns a string containing the stack trace of the given throwable.
- Since:
- jEdit 4.2pre6
compareChars
private static boolean compareChars(char ch1,
char ch2,
boolean ignoreCase)
- should this be public?
|
|||||||||
| Home >> All >> org >> gjt >> sp >> [ jedit overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.gjt.sp.jedit.MiscUtilities