org.gjt.sp.jedit
Class MiscUtilities

java.lang.Object
  extended by org.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) method that unlike String.compareTo(), correctly recognizes and handles embedded numbers.

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 interface MiscUtilities.Compare
          Deprecated.  
static class MiscUtilities.MenuItemCompare
          Deprecated. Replaced with MenuItemTextComparator
static class MiscUtilities.StringCompare
          Deprecated. use StandardUtilities.StringCompare
static class MiscUtilities.StringICaseCompare
          Deprecated. use StandardUtilities.StringCompare
 
Field Summary
static java.text.DecimalFormat KB_FORMAT
           
static java.text.DecimalFormat MB_FORMAT
           
static java.lang.String UTF_8_Y
          Deprecated. Extended encodings are now supported as services. This value is no longer used.
 
Method Summary
static java.lang.String abbreviate(java.lang.String path)
          returns an abbreviated path, replacing values with variables, if a prefix exists.
static java.io.Reader autodetect(java.io.InputStream in, Buffer buffer)
          Tries to detect if the stream is gzipped, and if it has an encoding specified with an XML PI.
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)
           
static java.lang.String charsToEntities(java.lang.String str)
          Deprecated. Use XMLUtilities.charsToEntities(String, boolean).
static java.lang.String charsToEscapes(java.lang.String str)
          Deprecated. use StandardUtilities.charsToEscapes(String)
static java.lang.String charsToEscapes(java.lang.String str, java.lang.String toEscape)
          Deprecated. use StandardUtilities.charsToEscapes(String)
static java.lang.String classToFile(java.lang.String name)
          Converts a class name to a file name.
static void closeQuietly(java.io.InputStream in)
          Deprecated. use IOUtilities.closeQuietly(java.io.InputStream)
static void closeQuietly(java.io.OutputStream out)
          Deprecated. use IOUtilities.closeQuietly(java.io.OutputStream)
static int compareStrings(java.lang.String str1, java.lang.String str2, boolean ignoreCase)
          Deprecated. use StandardUtilities.compareStrings(String, String, boolean)
static int compareVersions(java.lang.String v1, java.lang.String v2)
          Deprecated. Call StandardUtilities.compareStrings(String, String, boolean) instead
static java.lang.String concatPath(java.lang.String parent, java.lang.String path)
          Like constructPath(java.lang.String, java.lang.String), 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 boolean copyStream(int bufferSize, ProgressObserver progress, java.io.InputStream in, java.io.OutputStream out, boolean canStop)
          Deprecated. use IOUtilities.copyStream(int, org.gjt.sp.util.ProgressObserver, java.io.InputStream, java.io.OutputStream, boolean)
static boolean copyStream(ProgressObserver progress, java.io.InputStream in, java.io.OutputStream out, boolean canStop)
          Deprecated. use IOUtilities.copyStream(org.gjt.sp.util.ProgressObserver, java.io.InputStream, java.io.OutputStream, boolean)
static java.lang.String createWhiteSpace(int len, int tabSize)
          Deprecated. use StandardUtilities.createWhiteSpace(int, int)
static java.lang.String createWhiteSpace(int len, int tabSize, int start)
          Deprecated. use StandardUtilities.createWhiteSpace(int, int, int)
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 expandVariables(java.lang.String arg)
          Accepts a string from the user which may contain variables of various syntaxes.
static java.lang.String fileToClass(java.lang.String name)
          Converts a file name to a class name.
static org.xml.sax.InputSource findEntity(java.lang.String systemId, java.lang.String test, java.lang.Class where)
          Deprecated. Use XMLUtilities.findEntity(String,String,Class).
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()
          Deprecated. See #getEncodings(boolean)
static java.lang.String[] getEncodings(boolean getSelected)
          Returns a list of supported character encodings.
static java.lang.String getFileExtension(java.lang.String path)
          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 getFirstSeparatorIndex(java.lang.String path)
          Return the first index of either / or the OS-specific file separator.
