Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.blojsom.util
Class BlojsomUtils

    java.lang.Object
      org.blojsom.util.BlojsomUtils

All Implemented Interfaces:
  BlojsomConstants

public class BlojsomUtils
extends java.lang.Object
implements BlojsomConstants

BlojsomUtils

Since:
  blojsom 3.0
Version:
  $Id: BlojsomUtils.java,v 1.9 2006/05/05 15:58:21 czarneckid Exp $
Author:
  David Czarnecki

Field Summary
`static java.util.Comparator` | `FILE_NAME_COMPARATOR` Return a comparator to sort by name
`static java.util.Comparator` | `RESPONSE_COMPARATOR`

Fields inherited from interface org.blojsom.util.BlojsomConstants
`BLOG_ADMIN_URL_IP, BLOG_ADMINISTRATION_LOCALE_IP, BLOG_AUTHORIZATION_IP, BLOG_BASE_URL_IP, BLOG_COMMENTS_ENABLED_IP, BLOG_COUNTRY_DEFAULT, BLOG_COUNTRY_IP, BLOG_DEFAULT_FLAVOR_IP, BLOG_DEFAULT_TIMEZONE, BLOG_DEPTH_IP, BLOG_DESCRIPTION_IP, BLOG_EMAIL_ENABLED_IP, BLOG_ENTRIES_DISPLAY_DEFAULT, BLOG_ENTRIES_DISPLAY_IP, BLOG_ID_PARAM, BLOG_LANGUAGE_DEFAULT, BLOG_LANGUAGE_IP, BLOG_NAME_IP, BLOG_OWNER, BLOG_OWNER_EMAIL, BLOG_PINGBACKS_ENABLED_IP, BLOG_TRACKBACKS_ENABLED_IP, BLOG_URL_IP, BLOGS_DIRECTORY_IP, BLOJSOM_AJAX_STATUS, BLOJSOM_ALL_CATEGORIES, BLOJSOM_APPLICATION_CONTEXT, BLOJSOM_BLOG, BLOJSOM_BLOG_ID, BLOJSOM_CATEGORIES, BLOJSOM_COMMENTAPI_APPLICATION_CONTEXT, BLOJSOM_DATE, BLOJSOM_DATE_ISO8601, BLOJSOM_DATE_OBJECT, BLOJSOM_DATE_UTC, BLOJSOM_ENTRIES, BLOJSOM_LAST_MODIFIED, BLOJSOM_PERMALINK, BLOJSOM_PERMALINK_NEXT_ENTRY, BLOJSOM_PERMALINK_PREVIOUS_ENTRY, BLOJSOM_PLUGIN_CHAIN, BLOJSOM_PLUGINS, BLOJSOM_REQUESTED_CATEGORY, BLOJSOM_REQUESTED_FLAVOR, BLOJSOM_SITE_URL, BLOJSOM_VERSION, BLOJSOM_VERSION_NUMBER, BLOJSOM_XMLRPC_APPLICATION_CONTEXT, BOOTSTRAP_DIRECTORY_IP, CACHE_CONTROL_HTTP_HEADER, CATEGORY_PARAM, DEFAULT_BLOG_IP, DEFAULT_BLOGS_DIRECTORY, DEFAULT_BOOTSTRAP_DIRECTORY, DEFAULT_CONFIGURATION_BASE_DIRECTORY, DEFAULT_DIGEST_ALGORITHM, DEFAULT_FLAVOR_HTML, DEFAULT_POST_CATEGORY, DEFAULT_RECENT_COMMENTS_COUNT, DEFAULT_RECENT_PINGBACKS_COUNT, DEFAULT_RECENT_TRACKBACKS_COUNT, DEFAULT_RESOURCES_DIRECTORY, DEFAULT_TEMPLATES_DIRECTORY, DIGEST_ALGORITHM, FAILURE, FLAVOR_PARAM, HTTP_ETAG, HTTP_LASTMODIFIED, INFINITE_BLOG_DEPTH, INSTALLED_LOCALES_IP, ISO_8601_DATE_FORMAT, LINE_SEPARATOR, LINEAR_NAVIGATION_ENABLED_IP, MAX_HASHABLE_LENGTH, NO_CACHE_HTTP_HEADER_VALUE, OVERRIDE_LASTMODIFIED_PARAM, PAGE_NUMBER_PARAM, PAGE_PARAM, PAGE_PARAM_ARCHIVE, PERMALINK_PARAM, PLUGINS_PARAM, PRAGMA_HTTP_HEADER, PREFERRED_SYNDICATION_FLAVOR, RECENT_COMMENTS_COUNT, RECENT_PINGBACKS_COUNT, RECENT_TRACKBACKS_COUNT, RECURSIVE_CATEGORIES, REDIRECT_TO_PARAM, RESOURCE_MANAGER_CONTEXT_KEY, RESOURCES_DIRECTORY_IP, RFC_822_DATE_FORMAT, SHORT_ISO_8601_DATE_FORMAT, SUCCESS, TEMPLATES_DIRECTORY_IP, USE_DYNAMIC_BLOG_URLS, USE_ENCRYPTED_PASSWORDS, USE_RICHTEXT_EDITOR, UTC_DATE_FORMAT, UTF8, WHITESPACE, XMLRPC_ENABLED_IP`

