imcode.util
Class Utility

java.lang.Object
  extended by imcode.util.Utility

public class Utility
extends java.lang.Object


Field Summary
static org.apache.commons.dbutils.ResultSetHandler SINGLE_STRING_HANDLER
           
static org.apache.commons.dbutils.ResultSetHandler STRING_ARRAY_ARRAY_HANDLER
           
static org.apache.commons.dbutils.ResultSetHandler STRING_ARRAY_HANDLER
           
 
Method Summary
static java.util.Date addDate(java.util.Date date, int i)
           
static boolean classIsSignedByCertificatesInKeyStore(java.lang.Class clazz, java.security.KeyStore keyStore)
           
static java.util.Collection collectImageDirectories()
           
static int compareDatesWithNullFirst(java.util.Date date1, java.util.Date date2)
           
static int[] convertStringArrayToIntArray(java.lang.String[] strings)
           
static java.lang.String createQueryStringFromParameterMultiMap(org.apache.commons.collections.MultiMap requestParameters)
           
static java.lang.String escapeUrl(java.lang.String imageUrl)
           
static java.lang.String fallbackUrlDecode(java.lang.String input, FallbackDecoder fallbackDecoder)
           
static java.lang.Object findMatch(org.apache.commons.collections.Factory factory, org.apache.commons.collections.Predicate predicate)
           
static java.lang.Object firstElementOfSetByOrderOf(java.util.Set set, java.util.Comparator comparator)
           
static java.lang.String formatDate(java.util.Date oneWeekAgo)
           
static java.lang.String formatHtmlDatetime(java.util.Date datetime)
           
static java.lang.String formatUser(UserDomainObject user)
           