static int getLastSeparatorIndex(java.lang.String path)
          Return the last index of either / or the OS-specific file separator.
static int getLeadingWhiteSpace(java.lang.String str)
          Deprecated. use StandardUtilities.getLeadingWhiteSpace(String)
static int getLeadingWhiteSpaceWidth(java.lang.String str, int tabSize)
          Deprecated. use StandardUtilities.getLeadingWhiteSpace(String)
static java.lang.String getLongestPrefix(java.util.List<java.lang.String> 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)
          Deprecated. use StandardUtilities.getVirtualWidth(javax.swing.text.Segment, int)
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)
          Deprecated. use StandardUtilities.getTrailingWhiteSpace(String)
static int getVirtualWidth(javax.swing.text.Segment seg, int tabSize)
          Deprecated. use StandardUtilities.getVirtualWidth(javax.swing.text.Segment, int)
static java.lang.String globToRE(java.lang.String glob)
          Deprecated. Use StandardUtilities.globToRE(String).
static boolean isAbsolutePath(java.lang.String path)
          Returns if the specified path name is an absolute path or URL.
static boolean isBackup(java.lang.String filename)
          Check if the filename is a backup file.
static boolean isBinary(java.io.InputStream in)
          Check if an InputStream is binary.
static boolean isBinary(java.io.Reader reader)
          Deprecated. Use isBinary(InputStream) instead.
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 moveFile(java.io.File source, java.io.File dest)
          Deprecated. use IOUtilities.moveFile(java.io.File, java.io.File)
static boolean objectsEqual(java.lang.Object o1, java.lang.Object o2)
          Deprecated. use StandardUtilities.objectsEqual(Object, Object)
static int parsePermissions(java.lang.String s)
          Parse a Unix-style permission string (rwxrwxrwx).
static boolean parseXML(java.io.InputStream in, org.xml.sax.helpers.DefaultHandler handler)
          Deprecated. Use XMLUtilities.parseXML(InputStream,DefaultHandler).
static boolean pathsEqual(java.lang.String p1, java.lang.String p2)
           
static void quicksort(java.util.List list, java.util.Comparator compare)
          Deprecated. Collections.sort()
static void quicksort(java.lang.Object[] obj, java.util.Comparator compare)
          Deprecated. use Arrays.sort()
static void quicksort(java.lang.Object[] obj, MiscUtilities.Compare compare)
          Deprecated. use Arrays.sort()
static void quicksort(java.util.Vector vector, java.util.Comparator compare)
          Deprecated. Collections.sort()
static void quicksort(java.util.Vector vector, MiscUtilities.Compare compare)
          Deprecated. Collections.sort()
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 StandardUtilities.objectsEqual(Object, Object) 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

@Deprecated
public static final java.lang.String UTF_8_Y
Deprecated. Extended encodings are now supported as services. This value is no longer used.
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
Method Detail

canonPath

public static java.lang.String canonPath(java.lang.String path)
Parameters:
path - The path name
Returns:
the canonical form of the specified path name. Currently only expands a leading ~. For local path names only.
Since:
jEdit 4.0pre2

expandVariables

public static java.lang.String expandVariables(java.lang.String arg)
Accepts a string from the user which may contain variables of various syntaxes. The goal is to support the following: $varname ${varname} And expand each of these by looking at the system environment variables for possible expansions.

Returns:
a string which is either the unchanged input string, or one with expanded variables.
Since:
4.3pre7

abbreviate

public static java.lang.String abbreviate(java.lang.String path)
returns an abbreviated path, replacing values with variables, if a prefix exists.

Since:
jEdit 4.3pre16

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.

Parameters:
parent - The directory
path - The path name

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.

Parameters:
parent - The parent directory
path1 - The first path
path2 - The second path

concatPath

public static java.lang.String concatPath(java.lang.String parent,
                                          java.lang.String path)
Like constructPath(java.lang.String, java.lang.String), except path will be appended to parent even if it is absolute. For local path names only..