Method Summary
`static java.lang.String` | `addSlashes(java.lang.String input)` Add preceeding and trailing slashes to an input string.
`static java.lang.String` | `addTrailingSlash(java.lang.String input)` Add a trailing slash to the input
`static java.util.Map` | `arrayOfStringsToMap(java.lang.String[] array)` Turn an array of strings into a Map where the keys and values are the input strings.
`static java.lang.String` | `arrayOfStringsToString(java.lang.String[] array)` Turn an array of strings into a single string separated by commas.
`static java.lang.String` | `arrayOfStringsToString(java.lang.String[] array, java.lang.String separator)` Turn an array of strings into a single string separated by a given delimeter.
`static java.util.List` | `arrayToList(java.lang.String[] input)` Convert a `String[]` to a `List`
`static java.util.Map` | `blojsomPropertiesToMap(java.util.Properties properties)` Convert a `BlojsomProperties` object to a `Map`.
`static boolean` | `checkMapForKey(java.util.Map map, java.lang.String key)` Check to see if a given map contains a particular key.
`static boolean` | `checkNullOrBlank(java.lang.String input)` Checks to see if the string is null or blank (after trimming)
`static java.lang.String` | `checkStartingAndEndingSlash(java.lang.String input)` Add a '/' at the beginning and end of the input string if necessary.
`static java.lang.String` | `constructBaseURL(javax.servlet.http.HttpServletRequest httpServletRequest)` Construct a blog base URL from the request
`static java.lang.String` | `constructBlogURL(javax.servlet.http.HttpServletRequest httpServletRequest, java.lang.String blogID)` Construct a blog URL from the request
`static java.lang.String` | `convertRequestParams(javax.servlet.http.HttpServletRequest request)` Convert the request parameters to a string
`static java.lang.String` | `convertRequestParams(javax.servlet.http.HttpServletRequest request, java.util.Map ignoreParams)` Convert the request parameters to a string
`static void` | `copyDirectory(java.io.File sourceDirectory, java.io.File targetDirectory)` Recursively copy a directory from a source to a target
`static java.util.List` | `csvToList(java.lang.String valuesAsString)` Return a comma-separated list of Strings as a `List`; trims space around value
`static int` | `daysBetweenDates(java.util.Date startDate, java.util.Date endDate)` Return the number of days between two dates
`static boolean` | `deleteDirectory(java.io.File directoryOrFile)` Delete a directory (or file) and any sub-directories underneath the directory
`static boolean` | `deleteDirectory(java.io.File directoryOrFile, boolean removeDirectoryOrFile)` Delete a directory (or file) and any sub-directories underneath the directory
`static java.lang.String` | `digestString(java.lang.String data)` Performs an MD5 Digest onthe given String content
`static java.lang.String` | `digestString(java.lang.String data, java.lang.String algorithm)` Performs an Digest onthe given String content for the given algorithm
`static java.lang.String` | `escapeMetaAndLink(java.lang.String input)` Return an escaped string where <meta, <link tags are escaped
`static java.lang.String` | `escapeString(java.lang.String input)` Return an escaped string where &, <, >, ", and ' are converted to their HTML equivalents
`static java.lang.String` | `escapeStringSimple(java.lang.String input)` Return an escaped string where &, <, > are converted to their HTML equivalents
`static java.lang.String` | `getBlogFromPath(java.lang.String pathInfo)` Returns blog id information from the path provided to the method where the path provided is assumed to be everything after the servlet instance with a user id at the very beginning of the path.
`static java.lang.String` | `getBlogSiteURL(java.lang.String blogURL, java.lang.String servletPath)` Return a URL to the main blog site without the servlet path requested
`static java.lang.String` | `getCalendarNavigationUrl(java.lang.String prefix, int month, int day, int year)` Create a Calendar Navigatation URL
`static java.lang.String` | `getCategoryFromPath(java.lang.String pathInfo)` Returns category information from the path provided to the method where the path provided is assumed to be everything after the servlet instance with a user id at the very beginning of the path.
`static java.lang.String[]` | `getCountriesForSystem(java.util.Locale locale)` Return of a list of locale countries supported on this system (JVM)
`static java.lang.String` | `getDateKey(java.util.Date date)` Return a string of "YYYYMMDD"
`static java.io.FileFilter` | `getDirectoryFilter()` Return a file filter which only returns directories
`static java.io.FileFilter` | `getDirectoryFilter(java.lang.String[] excludedDirectories)` Return a file filter which only returns directories that are not one of a list of excluded directories
`static java.io.FileFilter` | `getExtensionFilter(java.lang.String extension)` Return a file filter which takes a single file extension to look for
`static java.io.FileFilter` | `getExtensionsFilter(java.lang.String[] extensions)` Return a file filter which takes a list of file extensions to look for
`static java.io.FileFilter` | `getExtensionsFilter(java.lang.String[] extensions, java.lang.String[] excludedDirectories, boolean returnDirectories)` Return a file filter which takes a list of file extensions to look for
`static java.lang.String` | `getFileExtension(java.lang.String filename)` Return the file extension for a given filename or `null` if no file extension is present
`static java.lang.String` | `getFilename(java.lang.String filename)` Return the filename without extension for a given filename
`static java.io.File` | `getFilenameForDate(java.lang.String filename)` Return a filename with the date as a long value before the file extension.
`static java.lang.String` | `getFilenameForPermalink(java.lang.String permalink, java.lang.String[] blogEntryExtensions)` Return only the filename of a permalink request
`static java.lang.String` | `getFilenameFromPath(java.lang.String filenameWithPath)` Returns the base file name from the supplied file path.
`static java.util.Date` | `getFirstDateOfYear(java.util.Locale locale, int year)` Find the first date of a year
`static java.util.Date` | `getFirstDateOfYearMonth(java.util.Locale locale, int year, int month)` Find the first date of a year/month
`static java.util.Date` | `getFirstDateOfYearMonthDay(java.util.Locale locale, int year, int month, int day)` Get the first date of a year/month/day
`static java.lang.String` | `getFirstLine(java.lang.String input, int length)` Extracts the first line in a given string, otherwise returns the first n bytes
`static java.lang.String` | `getFormattedDate(java.util.Date date, java.lang.String format, java.util.Locale locale)` Return a date formatted date
`static java.lang.String` | `getHashableContent(java.lang.String content)` Return a digested string of some content
`static java.lang.String` | `getISO8601Date(java.util.Date date)` Return a date in ISO 8601 style http://www.w3.org/TR/NOTE-datetime
`static java.lang.String` | `getKeysAsStringList(java.util.Map input)` Return the keys of a map as a comma-separated list
`static java.lang.String[]` | `getLanguagesForSystem(java.util.Locale locale)` Return of a list of locale languages supported on this system (JVM)
`static java.util.Date` | `getLastDateOfYear(java.util.Locale locale, int year)` Find the last date of a year
`static java.util.Date` | `getLastDateOfYearMonth(java.util.Locale locale, int year, int month)` Find the last date of a year/month
`static java.util.Date` | `getLastDateOfYearMonthDay(java.util.Locale locale, int year, int month, int day)` Get the last date of a year/month/day
`static java.util.Locale` | `getLocaleFromString(java.lang.String locale)` Create a `Locale` object from a string of form `language_country_variant`
`static java.lang.String` | `getPostSlug(java.lang.String title, java.lang.String content)` Return a filename appropriate for the blog entry content
`static java.io.FileFilter` | `getRegularExpressionFilter(java.lang.String[] expressions)` Return a file filter which takes a list of regular expressions to look for
`static java.lang.String` | `getRequestValue(java.lang.String key, javax.servlet.http.HttpServletRequest httpServletRequest)` Tries to retrieve a given key using getParameter(key) and if not available, will use getAttribute(key) from the servlet request
`static java.lang.String` | `getRequestValue(java.lang.String key, javax.servlet.http.HttpServletRequest httpServletRequest, boolean preferAttributes)` Tries to retrieve a given key using getParameter(key) and if not available, will use getAttribute(key) from the servlet request
`static java.lang.String[]` | `getRequestValues(java.lang.String key, javax.servlet.http.HttpServletRequest httpServletRequest)` Get request values for a given key and if not available, returns and empty `String[]`
`static java.lang.String` | `getRFC822Date(java.util.Date date)` Return a date in RFC 822 style
`static java.lang.String` | `getTemplateForPage(java.lang.String flavorTemplate, java.lang.String page)` Return the template name for a particular page
`static java.lang.String[]` | `getTimeZonesForSystem(java.util.Locale locale)` Return of a list of time zone IDs supported on this system (JVM)
`static java.lang.String` | `getUTCDate(java.util.Date date)` Return a date in UTC style
`static void` | `listDirectoriesInSubdirectories(java.io.File directory, java.lang.String parentDirectory, java.util.List directories)` List the sub-directories in a sub-directory of a given directory and strip the parent directory from the path of the directories added to the list.
`static void` | `listFilesInSubdirectories(java.io.File directory, java.lang.String parentDirectory, java.util.List files)` List the files in a sub-directory of a given directory and strip the parent directory from the path of the files added to the list.
`static java.lang.String` | `listToCSV(java.util.List values)` Convert a list to a comma-separated string.
`static java.util.Map` | `listToMap(java.util.List values)` Convert a list of values to a `Map`.
`static java.lang.String` | `listToString(java.util.List values, java.lang.String separator)` Return a `List` as a string
`static java.lang.String` | `normalize(java.lang.String path)` Normalize a path to remove all ./, ../, .../, //, etc.
`static java.lang.String` | `nullToBlank(java.lang.String input)` Check to see if the given input string is `null` and if so, return a blank string instead
`static java.lang.String[]` | `parseCommaList(java.lang.String commaList)` Parse a comma-separated list of values; also parses over internal spaces
`static java.lang.String[]` | `parseDelimitedList(java.lang.String delimitedList, java.lang.String delimiter)` Parse a delimited list of values
`static java.lang.String[]` | `parseDelimitedList(java.lang.String delimitedList, java.lang.String delimiter, boolean trim)` Parse a delimited list of values
`static java.lang.String[]` | `parseLastComma(java.lang.String value)` Parse a string into two separate strings based on the last comma in the input value
`static java.lang.String[]` | `parseOnlyCommaList(java.lang.String commaList)` Parse a comma-separated list of values
`static java.lang.String[]` | `parseOnlyCommaList(java.lang.String commaList, boolean trim)` Parse a comma-separated list of values
`static java.util.Map` | `propertiesToMap(java.util.Properties properties)` Convert a set of `Properties` to a `Map`
`static java.lang.String` | `removeInitialSlash(java.lang.String input)` Remove the initial "/" from a string
`static java.util.List` | `removeNullValues(java.util.List input)` Remove `null` values from a given list
`static java.lang.String` | `removeSlashes(java.lang.String input)` Remove the "/" from the beginning and end of a string
`static java.lang.String` | `removeTrailingSlash(java.lang.String input)` Remove the trailing "/" from a string
`static java.lang.String` | `replace(java.lang.String str, java.lang.String pattern, java.lang.String replace)` Replace any occurances of a string pattern within a string with a different string.
`static void` | `resolveDynamicBaseAndBlogURL(javax.servlet.http.HttpServletRequest httpServletRequest, Blog blog, java.lang.String blogID)` Check to see if the blog base URL or blog URL are present.
`static void` | `setNoCacheControlHeaders(javax.servlet.http.HttpServletResponse httpServletResponse)` Set various cache control HTTP headers so that the browser does not try and cache the page
`static java.lang.String` | `stripHTML(java.lang.String text)` Strip all HTML from a given piece of text
`static java.lang.String` | `stripLineTerminators(java.lang.String input)` Strip line terminator characters from an input string
`static java.lang.String` | `stripLineTerminators(java.lang.String input, java.lang.String replacement)` Strip line terminator characters from an input string
`static java.lang.String` | `toHexString(byte[] buf, int offset, int length)` Convert a byte array to a hex string
`static java.lang.String` | `urlDecode(java.lang.String input)` Return a URL decoded string
`static java.lang.String` | `urlEncode(java.lang.String input)` Return an input string URL encoded
`static java.lang.String` | `urlEncodeForLink(java.lang.String input)` Return an input string URL encoded for a URL link where '/' show as '/'

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### FILE_NAME_COMPARATOR

    public static final java.util.Comparator FILE_NAME_COMPARATOR

  Return a comparator to sort by name

