com.bradmcevoy.http
Class Utils

java.lang.Object
  extended by com.bradmcevoy.http.Utils

public class Utils
extends java.lang.Object


Constructor Summary
Utils()
           
 
Method Summary
static java.util.Date addSeconds(java.util.Date dt, int seconds)
           
static java.util.Date addSeconds(java.util.Date dt, long seconds)
           
static java.lang.String decodePath(java.lang.String href)
          does percentage decoding on a path portion of a url E.g.
static java.lang.String encodeURL(java.lang.String str, java.lang.String charset)
          This method has been provided by Andr� Kunert - looks a bit better then my shabby implementation! BM
static java.lang.String escapeXml(java.lang.String s)
           
static Resource findChild(Resource parent, Path path)
           
static java.lang.String getProtocol(java.lang.String url)
           
static java.util.Date mostRecent(java.util.Date... dates)
           
static java.util.Date now()
           
static java.lang.String percentEncode(java.lang.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
static java.lang.String stripServer(java.lang.String href)
           
static java.lang.String toCsv(java.util.List<java.lang.String> list)
          Convert the list of strings to a comma separated string
static java.lang.String truncateFileName(java.lang.String s)
           
static java.lang.String truncateFileName(java.lang.String agent, java.lang.String s)
          Used for parsing uploaded file names.
static long withMax(long n, long max)
          If n is > max, returns max.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

findChild

public static Resource findChild(Resource parent,
                                 Path path)

decodePath

public static java.lang.String decodePath(java.lang.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 java.util.Date now()

addSeconds

public static java.util.Date addSeconds(java.util.Date dt,
                                        long seconds)

addSeconds

public static java.util.Date addSeconds(java.util.Date dt,
                                        int seconds)

getProtocol

public static java.lang.String getProtocol(java.lang.String url)

escapeXml

public static java.lang.String escapeXml(java.lang.String s)

percentEncode

public static java.lang.String percentEncode(java.lang.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 java.lang.String encodeURL(java.lang.String str,
                                         java.lang.String charset)
This method has been provided by Andr� Kunert - looks a bit better then my shabby implementation! BM

Parameters:
str -
charset -
Returns:

mostRecent

public static java.util.Date mostRecent(java.util.Date... dates)

toCsv

public static java.lang.String toCsv(java.util.List<java.lang.String> list)
Convert the list of strings to a comma separated string

Parameters:
list -

stripServer

public static java.lang.String stripServer(java.lang.String href)

truncateFileName

public static java.lang.String truncateFileName(java.lang.String agent,
                                                java.lang.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:

truncateFileName

public static java.lang.String truncateFileName(java.lang.String s)

withMax

public static long withMax(long n,
                           long max)
If n is > max, returns max. Otherwise n

Parameters:
n -
max -
Returns:


Copyright © 2011. All Rights Reserved.