Parameters:
parent - the parent path
path - the path to append to the parent

getFirstSeparatorIndex

public static int getFirstSeparatorIndex(java.lang.String path)
Return the first index of either / or the OS-specific file separator.

Parameters:
path - The path
Since:
jEdit 4.3pre3

getLastSeparatorIndex

public static int getLastSeparatorIndex(java.lang.String path)
Return the last index of either / or the OS-specific file separator.

Parameters:
path - The path
Since:
jEdit 4.3pre3

getFileExtension

public static java.lang.String getFileExtension(java.lang.String path)
Returns the extension of the specified filename, or an empty string if there is none.

Parameters:
path - The path

getFileName

public static java.lang.String getFileName(java.lang.String path)
Returns the last component of the specified path. This method is VFS-aware.

Parameters:
path - The path name

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).

Parameters:
path - The path name
Since:
jEdit 4.0pre8

getFileParent

@Deprecated
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.

Parameters:
path - The path name
Since:
jEdit 2.6pre5

getFileProtocol

@Deprecated
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.

Parameters:
url - The URL
Since:
jEdit 2.6pre5

isURL

public static boolean isURL(java.lang.String str)
Checks if the specified string is a URL.

Parameters:
str - The string to check
Returns:
True if the string is a URL, false otherwise

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.

Parameters:
file - A local file
backups - The number of backups. Must be >= 1. If > 1, backup files will be numbered.
backupPrefix - The backup file name prefix
backupSuffix - The backup file name suffix
backupDirectory - The directory where to save backups; if null, they will be saved in the same directory as the file itself.
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.

Parameters:
file - A local file
backups - The number of backups. Must be >= 1. If > 1, backup files will be numbered.
backupPrefix - The backup file name prefix
backupSuffix - The backup file name suffix
backupDirectory - The directory where to save backups; if null, they will be saved in the same directory as the file itself.
backupTimeDistance - The minimum time in minutes when a backup version 1 shall be moved into version 2; if 0, backups are always moved.
Since:
jEdit 4.2pre5

moveFile

@Deprecated
public static boolean moveFile(java.io.File source,
                                          java.io.File dest)
Deprecated. use IOUtilities.moveFile(java.io.File, java.io.File)

Moves the source file to the destination. If the destination cannot be created or is a read-only file, the method returns false. Otherwise, the contents of the source are copied to the destination, the source is deleted, and true is returned.

Parameters:
source - The source file to move.
dest - The destination where to move the file.
Returns:
true on success, false otherwise.
Since:
jEdit 4.3pre1

copyStream

@Deprecated
public static boolean copyStream(int bufferSize,
                                            ProgressObserver progress,
                                            java.io.InputStream in,
                                            java.io.OutputStream out,
                                            boolean canStop)
                          throws java.io.IOException
Deprecated. use IOUtilities.copyStream(int, org.gjt.sp.util.ProgressObserver, java.io.InputStream, java.io.OutputStream, boolean)

Copy an input stream to an output stream.

Parameters:
bufferSize - the size of the buffer
progress - the progress observer it could be null
in - the input stream
out - the output stream
canStop - if true, the copy can be stopped by interrupting the thread
Returns:
true if the copy was done, false if it was interrupted
Throws:
java.io.IOException - IOException If an I/O error occurs
Since:
jEdit 4.3pre3

copyStream

@Deprecated
public static boolean copyStream(ProgressObserver progress,
                                            java.io.InputStream in,
                                            java.io.OutputStream out,
                                            boolean canStop)
                          throws java.io.IOException
Deprecated. use IOUtilities.copyStream(org.gjt.sp.util.ProgressObserver, java.io.InputStream, java.io.OutputStream, boolean)

Copy an input stream to an output stream with a buffer of 4096 bytes.

Parameters:
progress - the progress observer it could be null
in - the input stream
out - the output stream
canStop - if true, the copy can be stopped by interrupting the thread
Returns:
true if the copy was done, false if it was interrupted
Throws:
java.io.IOException - IOException If an I/O error occurs
Since:
jEdit 4.3pre3