### RESPONSE_COMPARATOR

    public static java.util.Comparator RESPONSE_COMPARATOR

Method Detail

### getDirectoryFilter

    public static java.io.FileFilter getDirectoryFilter()

  Return a file filter which only returns directories

  Returns:
    File filter appropriate for filtering only directories

### getDirectoryFilter

    public static java.io.FileFilter getDirectoryFilter(java.lang.String[] excludedDirectories)

  Return a file filter which only returns directories that are not one of a list of excluded directories

  Parameters:
    `excludedDirectories` - List of directories to exclude
  Returns:
    File filter appropriate for filtering only directories

### getRFC822Date

    public static java.lang.String getRFC822Date(java.util.Date date)

  Return a date in RFC 822 style

  Parameters:
    `date` - Date
  Returns:
    Date formatted as RFC 822

### getFormattedDate

    public static java.lang.String getFormattedDate(java.util.Date date,
                                                    java.lang.String format,
                                                    java.util.Locale locale)

  Return a date formatted date

  Parameters:
    `date` - Date
    `format` - Date Format String
    `locale` - Locale Locale for retrieving proper date symbols
  Returns:
    Date formatted date

### getISO8601Date

    public static java.lang.String getISO8601Date(java.util.Date date)

  Return a date in ISO 8601 style http://www.w3.org/TR/NOTE-datetime

  Parameters:
    `date` - Date
  Returns:
    Date formatted as ISO 8601

