Package io.milton.common
Class Utils
- java.lang.Object
-
- io.milton.common.Utils
-
public class Utils extends Object
-
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DateaddSeconds(Date dt, int seconds)static DateaddSeconds(Date dt, long seconds)static StringdecodePath(String href)does percentage decoding on a path portion of a url E.g.static StringencodeURL(String str, String charset)This method has been provided by Andr� Kunert - looks a bit better then my shabby implementation! BMstatic StringescapeXml(String s)static ResourcefindChild(Resource parent, Path path)static io.milton.http.webdav.DestgetDecodedDestination(String destinationHeader)static StringgetProtocol(String url)static DatemostRecent(Date... dates)static Datenow()static StringpercentEncode(String s)this is a modified verion of java.net.URI.encode(s) the java.net version only encodes characters over , but this version also applies encoding to characters below char 48 this method should be applied only to parts of a URL, not the whole URL as forward slashes, semi-colons etc will be encoded by "part of url" i mean the bits between slashesstatic StringstripServer(String href)static StringsuffixSlash(String parentHref)Add a slash if not presentstatic StringtoCsv(Collection<String> list)Convert the list of strings to a comma separated stringstatic StringtoCsv(Collection<String> list, boolean addSpace)static StringtruncateFileName(String agent, String s)Used for parsing uploaded file names.static longwithMax(long n, long max)If n is > max, returns max.
-
-
-
Field Detail
-
UTF8
public static final Charset UTF8
-
-
Method Detail
-
findChild
public static Resource findChild(Resource parent, Path path) throws io.milton.http.exceptions.NotAuthorizedException, io.milton.http.exceptions.BadRequestException
- Throws:
io.milton.http.exceptions.NotAuthorizedExceptionio.milton.http.exceptions.BadRequestException
-
decodePath
public static String decodePath(String href)
does percentage decoding on a path portion of a url E.g. /foo > /foo /with%20space -> /with space- Parameters:
href-
-
now
public static Date now()
-
percentEncode
public static String percentEncode(String s)
this is a modified verion of java.net.URI.encode(s) the java.net version only encodes characters over , but this version also applies encoding to characters below char 48 this method should be applied only to parts of a URL, not the whole URL as forward slashes, semi-colons etc will be encoded by "part of url" i mean the bits between slashes- Parameters:
s-
-
encodeURL
public static String encodeURL(String str, String charset)
This method has been provided by Andr� Kunert - looks a bit better then my shabby implementation! BM- Parameters:
str-charset-- Returns:
-
toCsv
public static String toCsv(Collection<String> list)
Convert the list of strings to a comma separated string- Parameters:
list-- Returns:
- - a comma seperated list of values
-
toCsv
public static String toCsv(Collection<String> list, boolean addSpace)
-
truncateFileName
public static String truncateFileName(String agent, String s)
Used for parsing uploaded file names. MS web browsers tend to transmit the complete path for an uploaded file, but we generally only want to know the last part of the path. TODO: move this into milton- Parameters:
s-- Returns:
-
withMax
public static long withMax(long n, long max)If n is > max, returns max. Otherwise n- Parameters:
n-max-- Returns:
-
suffixSlash
public static String suffixSlash(String parentHref)
Add a slash if not present- Parameters:
parentHref-- Returns:
-
getDecodedDestination
public static io.milton.http.webdav.Dest getDecodedDestination(String destinationHeader)
-
-