public class NameUtils extends Object
Has accreeted a ragbag of other string bashing utilities.
| Constructor and Description |
|---|
NameUtils() |
| Modifier and Type | Method and Description |
|---|---|
static int |
asInt(Object param,
int defaultint)
Extract an integer from a parameter object, with default
|
static String |
decodeSafeName(String name)
Decode an encoded safe name
|
static String |
encodeSafeName(String name)
Convert a name to a safe name in a reversible fashion by
(very) conservative percent-encoding of the UTF-8 version.
|
static String |
ensureLastSlash(String u)
Normalize a URI by ensuring there is a final "/"
|
static String |
escape(String value,
char esc)
Escape a sensitive character by a "\" if it is not already so escaped.
|
static String |
extension(String f)
Find the .xxx extension of a file name
|
static String |
formatDuration(long duration)
Format a duration (measured in ms) as human readable
|
static String |
idFromURI(String uri)
Encode a resource URI into a unique label which can be used
as a URI segment into a REST API.
|
static boolean |
isURI(String name)
Test if the given name is a legal URI.
|
static String |
lastSegment(String f)
Find the last path segment in a URL or unix path.
|
static String |
newName(String type)
Generate a random name for something of the given type, result
will currently look like: {type}-{uuid}
|
static String |
newURI(String type,
String serverURI)
Generate a random URI for something of the given type, result
will currently look like: {server}/modal/{type}/{uuid}
|
static String |
normalizeFilepath(String path)
Normalize a relative file path to unix syntax.
|
static String |
removeExtension(String f)
Remove a trailing .xxx extension from a file name
|
static String |
removeFilePrefix(String f)
Strip any leading "file:" off a URL string
|
static String |
safeName(String name)
Convert an arbitrary name to name safe to use as a file name or URL path slug.
|
static String |
safeVarName(String name)
Convert an arbitrary name, such as a CSV column name to something usable as a
variable name in an expression as well as a path segment, normalizing the case.
|
static String |
splitAfterLast(String filename,
String at)
Return segment of a string after the last occurrence of "at"
|
static String |
splitBeforeLast(String filen,
String at)
Return segment of a string before the last occurrence of "at"
|
static String |
stripLastSlash(String u)
Normalize a URI by stripping any final "/"
|
static String |
uriFor(String name,
String serverURI,
String type)
Convert an arbitrary name to a URI which can be used in metadata
descriptions of the named object.
|
public static String safeName(String name)
public static String safeVarName(String name)
public static String uriFor(String name, String serverURI, String type)
{intendedBaseURL}/modal/{type}/{safe-version-of-name}
public static boolean isURI(String name)
public static String idFromURI(String uri)
public static String encodeSafeName(String name)
public static String newName(String type)
public static String newURI(String type, String serverURI)
public static int asInt(Object param, int defaultint)
public static String normalizeFilepath(String path)
public static String removeFilePrefix(String f)
public static String lastSegment(String f)
public static String stripLastSlash(String u)
public static String ensureLastSlash(String u)
public static String removeExtension(String f)
public static String splitAfterLast(String filename, String at)
public static String splitBeforeLast(String filen, String at)
public static String formatDuration(long duration)
Copyright © 2015. All rights reserved.