### getUTCDate

    public static java.lang.String getUTCDate(java.util.Date date)

  Return a date in UTC style

  Parameters:
    `date` - Date
  Returns:
    Date formatted as ISO 8601

### getRegularExpressionFilter

    public static java.io.FileFilter getRegularExpressionFilter(java.lang.String[] expressions)

  Return a file filter which takes a list of regular expressions to look for

  Parameters:
    `expressions` - List of regular expressions for files to retrieve
  Returns:
    File filter appropriate for filtering out a set of files based on regular expressions

### getExtensionsFilter

    public static java.io.FileFilter getExtensionsFilter(java.lang.String[] extensions)

  Return a file filter which takes a list of file extensions to look for

  Parameters:
    `extensions` - List of file extensions
  Returns:
    File filter appropriate for filtering out a set of file extensions

### getExtensionsFilter

    public static java.io.FileFilter getExtensionsFilter(java.lang.String[] extensions,
                                                         java.lang.String[] excludedDirectories,
                                                         boolean returnDirectories)

  Return a file filter which takes a list of file extensions to look for

  Parameters:
    `extensions` - List of file extensions
    `returnDirectories` - Whether or not to return
  Returns:
    File filter appropriate for filtering out a set of file extensions

### getExtensionFilter

    public static java.io.FileFilter getExtensionFilter(java.lang.String extension)

  Return a file filter which takes a single file extension to look for

  Parameters:
    `extension` - File extension
  Returns:
    File filter appropriate for filtering out a single file extension

### parseCommaList

    public static java.lang.String[] parseCommaList(java.lang.String commaList)

  Parse a comma-separated list of values; also parses over internal spaces

  Parameters:
    `commaList` - Comma-separated list
  Returns:
    Individual strings from the comma-separated list

### parseOnlyCommaList

    public static java.lang.String[] parseOnlyCommaList(java.lang.String commaList)

  Parse a comma-separated list of values

  Parameters:
    `commaList` - Comma-separated list
  Returns:
    Individual strings from the comma-separated list

### parseOnlyCommaList

    public static java.lang.String[] parseOnlyCommaList(java.lang.String commaList,
                                                        boolean trim)

  Parse a comma-separated list of values

  Parameters:
    `commaList` - Comma-separated list
    `trim` - If the contents of the array should be trimmed
  Returns:
    Individual strings from the comma-separated list

### parseLastComma

    public static java.lang.String[] parseLastComma(java.lang.String value)

  Parse a string into two separate strings based on the last comma in the input value

  Parameters:
    `value` - Input
  Returns:
    Parsed string

### parseDelimitedList

    public static java.lang.String[] parseDelimitedList(java.lang.String delimitedList,
                                                        java.lang.String delimiter)

  Parse a delimited list of values

  Parameters:
    `delimitedList` - Delimited list
    `delimiter` - Field Delimiter
  Returns:
    Individual strings from the comma-separated list

### parseDelimitedList

    public static java.lang.String[] parseDelimitedList(java.lang.String delimitedList,
                                                        java.lang.String delimiter,
                                                        boolean trim)

  Parse a delimited list of values

  Parameters:
    `delimitedList` - Delimited list
    `delimiter` - Field Delimiter
    `trim` - If the contents of the array should be trimmed
  Returns:
    Individual strings from the comma-separated list

### convertRequestParams

    public static java.lang.String convertRequestParams(javax.servlet.http.HttpServletRequest request)

  Convert the request parameters to a string

  Parameters:
    `request` - Servlet request
  Returns:
    Request parameters in the form &name=value

