Class Utils

java.lang.Object
io.milton.common.Utils

public class Utils extends Object
  • Field Details

    • UTF8

      public static final Charset UTF8
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • 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.NotAuthorizedException
      io.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()
    • addSeconds

      public static Date addSeconds(Date dt, long seconds)
    • addSeconds

      public static Date addSeconds(Date dt, int seconds)
    • getProtocol

      public static String getProtocol(String url)
    • escapeXml

      public static String escapeXml(String s)
    • 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:
    • mostRecent

      public static Date mostRecent(Date... dates)
    • 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)
    • stripServer

      public static String stripServer(String href)
    • 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)