public class Util
extends java.lang.Object
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
commonPathPrefix(java.lang.String path1,
java.lang.String path2)
Finds the common path prefix of two specified paths.
|
static java.lang.String |
commonPrefix(java.lang.String str1,
java.lang.String str2)
Finds the common prefix of two specified strings.
|
static void |
copyFile(java.lang.String srcFilename,
java.lang.String dstFilename)
Does a fast file copy from specified source to specified destination.
|
static boolean |
endsWith(java.lang.String aString,
java.lang.String aSuffix)
Tests if specified string ends with the specified suffix.
|
static java.lang.String |
escape2Html(java.lang.String plainString)
Escapes a plain text string for html.
|
static java.lang.String |
getDateStamp()
Creates a string representing a date stamp of the current system date and
system time.
|
static boolean |
hasWildcards(java.lang.String filename)
Returns
true if the specified filename has wildcard
characters in it, i.e. |
static boolean |
isJavaIdentifier(java.lang.String candidate)
Returns
true if specified string is a valid identifier for
java or javascript. |
static boolean |
isLikelyIdentifier(java.lang.String candidate)
Returns
true if specified string is a mixed case string
with case mixing happening in the middle of the string (starting with
uppercase char and continuing with all lowercase chars does count). |
static boolean |
isValidCompositeReference(java.lang.String candidate)
Returns
true if specified string is a valid composite
reference where each part is a valid identifier for java or javascript. |
static boolean |
isWhitespace(java.lang.String candidate)
Returns
true if specified string is whitespace |
static java.lang.String |
millisToNice(long millis)
Converts milliseconds to some more human readable representation.
|
static java.nio.CharBuffer |
readBytes(java.io.InputStream inputStream,
java.nio.charset.CharsetDecoder decoder)
Reads an input stream completely into memory and returns a CharBuffer
instance with the contents.
|
static java.lang.String |
replaceSeparatedString(java.lang.String s,
java.lang.String sub,
java.lang.String with)
Replaces occurences of substring
sub with string
with in specified string but only if substring is
delimited by non-alphanumeric characters. |
static java.lang.String |
replaceString(java.lang.String s,
java.lang.String sub,
java.lang.String with)
Replaces occurences of substring
sub with string
with in specified string. |
static java.io.File |
resolveWebURL(java.lang.String urlPath,
java.lang.String webroot,
java.util.Map webmaps)
Resolves the specified url path to a file on the local file system.
|
static java.lang.String[] |
tokenizeCommaSepString(java.lang.String aString)
Creates an array of strings from a string of comma-separated string
tokens.
|
static java.lang.String |
wildCard2Pattern(java.lang.String wildcard)
Transforms a user wildcard into a java.util.regex.Pattern pattern string.
|
public static final java.lang.String millisToNice(long millis)
millis
- An amount of elapsed millisecondspublic static final java.lang.String[] tokenizeCommaSepString(java.lang.String aString)
aString
- string containing tokens separated by ","public static final java.lang.String commonPrefix(java.lang.String str1, java.lang.String str2)
str1
- first stringstr2
- second stringpublic static final java.lang.String commonPathPrefix(java.lang.String path1, java.lang.String path2)
path1
- first pathpath2
- second pathpublic static final void copyFile(java.lang.String srcFilename, java.lang.String dstFilename) throws java.io.IOException
srcFilename
- file name of source filedstFilename
- file name of copyjava.io.IOException
- if an I/O error occurspublic static final java.lang.String getDateStamp()
public static final boolean isJavaIdentifier(java.lang.String candidate)
true
if specified string is a valid identifier for
java or javascript.candidate
- potential identifiertrue
if it is in fact an identifierpublic static final boolean isValidCompositeReference(java.lang.String candidate)
true
if specified string is a valid composite
reference where each part is a valid identifier for java or javascript.candidate
- potential identifiertrue
if it is in fact a valid composite referencepublic static final boolean isWhitespace(java.lang.String candidate)
true
if specified string is whitespacecandidate
- potential whitespacetrue
if it is in fact whitespacepublic static final boolean isLikelyIdentifier(java.lang.String candidate)
true
if specified string is a mixed case string
with case mixing happening in the middle of the string (starting with
uppercase char and continuing with all lowercase chars does count).candidate
- potential mixed casetrue
if it is in fact mixed casepublic static java.lang.String replaceString(java.lang.String s, java.lang.String sub, java.lang.String with)
sub
with string
with
in specified string.s
- string for replacementsub
- substring to replacewith
- substring to take its placepublic static java.lang.String replaceSeparatedString(java.lang.String s, java.lang.String sub, java.lang.String with)
sub
with string
with
in specified string but only if substring is
delimited by non-alphanumeric characters.s
- string for replacementsub
- substring to replacewith
- substring to take its placepublic static boolean endsWith(java.lang.String aString, java.lang.String aSuffix)
aString
- string to testaSuffix
- suffix.true
if the ends in suffixpublic static boolean hasWildcards(java.lang.String filename)
true
if the specified filename has wildcard
characters in it, i.e. the name contains either "*" or "?" characters.filename
- filenametrue
if has wildcard characterspublic static java.lang.String wildCard2Pattern(java.lang.String wildcard)
wildcard
- wildcard stringpublic static java.io.File resolveWebURL(java.lang.String urlPath, java.lang.String webroot, java.util.Map webmaps)
urlPath
- a url pathwebroot
- directory path on local file system of the web rootwebmaps
- web map aliasespublic static java.nio.CharBuffer readBytes(java.io.InputStream inputStream, java.nio.charset.CharsetDecoder decoder) throws java.io.IOException
inputStream
- an input streamdecoder
- charset decoderjava.io.IOException
- if reading from inputStream throws IOExceptionpublic static java.lang.String escape2Html(java.lang.String plainString)
plainString
- plain text string