### convertRequestParams

    public static java.lang.String convertRequestParams(javax.servlet.http.HttpServletRequest request,
                                                        java.util.Map ignoreParams)

  Convert the request parameters to a string

  Parameters:
    `request` - Servlet request
    `ignoreParams` - Parameters to ignore when converting the request
  Returns:
    Request parameters in the form &name=value

### getBlogSiteURL

    public static java.lang.String getBlogSiteURL(java.lang.String blogURL,
                                                  java.lang.String servletPath)

  Return a URL to the main blog site without the servlet path requested

  Parameters:
    `blogURL` - URL for the blog
    `servletPath` - Servlet path under which the blog is placed
  Returns:
    URL to the blog up to the servlet path

### escapeString

    public static java.lang.String escapeString(java.lang.String input)

  Return an escaped string where &, <, >, ", and ' are converted to their HTML equivalents

  Parameters:
    `input` - Unescaped string
  Returns:
    Escaped string containing HTML equivalents for &, <, >, ", and '

### escapeStringSimple

    public static java.lang.String escapeStringSimple(java.lang.String input)

  Return an escaped string where &, <, > are converted to their HTML equivalents

  Parameters:
    `input` - Unescaped string
  Returns:
    Escaped string containing HTML equivalents for &, <, >

### escapeMetaAndLink

    public static java.lang.String escapeMetaAndLink(java.lang.String input)

  Return an escaped string where <meta, <link tags are escaped

  Parameters:
    `input` - Unescaped string
  Returns:
    Escaped string where <meta, <link tags are escaped

### replace

    public static java.lang.String replace(java.lang.String str,
                                           java.lang.String pattern,
                                           java.lang.String replace)

  Replace any occurances of a string pattern within a string with a different string.

  Parameters:
    `str` - The source string. This is the string that will be searched and have the replacements
    `pattern` - The pattern to look for in str
    `replace` - The string to insert in the place of pattern
  Returns:
    String with replace occurences

### getFileExtension

    public static java.lang.String getFileExtension(java.lang.String filename)

  Return the file extension for a given filename or `null` if no file extension is present

  Parameters:
    `filename` - Filename
  Returns:
    File extension without the . or `null` if no file extension is present

### getFilename

    public static java.lang.String getFilename(java.lang.String filename)

  Return the filename without extension for a given filename

  Parameters:
    `filename` - Filename
  Returns:
    Filename up to the .

### getFilenameFromPath

    public static java.lang.String getFilenameFromPath(java.lang.String filenameWithPath)

  Returns the base file name from the supplied file path. On the surface, this would appear to be a trivial task. Apparently, however, some Linux JDKs do not implement `File.getName()` correctly for Windows paths, so we attempt to take care of that here.

  Parameters:
    `filenameWithPath` - The full path to the file.
  Returns:
    The base file name, from the end of the path.

### getDateKey

    public static java.lang.String getDateKey(java.util.Date date)

  Return a string of "YYYYMMDD"

  Parameters:
    `date` - Date from which to extract "key"
  Returns:
    String of "YYYYMMDD"

### removeInitialSlash

    public static java.lang.String removeInitialSlash(java.lang.String input)

  Remove the initial "/" from a string

  Parameters:
    `input` - Input string
  Returns:
    Input string without initial "/" removed or `null` if the input was null

### removeTrailingSlash

    public static java.lang.String removeTrailingSlash(java.lang.String input)

  Remove the trailing "/" from a string

  Parameters:
    `input` - Input string
  Returns:
    Input string with trailing "/" removed or `null` if the input was null

### removeSlashes

    public static java.lang.String removeSlashes(java.lang.String input)

  Remove the "/" from the beginning and end of a string

  Parameters:
    `input` - Input string
  Returns:
    Input string with beginning and ending "/" removed or `null` if the input was null

### getFirstLine

    public static java.lang.String getFirstLine(java.lang.String input,
                                                int length)

  Extracts the first line in a given string, otherwise returns the first n bytes

  Parameters:
    `input` - String from which to extract the first line
    `length` - Number of bytes to return if line seperator isnot found
  Returns:
    the first line of the string

### getTemplateForPage

    public static java.lang.String getTemplateForPage(java.lang.String flavorTemplate,
                                                      java.lang.String page)

  Return the template name for a particular page

  Parameters:
    `flavorTemplate` - Flavor template filename
    `page` - Requested page
  Returns:

### getRequestValue

    public static java.lang.String getRequestValue(java.lang.String key,
                                                   javax.servlet.http.HttpServletRequest httpServletRequest)

  Tries to retrieve a given key using getParameter(key) and if not available, will use getAttribute(key) from the servlet request

  Parameters:
    `key` - Parameter to retrieve
    `httpServletRequest` - Request
  Returns:
    Value of the key as a string, or `null` if there is no parameter/attribute

### getRequestValue

    public static java.lang.String getRequestValue(java.lang.String key,
                                                   javax.servlet.http.HttpServletRequest httpServletRequest,
                                                   boolean preferAttributes)

  Tries to retrieve a given key using getParameter(key) and if not available, will use getAttribute(key) from the servlet request

  Parameters:
    `key` - Parameter to retrieve
    `httpServletRequest` - Request
    `preferAttributes` - If request attributes should be checked before request parameters
  Returns:
    Value of the key as a string, or `null` if there is no parameter/attribute

### getRequestValues

    public static java.lang.String[] getRequestValues(java.lang.String key,
                                                      javax.servlet.http.HttpServletRequest httpServletRequest)

  Get request values for a given key and if not available, returns and empty `String[]`

  Parameters:
    `key` - Parameter to retrieve
    `httpServletRequest` - Request
  Returns:
    Request values for the key as a `String[]`