isBinary

@Deprecated
public static boolean isBinary(java.io.Reader reader)
                        throws java.io.IOException
Deprecated. Use isBinary(InputStream) instead.

Check if a Reader is binary.

Throws:
java.io.IOException

isBinary

public static boolean isBinary(java.io.InputStream in)
                        throws java.io.IOException
Check if an InputStream is binary. First this tries encoding auto detection. If an encoding is detected, the stream should be a text stream. Otherwise, this will check the first characters 100 (jEdit property vfs.binaryCheck.length) in the system default encoding. If more than 1 (jEdit property vfs.binaryCheck.count) NUL() was found, the stream is declared binary. This is not 100% because sometimes the autodetection could fail. This method will not close the stream. You have to do it yourself

Parameters:
in - the stream
Returns:
true if the stream was detected as binary
Throws:
java.io.IOException - IOException If an I/O error occurs
Since:
jEdit 4.3pre10

isBackup

public static boolean isBackup(java.lang.String filename)
Check if the filename is a backup file.

Parameters:
filename - the filename to check
Returns:
true if this is a backup file.
Since:
jEdit 4.3pre5

autodetect

public static java.io.Reader autodetect(java.io.InputStream in,
                                        Buffer buffer)
                                 throws java.io.IOException
Tries to detect if the stream is gzipped, and if it has an encoding specified with an XML PI.

Parameters:
in - the input stream reader that must be autodetected
buffer - a buffer. It can be null if you only want to autodetect the encoding of a file
Returns:
a Reader using the detected encoding
Throws:
java.io.IOException - io exception during read
Since:
jEdit 4.3pre5

closeQuietly

@Deprecated
public static void closeQuietly(java.io.InputStream in)
Deprecated. use IOUtilities.closeQuietly(java.io.InputStream)

Method that will close an InputStream ignoring it if it is null and ignoring exceptions.

Parameters:
in - the InputStream to close.
Since:
jEdit 4.3pre3

closeQuietly

@Deprecated
public static void closeQuietly(java.io.OutputStream out)
Deprecated. use IOUtilities.closeQuietly(java.io.OutputStream)

Method that will close an OutputStream ignoring it if it is null and ignoring exceptions.

Parameters:
out - the OutputStream to close.
Since:
jEdit 4.3pre3

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.

Parameters:
name - The file name

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.

Parameters:
name - The class name

pathsEqual

public static boolean pathsEqual(java.lang.String p1,
                                 java.lang.String p2)
Parameters:
p1 - A path name
p2 - A path name
Returns:
True if both paths are equal, ignoring trailing slashes, as well as case insensitivity on Windows.
Since:
jEdit 4.3pre2

getLeadingWhiteSpace

@Deprecated
public static int getLeadingWhiteSpace(java.lang.String str)
Deprecated. use StandardUtilities.getLeadingWhiteSpace(String)

Returns the number of leading white space characters in the specified string.

Parameters:
str - The string

getTrailingWhiteSpace

@Deprecated
public static int getTrailingWhiteSpace(java.lang.String str)
Deprecated. use StandardUtilities.getTrailingWhiteSpace(String)

Returns the number of trailing whitespace characters in the specified string.

Parameters:
str - The string
Since:
jEdit 2.5pre5

getLeadingWhiteSpaceWidth

@Deprecated
public static int getLeadingWhiteSpaceWidth(java.lang.String str,
                                                       int tabSize)
Deprecated. use StandardUtilities.getLeadingWhiteSpace(String)

Returns the width of the leading white space in the specified string.

Parameters:
str - The string
tabSize - The tab size

getVirtualWidth

@Deprecated
public static int getVirtualWidth(javax.swing.text.Segment seg,
                                             int tabSize)
Deprecated. use StandardUtilities.getVirtualWidth(javax.swing.text.Segment, int)

Returns the virtual column number (taking tabs into account) of the specified offset in the segment.