static void forwardToLogin(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
static java.lang.String getAbsolutePathToDocument(javax.servlet.http.HttpServletRequest request, DocumentDomainObject document)
           
static ContentManagementSystem getContentManagementSystemFromRequest(javax.servlet.ServletRequest request)
           
static java.lang.String getContents(java.lang.String path, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
static java.lang.String getContextRelativePathToDocument(DocumentDomainObject document)
           
static java.lang.String getContextRelativePathToDocumentWithName(java.lang.String name)
           
static java.lang.Integer getInteger(java.lang.Object object)
           
static UserDomainObject getLoggedOnUser(javax.servlet.http.HttpServletRequest req)
           
static java.util.Map getMapViewOfObjectPairArray(java.lang.Object[][] array)
           
static int[] getParameterInts(javax.servlet.http.HttpServletRequest request, java.lang.String parameterName)
           
static java.lang.String[] getParameterValues(javax.servlet.http.HttpServletRequest request, java.lang.String parameterName)
           
static java.lang.String getRequestURLWithoutPath(javax.servlet.http.HttpServletRequest request)
           
static java.util.ResourceBundle getResourceBundle(javax.servlet.http.HttpServletRequest request)
           
static ContentManagementSystem initRequestWithApi(javax.servlet.ServletRequest request, UserDomainObject currentUser)
           
static java.lang.String ipLongToString(long ip)
          Transforms a long containing an ip into a String.
static long ipStringToLong(java.lang.String ip)
          Transforms a String containing an ip into a long.
static boolean isValidEmail(java.lang.String email)
           
static java.lang.String makeSqlStringFromDate(java.util.Date date)
           
static void makeUserLoggedIn(javax.servlet.http.HttpServletRequest req, UserDomainObject user)
           
static void makeUserLoggedOut(javax.servlet.http.HttpServletRequest req)
           
static java.lang.String numberToAlphaNumerics(long identityHashCode)
           
static void outputXmlDocument(javax.servlet.http.HttpServletResponse response, org.w3c.dom.Document xmlDocument)
           
static boolean parameterIsSet(javax.servlet.http.HttpServletRequest request, java.lang.String parameter)
           
static java.util.Date parseDateFormat(java.text.DateFormat dateFormat, java.lang.String dateString)
           
static void redirectToStartDocument(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
static void removeNullValuesFromMap(java.util.Map map)
           
static void setDefaultHtmlContentType(javax.servlet.http.HttpServletResponse res)
           
static void setNoCache(javax.servlet.http.HttpServletResponse res)
          Make a HttpServletResponse non-cacheable
static boolean throwableContainsMessageContaining(java.lang.Throwable t, java.lang.String s)
           
static java.util.Date truncateDateToMinutePrecision(java.util.Date fieldValue)
           
static void writeXmlDocument(org.w3c.dom.Document xmlDocument, javax.xml.transform.stream.StreamResult streamResult)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SINGLE_STRING_HANDLER

public static final org.apache.commons.dbutils.ResultSetHandler SINGLE_STRING_HANDLER

STRING_ARRAY_HANDLER

public static final org.apache.commons.dbutils.ResultSetHandler STRING_ARRAY_HANDLER

STRING_ARRAY_ARRAY_HANDLER

public static final org.apache.commons.dbutils.ResultSetHandler STRING_ARRAY_ARRAY_HANDLER
Method Detail

ipLongToString

public static java.lang.String ipLongToString(long ip)
Transforms a long containing an ip into a String.


ipStringToLong

public static long ipStringToLong(java.lang.String ip)
                           throws java.lang.IllegalArgumentException
Transforms a String containing an ip into a long.

Throws:
java.lang.IllegalArgumentException - if the input is not a valid IPv4 address.

setNoCache

public static void setNoCache(javax.servlet.http.HttpServletResponse res)
Make a HttpServletResponse non-cacheable


getLoggedOnUser

public static UserDomainObject getLoggedOnUser(javax.servlet.http.HttpServletRequest req)

compareDatesWithNullFirst

public static int compareDatesWithNullFirst(java.util.Date date1,
                                            java.util.Date date2)

setDefaultHtmlContentType

public static void setDefaultHtmlContentType(javax.servlet.http.HttpServletResponse res)

redirectToStartDocument

public static void redirectToStartDocument(javax.servlet.http.HttpServletRequest req,
                                           javax.servlet.http.HttpServletResponse res)
                                    throws java.io.IOException
Throws:
java.io.IOException

isValidEmail

public static boolean isValidEmail(java.lang.String email)

removeNullValuesFromMap

public static void removeNullValuesFromMap(java.util.Map map)

createQueryStringFromParameterMultiMap

public static java.lang.String createQueryStringFromParameterMultiMap(org.apache.commons.collections.MultiMap requestParameters)

collectImageDirectories

public static java.util.Collection collectImageDirectories()

firstElementOfSetByOrderOf

public static java.lang.Object firstElementOfSetByOrderOf(java.util.Set set,
                                                          java.util.Comparator comparator)

parameterIsSet

public static boolean parameterIsSet(javax.servlet.http.HttpServletRequest request,
                                     java.lang.String parameter)

getParameterInts

public static int[] getParameterInts(javax.servlet.http.HttpServletRequest request,
                                     java.lang.String parameterName)

convertStringArrayToIntArray

public static int[] convertStringArrayToIntArray(java.lang.String[] strings)

getContents

public static java.lang.String getContents(java.lang.String path,
                                           javax.servlet.http.HttpServletRequest request,
                                           javax.servlet.http.HttpServletResponse response)
                                    throws javax.servlet.ServletException,
                                           java.io.IOException
Throws:
javax.servlet.ServletException
java.io.IOException

formatDate

public static java.lang.String formatDate(java.util.Date oneWeekAgo)

formatUser

public static java.lang.String formatUser(UserDomainObject user)

getAbsolutePathToDocument

public static java.lang.String getAbsolutePathToDocument(javax.servlet.http.HttpServletRequest request,
                                                         DocumentDomainObject document)

getContextRelativePathToDocument

public static java.lang.String getContextRelativePathToDocument(DocumentDomainObject document)

getContextRelativePathToDocumentWithName

public static java.lang.String getContextRelativePathToDocumentWithName(java.lang.String name)

formatHtmlDatetime

public static java.lang.String formatHtmlDatetime(java.util.Date datetime)

forwardToLogin

public static void forwardToLogin(javax.servlet.http.HttpServletRequest request,
                                  javax.servlet.http.HttpServletResponse response)
                           throws javax.servlet.ServletException,
                                  java.io.IOException
Throws:
javax.servlet.ServletException
java.io.IOException

getParameterValues

public static java.lang.String[] getParameterValues(javax.servlet.http.HttpServletRequest request,
                                                    java.lang.String parameterName)

truncateDateToMinutePrecision

public static java.util.Date truncateDateToMinutePrecision(java.util.Date fieldValue)

getRequestURLWithoutPath

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

throwableContainsMessageContaining

public static boolean throwableContainsMessageContaining(java.lang.Throwable t,
                                                         java.lang.String s)

classIsSignedByCertificatesInKeyStore

public static boolean classIsSignedByCertificatesInKeyStore(java.lang.Class clazz,
                                                            java.security.KeyStore keyStore)

getMapViewOfObjectPairArray

public static java.util.Map getMapViewOfObjectPairArray(java.lang.Object[][] array)

makeSqlStringFromDate

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

parseDateFormat

public static java.util.Date parseDateFormat(java.text.DateFormat dateFormat,
                                             java.lang.String dateString)

findMatch

public static java.lang.Object findMatch(org.apache.commons.collections.Factory factory,
                                         org.apache.commons.collections.Predicate predicate)

numberToAlphaNumerics

public static java.lang.String numberToAlphaNumerics(long identityHashCode)

getInteger

public static java.lang.Integer getInteger(java.lang.Object object)

escapeUrl

public static java.lang.String escapeUrl(java.lang.String imageUrl)

addDate

public static java.util.Date addDate(java.util.Date date,
                                     int i)

outputXmlDocument

public static void outputXmlDocument(javax.servlet.http.HttpServletResponse response,
                                     org.w3c.dom.Document xmlDocument)
                              throws java.io.IOException
Throws:
java.io.IOException

writeXmlDocument

public static void writeXmlDocument(org.w3c.dom.Document xmlDocument,
                                    javax.xml.transform.stream.StreamResult streamResult)

makeUserLoggedIn

public static void makeUserLoggedIn(javax.servlet.http.HttpServletRequest req,
                                    UserDomainObject user)

makeUserLoggedOut

public static void makeUserLoggedOut(javax.servlet.http.HttpServletRequest req)

initRequestWithApi

public static ContentManagementSystem initRequestWithApi(javax.servlet.ServletRequest request,
                                                         UserDomainObject currentUser)

getContentManagementSystemFromRequest

public static ContentManagementSystem getContentManagementSystemFromRequest(javax.servlet.ServletRequest request)

fallbackUrlDecode

public static java.lang.String fallbackUrlDecode(java.lang.String input,
                                                 FallbackDecoder fallbackDecoder)

getResourceBundle

public static java.util.ResourceBundle getResourceBundle(javax.servlet.http.HttpServletRequest request)