### getFilenameForPermalink

    public static java.lang.String getFilenameForPermalink(java.lang.String permalink,
                                                           java.lang.String[] blogEntryExtensions)

  Return only the filename of a permalink request

  Parameters:
    `permalink` - Permalink request
    `blogEntryExtensions` - Regex for blog entries so that we only pickup requests for valid blog entries
  Returns:
    Filename portion of permalink request

### urlEncode

    public static java.lang.String urlEncode(java.lang.String input)

  Return an input string URL encoded

  Parameters:
    `input` - Input string
  Returns:
    URL encoded string, `null` if the input was null, or `input` unmodified there is an encoding exception

### urlEncodeForLink

    public static java.lang.String urlEncodeForLink(java.lang.String input)

  Return an input string URL encoded for a URL link where '/' show as '/'

  Parameters:
    `input` - Input string
  Returns:
    URL encoded string, `null` if the input was null, or `input` unmodified there is an encoding exception

### urlDecode

    public static java.lang.String urlDecode(java.lang.String input)

  Return a URL decoded string

  Parameters:
    `input` - Input string
  Returns:
    URL decoded string or `null` if either the input was null or there is a decoding exception

### getCalendarNavigationUrl

    public static java.lang.String getCalendarNavigationUrl(java.lang.String prefix,
                                                            int month,
                                                            int day,
                                                            int year)

  Create a Calendar Navigatation URL

  Parameters:
    `prefix` - Any URL Prefix
    `month` - Month of navigation
    `day` - Day of navigation
    `year` - Year of navigation
  Returns:
    Properly formatted calendar navigation url

### digestString

    public static java.lang.String digestString(java.lang.String data)

  Performs an MD5 Digest onthe given String content

  Parameters:
    `data` - Content to digest
  Returns:
    The Hash as Hex String

### digestString

    public static java.lang.String digestString(java.lang.String data,
                                                java.lang.String algorithm)

  Performs an Digest onthe given String content for the given algorithm

  Parameters:
    `data` - Content to digest
    `algorithm` - the algorithm to use (MD5, SHA1)
  Returns:
    The Hash as Hex String

### toHexString

    public static java.lang.String toHexString(byte[] buf,
                                               int offset,
                                               int length)

  Convert a byte array to a hex string

  Parameters:
    `buf` - Byte array to convert to hex string
    `offset` - Starting offset for conversion
    `length` - Length to convert
  Returns:
    Hex string representing the byte array

### normalize

    public static java.lang.String normalize(java.lang.String path)

  Normalize a path to remove all ./, ../, .../, //, etc. type references

  Parameters:
    `path` - Input path
  Returns:
    Normalized path

### nullToBlank

    public static java.lang.String nullToBlank(java.lang.String input)

  Check to see if the given input string is `null` and if so, return a blank string instead

  Parameters:
    `input` - Input string
  Returns:
    Blank string if the input string is `null`, otherwise just return the input string

### propertiesToMap

    public static java.util.Map propertiesToMap(java.util.Properties properties)

  Convert a set of `Properties` to a `Map`

  Parameters:
    `properties` - Properties to be converted to a Map
  Returns:
    Map object containing all the keys and values from the original Properties object. If the Properties object was null, a new Map is returned with no values.

### blojsomPropertiesToMap

    public static java.util.Map blojsomPropertiesToMap(java.util.Properties properties)

  Convert a `BlojsomProperties` object to a `Map`. If the properties object is `null` an emtpy `Map` is returned.

  Parameters:
    `properties` - `BlojsomProperties`
  Returns:
    `Map` containing keys and values from the properties

### arrayOfStringsToString

    public static java.lang.String arrayOfStringsToString(java.lang.String[] array,
                                                          java.lang.String separator)

  Turn an array of strings into a single string separated by a given delimeter. If the incoming array is null, this method returns the `null` string.

  Parameters:
    `array` - Array of strings
    `separator` - Separator between strings
  Returns:
    Single string containing all the strings from the original array separated by the given delimeter, or `null` if the input was null.

### arrayOfStringsToString

    public static java.lang.String arrayOfStringsToString(java.lang.String[] array)

  Turn an array of strings into a single string separated by commas. If the incoming array is null, this method returns the `null` string.

  Parameters:
    `array` - Array of strings
  Returns:
    Single string containing all the strings from the original array separated by commas, or `null` if the input was null.

### getCategoryFromPath

    public static java.lang.String getCategoryFromPath(java.lang.String pathInfo)

  Returns category information from the path provided to the method where the path provided is assumed to be everything after the servlet instance with a user id at the very beginning of the path. For example, /david/this/is/the/category

  Parameters:
    `pathInfo` - Path information
  Returns:
    Everything after the second "/" character in the path

### getBlogFromPath

    public static java.lang.String getBlogFromPath(java.lang.String pathInfo)

  Returns blog id information from the path provided to the method where the path provided is assumed to be everything after the servlet instance with a user id at the very beginning of the path. For example, /david/this/is/the/category

  Parameters:
    `pathInfo` - Path information
  Returns:
    Everything before the second "/" character in the path

### deleteDirectory

    public static boolean deleteDirectory(java.io.File directoryOrFile)

  Delete a directory (or file) and any sub-directories underneath the directory

  Parameters:
    `directoryOrFile` - Directory or file to be deleted
  Returns:
    `true` if the directory (or file) could be deleted, `false` otherwise

### deleteDirectory

    public static boolean deleteDirectory(java.io.File directoryOrFile,
                                          boolean removeDirectoryOrFile)

  Delete a directory (or file) and any sub-directories underneath the directory

  Parameters:
    `directoryOrFile` - Directory or file to be deleted
    `removeDirectoryOrFile` - If the directory of file should be deleted in addition to the sub-directories
  Returns:
    `true` if the directory (or file) could be deleted, `false` otherwise

