nu.staldal.lsp
Class Utils

java.lang.Object
  extended by nu.staldal.lsp.Utils

public final class Utils
extends java.lang.Object

Some utility methods. All methods in this class are static.


Method Summary
static boolean absoluteURL(java.lang.String url)
          Check whether an URL is absolute.
static java.lang.String encodePath(java.lang.String path)
          Encode a path name or URL into a filename.
static java.lang.String encodePathAsIdentifier(java.lang.String path)
          Encode a path name or URL into a Java identifier.
static java.lang.String nChars(int n, char c)
          Generate a String with a specified number of a given character.
static boolean pseudoAbsoluteURL(java.lang.String url)
          Check whether an URL is pseudo-absolute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encodePath

public static java.lang.String encodePath(java.lang.String path)
Encode a path name or URL into a filename. The encoding function is not intended to be inversible.

Parameters:
path - the path to encode
Returns:
the encoded path

encodePathAsIdentifier

public static java.lang.String encodePathAsIdentifier(java.lang.String path)
Encode a path name or URL into a Java identifier. The encoding function is not intended to be inversible.

Parameters:
path - the path to encode
Returns:
the encoded path

absoluteURL

public static boolean absoluteURL(java.lang.String url)
Check whether an URL is absolute.

Parameters:
url - the URL to check
Returns:
true if the URL contains at least one colon, and the first colon is before the first slash (if any).

pseudoAbsoluteURL

public static boolean pseudoAbsoluteURL(java.lang.String url)
Check whether an URL is pseudo-absolute.

Parameters:
url - the URL to check
Returns:
true if the URL start with a slash.

nChars

public static java.lang.String nChars(int n,
                                      char c)
Generate a String with a specified number of a given character.

Parameters:
n - character count
c - the character
Returns:
a string with c n times