Parameters:
seg - The segment
tabSize - The tab size
Since:
jEdit 4.1pre1

getOffsetOfVirtualColumn

@Deprecated
public static int getOffsetOfVirtualColumn(javax.swing.text.Segment seg,
                                                      int tabSize,
                                                      int column,
                                                      int[] totalVirtualWidth)
Deprecated. use StandardUtilities.getVirtualWidth(javax.swing.text.Segment, int)

Returns the array offset of a virtual column number (taking tabs into account) in the segment.

Parameters:
seg - The segment
tabSize - The tab size
column - The virtual column number
totalVirtualWidth - If this array is non-null, the total virtual width will be stored in its first location if this method returns -1.
Returns:
-1 if the column is out of bounds
Since:
jEdit 4.1pre1

createWhiteSpace

@Deprecated
public static java.lang.String createWhiteSpace(int len,
                                                           int tabSize)
Deprecated. use StandardUtilities.createWhiteSpace(int, int)

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()));

Parameters:
len - The length
tabSize - The tab size, or 0 if tabs are not to be used

createWhiteSpace

@Deprecated
public static java.lang.String createWhiteSpace(int len,
                                                           int tabSize,
                                                           int start)
Deprecated. use StandardUtilities.createWhiteSpace(int, int, int)

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()));

Parameters:
len - The length
tabSize - The tab size, or 0 if tabs are not to be used
start - The start offset, for tab alignment
Since:
jEdit 4.2pre1

globToRE

@Deprecated
public static java.lang.String globToRE(java.lang.String glob)
Deprecated. Use StandardUtilities.globToRE(String).

Converts a Unix-style glob to a regular expression.

? becomes ., * becomes .*, {aa,bb} becomes (aa|bb).

Parameters:
glob - The glob pattern

escapesToChars

public static java.lang.String escapesToChars(java.lang.String str)
Converts "\n" and "\t" escapes in the specified string to newlines and tabs.

Parameters:
str - The string
Since:
jEdit 2.3pre1

charsToEscapes

@Deprecated
public static java.lang.String charsToEscapes(java.lang.String str)
Deprecated. use StandardUtilities.charsToEscapes(String)

Escapes newlines, tabs, backslashes, and quotes in the specified string.

Parameters:
str - The string
Since:
jEdit 2.3pre1

charsToEscapes

@Deprecated
public static java.lang.String charsToEscapes(java.lang.String str,
                                                         java.lang.String toEscape)
Deprecated. use StandardUtilities.charsToEscapes(String)

Escapes the specified characters in the specified string.

Parameters:
str - The string
toEscape - Any characters that require escaping
Since:
jEdit 4.1pre3

compareVersions

@Deprecated
public static int compareVersions(java.lang.String v1,
                                             java.lang.String v2)
Deprecated. Call StandardUtilities.compareStrings(String, String, boolean) instead


compareStrings

@Deprecated
public static int compareStrings(java.lang.String str1,
                                            java.lang.String str2,
                                            boolean ignoreCase)
Deprecated. use StandardUtilities.compareStrings(String, String, boolean)

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".

Parameters:
str1 - The first string
str2 - The second string
ignoreCase - If true, case will be ignored
Returns:
negative If str1 < str2, 0 if both are the same, positive if str1 > str2
Since:
jEdit 4.0pre1

stringsEqual

@Deprecated
public static boolean stringsEqual(java.lang.String s1,
                                              java.lang.String s2)
Deprecated. Call StandardUtilities.objectsEqual(Object, Object) instead.


objectsEqual

@Deprecated
public static boolean objectsEqual(java.lang.Object o1,
                                              java.lang.Object o2)
Deprecated. use StandardUtilities.objectsEqual(Object, Object)

Returns if two strings are equal. This correctly handles null pointers, as opposed to calling o1.equals(o2).

Since:
jEdit 4.2pre1

charsToEntities

@Deprecated
public static java.lang.String charsToEntities(java.lang.String str)
Deprecated. Use XMLUtilities.charsToEntities(String, boolean).