### copyDirectory

    public static void copyDirectory(java.io.File sourceDirectory,
                                     java.io.File targetDirectory)
                              throws java.io.IOException

  Recursively copy a directory from a source to a target

  Parameters:
    `sourceDirectory` - Source directory
    `targetDirectory` - Destination directory
  Throws:
    `java.io.IOException` - If there is an error copying the files and directories

### arrayOfStringsToMap

    public static java.util.Map arrayOfStringsToMap(java.lang.String[] array)

  Turn an array of strings into a Map where the keys and values are the input strings. If the incoming array is null, this method returns an empty map.

  Parameters:
    `array` - Array of strings
  Returns:
    Map Map containing all the strings from the original array or an empty map if the incoming array is null.

### checkStartingAndEndingSlash

    public static java.lang.String checkStartingAndEndingSlash(java.lang.String input)

  Add a '/' at the beginning and end of the input string if necessary.

  Parameters:
    `input` - Input string
  Returns:
    String with a '/' at the beginning and end of the original string, `null` if the input was `null`

### checkNullOrBlank

    public static boolean checkNullOrBlank(java.lang.String input)

  Checks to see if the string is null or blank (after trimming)

  Parameters:
    `input` - Input string
  Returns:
    `true` if the string is null or blank (after trimming), `false` otherwise

### setNoCacheControlHeaders

    public static void setNoCacheControlHeaders(javax.servlet.http.HttpServletResponse httpServletResponse)

  Set various cache control HTTP headers so that the browser does not try and cache the page

  Parameters:
    `httpServletResponse` - Response

### checkMapForKey

    public static boolean checkMapForKey(java.util.Map map,
                                         java.lang.String key)

  Check to see if a given map contains a particular key. Returns `true` if and only if the map and key are not null and the map contains the key.

  Parameters:
    `map` - Map to check for given key
    `key` - Key to check for in map
  Returns:
    Returns `true` if and only if the map and key are not null and the map contains the key.

### daysBetweenDates

    public static int daysBetweenDates(java.util.Date startDate,
                                       java.util.Date endDate)

  Return the number of days between two dates

  Parameters:
    `startDate` - Start date
    `endDate` - End date
  Returns:
    Number of days between two dates which may be 0 if either of the dates if `null`

### getFilenameForDate

    public static java.io.File getFilenameForDate(java.lang.String filename)

  Return a filename with the date as a long value before the file extension.

  Parameters:
    `filename` - Filename with extension
  Returns:
    Filename as {filename}-{date}.{file extension} or `null` if there was no file extension

### stripLineTerminators

    public static java.lang.String stripLineTerminators(java.lang.String input)

  Strip line terminator characters from an input string

  Parameters:
    `input` - Input string
  Returns:
    Input with line terminator characters stripped or `null` if the input was `null`

### stripLineTerminators

    public static java.lang.String stripLineTerminators(java.lang.String input,
                                                        java.lang.String replacement)

  Strip line terminator characters from an input string

  Parameters:
    `input` - Input string
    `replacement` - Replacement string
  Returns:
    Input with line terminator characters stripped or `null` if the input was `null`

### getKeysAsStringList

    public static java.lang.String getKeysAsStringList(java.util.Map input)

  Return the keys of a map as a comma-separated list

  Parameters:
    `input` - `Map`
  Returns:
    Keys as a comma-separated list or an empty string if the input is `null` or contains no keys

### listToCSV

    public static java.lang.String listToCSV(java.util.List values)

  Convert a list to a comma-separated string. If values in the list are `null`, a space is printed. If the input is null or there are no items in the list, an empty string is returned.

  Parameters:
    `values` - List of values
  Returns:
    Comma-separated string

### listToMap

    public static java.util.Map listToMap(java.util.List values)

  Convert a list of values to a `Map`. `null` values are not placed in the returned `Map`.

  Parameters:
    `values` - List of values
  Returns:
    `Map` where each key and value pair is from the list of values

### csvToList

    public static java.util.List csvToList(java.lang.String valuesAsString)

  Return a comma-separated list of Strings as a `List`; trims space around value

  Parameters:
    `valuesAsString` - Comma-separated values
  Returns:
    Comma-separated list of Strings as a `List`

### constructBaseURL

    public static java.lang.String constructBaseURL(javax.servlet.http.HttpServletRequest httpServletRequest)

  Construct a blog base URL from the request

  Parameters:
    `httpServletRequest` - Request
  Returns:
    URL of the form `http://server:port/context_path`

### constructBlogURL

    public static java.lang.String constructBlogURL(javax.servlet.http.HttpServletRequest httpServletRequest,
                                                    java.lang.String blogID)

  Construct a blog URL from the request

  Parameters:
    `httpServletRequest` - Request
    `blogID` - Blog ID
  Returns:
    URL of the form `http://server:port/context_path/servlet_path/blog_id/`

### getHashableContent

    public static java.lang.String getHashableContent(java.lang.String content)

  Return a digested string of some content

  Parameters:
    `content` - Content from which to generate a hashed digest
  Returns:
    `digestString(String)`

### getPostSlug

    public static java.lang.String getPostSlug(java.lang.String title,
                                               java.lang.String content)

  Return a filename appropriate for the blog entry content

  Parameters:
    `title` - Blog entry title
    `content` - Blog entry content
  Returns:
    Filename for the new blog entry

### getLocaleFromString

    public static java.util.Locale getLocaleFromString(java.lang.String locale)

  Create a `Locale` object from a string of form `language_country_variant`

  Parameters:
    `locale` - Locale string of form `language_country_variant`
  Returns:
    `Locale` object with language, country, variant settings or `Locale.getDefault()` if `locale` input is `null` or blank

