Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.hartmath.util
Class Misc  view Misc download Misc.java

java.lang.Object
  extended bycom.hartmath.util.Misc

public class Misc
extends java.lang.Object

Class with several useful miscellaneous functions.

It provides methods for converting file names to class names, for constructing path names, and for various indentation calculations. A quicksort implementation is also available.

Version:
$Id: Misc.java,v 1.1 2001/10/06 13:30:21 khartlage Exp $

Nested Class Summary
static interface Misc.Compare
          An interface for comparing objects.
static class Misc.MenuItemCompare
           
static class Misc.StringCompare
          Compares strings.
static class Misc.StringICaseCompare
          Compares strings ignoring case.
static class Misc.VersionCompare
          Compares two version strings formatted like 'xxx.xx.xxx'.
 
Constructor Summary
private Misc()
           
 
Method Summary
static java.lang.String buildToVersion(java.lang.String build)
          Converts an internal version number (build) into a `human-readable' form.
private static java.lang.String canonPath(java.lang.String path)
           
static java.lang.String charsToEscapes(java.lang.String str)
          Escapes newlines, tabs, backslashes, quotes in the specified string.
static java.lang.String charsToEscapes(java.lang.String str, boolean history)
          Escapes newlines, tabs, backslashes, quotes in the specified string.
static java.lang.String classToFile(java.lang.String name)
          Converts a class name to a file name.
static int compareVersions(java.lang.String version1, java.lang.String version2)
          Helper function to compare two version strings, using the VersionCompare class.
static java.lang.String concatPath(java.lang.String parent, java.lang.String path)
          Like constructPath(), 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 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 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)
          For use with local files only - returns the last component of the specified path.
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 getParentOfPath(java.lang.String path)
          For use with local files only - 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 java.lang.String globToRE(java.lang.String glob)
          Converts a Unix-style glob to a regular expression.
static boolean isURL(java.lang.String str)
          Checks if the specified string is a URL.
private static void quicksort(java.lang.Object[] obj, int _start, int _end, Misc.Compare compare)
           
static void quicksort(java.lang.Object[] obj, Misc.Compare compare)
          Sorts the specified array.
private static void quicksort(java.util.Vector obj, int _start, int _end, Misc.Compare compare)
           
static void quicksort(java.util.Vector vector, Misc.Compare compare)
          Sorts the specified vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Misc

private Misc()
Method Detail

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.


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.


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.


concatPath

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


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)
For use with local files only - returns the last component of the specified path.


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)
For use with local files only - returns the parent of the specified path.

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.


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.


createWhiteSpace

public static java.lang.String createWhiteSpace(int len,
                                                int tabSize)
Creates a string of white space with the specified length.


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, quotes in the specified string.

Since:
jEdit 2.3pre1

charsToEscapes

public static java.lang.String charsToEscapes(java.lang.String str,
                                              boolean history)
Escapes newlines, tabs, backslashes, quotes in the specified string.

Since:
jEdit 2.7pre2

quicksort

public static void quicksort(java.lang.Object[] obj,
                             Misc.Compare compare)
Sorts the specified array.


quicksort

public static void quicksort(java.util.Vector vector,
                             Misc.Compare compare)
Sorts the specified vector.


compareVersions

public static int compareVersions(java.lang.String version1,
                                  java.lang.String version2)
Helper function to compare two version strings, using the VersionCompare class.


buildToVersion

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


canonPath

private static java.lang.String canonPath(java.lang.String path)

quicksort

private static void quicksort(java.lang.Object[] obj,
                              int _start,
                              int _end,
                              Misc.Compare compare)

quicksort

private static void quicksort(java.util.Vector obj,
                              int _start,
                              int _end,
                              Misc.Compare compare)