Converts <, >, & in the string to their HTML entity equivalents.

Parameters:
str - The string
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).

Parameters:
length - The size
Since:
jEdit 4.2pre1

getLongestPrefix

public static java.lang.String getLongestPrefix(java.util.List<java.lang.String> str,
                                                boolean ignoreCase)
Returns the longest common prefix in the given set of strings.

Parameters:
str - The strings
ignoreCase - If true, case insensitive
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.

Parameters:
str - The strings
ignoreCase - If true, case insensitive
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.

Parameters:
str - The strings (calls toString() on each object)
ignoreCase - If true, case insensitive
Since:
jEdit 4.2pre6

quicksort

@Deprecated
public static void quicksort(java.lang.Object[] obj,
                                        java.util.Comparator compare)
Deprecated. use Arrays.sort()

Sorts the specified array. Equivalent to calling Arrays.sort().

Parameters:
obj - The array
compare - Compares the objects
Since:
jEdit 4.0pre4

quicksort

@Deprecated
public static void quicksort(java.util.Vector vector,
                                        java.util.Comparator compare)
Deprecated. Collections.sort()

Sorts the specified vector.

Parameters:
vector - The vector
compare - Compares the objects
Since:
jEdit 4.0pre4

quicksort

@Deprecated
public static void quicksort(java.util.List list,
                                        java.util.Comparator compare)
Deprecated. Collections.sort()

Sorts the specified list.

Parameters:
list - The list
compare - Compares the objects
Since:
jEdit 4.0pre4

quicksort

@Deprecated
public static void quicksort(java.lang.Object[] obj,
                                        MiscUtilities.Compare compare)
Deprecated. use Arrays.sort()

Sorts the specified array. Equivalent to calling Arrays.sort().

Parameters:
obj - The array
compare - Compares the objects

quicksort

@Deprecated
public static void quicksort(java.util.Vector vector,
                                        MiscUtilities.Compare compare)
Deprecated. Collections.sort()

Sorts the specified vector.

Parameters:
vector - The vector
compare - Compares the objects

buildToVersion

public static java.lang.String buildToVersion(java.lang.String build)
Converts an internal version number (build) into a `human-readable' form.

Parameters:
build - The build

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:

  1. the classpath that was used when jEdit was started,
  2. jEdit's jars folder in the user's home,
  3. jEdit's system jars folder,
  4. 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).

Returns:
false if and only if on JDK 1.2 and tools.jar could not be found. In this case it prints some warnings on Log, too, about the places where it was searched for.
Since:
jEdit 3.2.2

parsePermissions

public static int parsePermissions(java.lang.String s)
Parse a Unix-style permission string (rwxrwxrwx).

Parameters:
s - The string (must be 9 characters long).
Since:
jEdit 4.1pre8

getEncodings

@Deprecated
public static java.lang.String[] getEncodings()
Deprecated. See #getEncodings(boolean)

Returns a list of supported character encodings.

Since:
jEdit 4.2pre5

getEncodings

public static java.lang.String[] getEncodings(boolean getSelected)
Returns a list of supported character encodings.

Parameters:
getSelected - Whether to return just the selected encodings or all.
Since:
jEdit 4.3pre5

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

parseXML

@Deprecated
public static boolean parseXML(java.io.InputStream in,
                                          org.xml.sax.helpers.DefaultHandler handler)
                        throws java.io.IOException
Deprecated. Use XMLUtilities.parseXML(InputStream,DefaultHandler).

Convenience method for parsing an XML file.

Returns:
Whether any error occured during parsing.
Throws:
java.io.IOException
Since:
jEdit 4.3pre5

findEntity

@Deprecated
public static org.xml.sax.InputSource findEntity(java.lang.String systemId,
                                                            java.lang.String test,
                                                            java.lang.Class where)
Deprecated. Use XMLUtilities.findEntity(String,String,Class).

Tries to find the given systemId in the context of the given class.