### getLanguagesForSystem

    public static java.lang.String[] getLanguagesForSystem(java.util.Locale locale)

  Return of a list of locale languages supported on this system (JVM)

  Parameters:
    `locale` - `Locale` used for sorting
  Returns:
    List of locale languages supported on this system (JVM)

### getCountriesForSystem

    public static java.lang.String[] getCountriesForSystem(java.util.Locale locale)

  Return of a list of locale countries supported on this system (JVM)

  Parameters:
    `locale` - `Locale` used for sorting
  Returns:
    Return of a list of locale countries supported on this system (JVM)

### getTimeZonesForSystem

    public static java.lang.String[] getTimeZonesForSystem(java.util.Locale locale)

  Return of a list of time zone IDs supported on this system (JVM)

  Parameters:
    `locale` - `Locale` used for sorting
  Returns:
    Return of a list of time zone IDs supported on this system (JVM)

### listFilesInSubdirectories

    public static void listFilesInSubdirectories(java.io.File directory,
                                                 java.lang.String parentDirectory,
                                                 java.util.List files)

  List the files in a sub-directory of a given directory and strip the parent directory from the path of the files added to the list.

  Parameters:
    `directory` - Sub-directory to start looking for files
    `parentDirectory` - Parent directory to strip
    `files` - List of files to add to

### listDirectoriesInSubdirectories

    public static void listDirectoriesInSubdirectories(java.io.File directory,
                                                       java.lang.String parentDirectory,
                                                       java.util.List directories)

  List the sub-directories in a sub-directory of a given directory and strip the parent directory from the path of the directories added to the list.

  Parameters:
    `directory` - Sub-directory to start looking for files
    `parentDirectory` - Parent directory to strip
    `directories` - List of directories to add to

### stripHTML

    public static java.lang.String stripHTML(java.lang.String text)

  Strip all HTML from a given piece of text

  Parameters:
    `text` - Text
  Returns:
    text stripped of HTML between < and > tags or `null` if input was null or blank if input was blank

### arrayToList

    public static java.util.List arrayToList(java.lang.String[] input)

  Convert a `String[]` to a `List`

  Parameters:
    `input` - `String[]`
  Returns:
    `List` from string array

### removeNullValues

    public static java.util.List removeNullValues(java.util.List input)

  Remove `null` values from a given list

  Parameters:
    `input` - List
  Returns:
    List with `null` values removed

### addSlashes

    public static java.lang.String addSlashes(java.lang.String input)

  Add preceeding and trailing slashes to an input string. If input is `null` a "/" is returned.

  Parameters:
    `input` - Input
  Returns:
    Input with preceeding and trailing slashes added

### addTrailingSlash

    public static java.lang.String addTrailingSlash(java.lang.String input)

  Add a trailing slash to the input

  Parameters:
    `input` - Input
  Returns:
    Input with trailing slash added

### resolveDynamicBaseAndBlogURL

    public static void resolveDynamicBaseAndBlogURL(javax.servlet.http.HttpServletRequest httpServletRequest,
                                                    Blog blog,
                                                    java.lang.String blogID)

  Check to see if the blog base URL or blog URL are present. If not, construct them dynamically by calling `constructBaseURL(javax.servlet.http.HttpServletRequest)` and `constructBlogURL(javax.servlet.http.HttpServletRequest, String)`.

  Parameters:
    `httpServletRequest` - Request
    `blog` - `Blog`
    `blogID` - Blog ID

### listToString

    public static java.lang.String listToString(java.util.List values,
                                                java.lang.String separator)

  Return a `List` as a string

  Parameters:
    `values` - `List` of values
    `separator` - Separator in-between values
  Returns:
    `List` as a string where each item is separated by the `separator`

### getFirstDateOfYear

    public static java.util.Date getFirstDateOfYear(java.util.Locale locale,
                                                    int year)

  Find the first date of a year

  Parameters:
    `locale` - Locale
    `year` - Year
  Returns:
    First date of the requested year

### getLastDateOfYear

    public static java.util.Date getLastDateOfYear(java.util.Locale locale,
                                                   int year)

  Find the last date of a year

  Parameters:
    `locale` - Locale
    `year` - Year
  Returns:
    Last date of the requested year

### getFirstDateOfYearMonth

    public static java.util.Date getFirstDateOfYearMonth(java.util.Locale locale,
                                                         int year,
                                                         int month)

  Find the first date of a year/month

  Parameters:
    `locale` - Locale
    `year` - Year
    `month` - Month
  Returns:
    FIrst date of the requested year/month

### getLastDateOfYearMonth

    public static java.util.Date getLastDateOfYearMonth(java.util.Locale locale,
                                                        int year,
                                                        int month)

  Find the last date of a year/month

  Parameters:
    `locale` - Locale
    `year` - Year
    `month` - Month
  Returns:
    Last date of the requested year/month

### getFirstDateOfYearMonthDay

    public static java.util.Date getFirstDateOfYearMonthDay(java.util.Locale locale,
                                                            int year,
                                                            int month,
                                                            int day)

  Get the first date of a year/month/day

  Parameters:
    `locale` - Locale
    `year` - Year
    `month` - Month
    `day` - Day
  Returns:
    First date of the requested year/month/day

### getLastDateOfYearMonthDay

    public static java.util.Date getLastDateOfYearMonthDay(java.util.Locale locale,
                                                           int year,
                                                           int month,
                                                           int day)

  Get the last date of a year/month/day

  Parameters:
    `locale` - Locale
    `year` - Year
    `month` - Month
    `day` - Day
  Returns:
    Last date of the requested year/month/day

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD