Modifier and Type | Method and Description |
---|---|
static String |
decode(String s)
Url decodes a string encoded in UTF-8.
|
static String |
encode(String s)
Url encodes a string in UTF-8.
|
static String |
encodeAndEscapeHTML(String input)
Encode a string for use in a URL, then escape characters that must be escaped in HTML.
|
static String |
escapeHtmlValues(String input)
Escapes HTML special characters ", &, < and > (but not ').
|
static String |
escapeJavascriptQuotes(String input)
Escapes a string for use in javascript.
|
static void |
forwardOnEmptyParameter(javax.servlet.jsp.PageContext context,
String... parameters)
Checks that the given parameters exist and are not empty.
|
static void |
forwardOnIllegalParameter(javax.servlet.jsp.PageContext context,
String parameter,
String... legalValues)
Checks that the given parameter exists and is one of a set of values.
|
static void |
forwardOnMissingParameter(javax.servlet.jsp.PageContext context,
String... parameters)
Checks that the given parameters exist.
|
static void |
forwardWithErrorMessage(javax.servlet.jsp.PageContext context,
I18n I18N,
String label,
Object... args)
Forward to our standard error message page with an internationalized message.
|
static void |
forwardWithErrorMessage(javax.servlet.jsp.PageContext context,
I18n i18n,
Throwable e,
String label,
Object... args)
Forward to our standard error message page with an internationalized message, in case of exception.
|
static void |
forwardWithRawErrorMessage(javax.servlet.jsp.PageContext context,
I18n i18n,
String label,
Object... args)
Forward to our standard error message page with an internationalized message.
|
static void |
generateFooter(javax.servlet.jsp.JspWriter out)
Writes out footer information to close the page.
|
static void |
generateHeader(javax.servlet.jsp.PageContext context)
Prints the header information for the webpages in the GUI.
|
static void |
generateHeader(javax.servlet.jsp.PageContext context,
long refreshInSeconds)
Prints the header information for the webpages in the GUI.
|
static void |
generateHeader(javax.servlet.jsp.PageContext context,
String... jsToInclude)
Prints the header information for the webpages in the GUI.
|
static void |
generateHeader(String title,
long refreshInSeconds,
javax.servlet.jsp.PageContext context)
Prints the header information for the webpages in the GUI.
|
static void |
generateHeader(String title,
javax.servlet.jsp.PageContext context,
String... jsToInclude)
Prints the header information for the webpages in the GUI.
|
static String |
getLocale(javax.servlet.http.HttpServletRequest request)
Get a locale from cookie, if present.
|
static Locale |
getLocaleObject(javax.servlet.jsp.PageContext context)
Get the locale according to header context information.
|
static String |
getRowClass(int rowCount)
Get the (CSS) class name for a row in a table.
|
static String |
getTitle(String url,
Locale locale)
Given a URL in the sitesection hierarchy, returns the corresponding page title.
|
static String |
localiseLong(long i,
Locale locale)
Create a localized string representation of the given long.
|
static String |
localiseLong(long i,
javax.servlet.jsp.PageContext context)
Create a localized string representation of the given long.
|
static String |
makeDate(Date d)
Deprecated.
Please use
|
static String |
makeTableElement(String s)
Create a table element containing the given string, escaping HTML values in the process.
|
static String |
makeTableHeader(String contents)
Create a table header element containing the given string, escaping HTML values in the process.
|
static String |
makeTableRow(String... contents)
Create a table row.
|
static String |
nullToHyphen(Object o)
Returns the toString() value of an object or a hyphen if the argument is null.
|
static int |
parseAndCheckInteger(javax.servlet.jsp.PageContext context,
String param,
int minValue,
int maxValue)
Parses a integer request parameter and checks that it lies within a given interval.
|
static String |
parseDate(Date timestamp)
Parse Date to be displayed in 24 Hour format.
|
static Long |
parseLong(Locale loc,
String paramValue,
String parameterName,
Long defaultValue)
Parse a given String for a long value.
|
static boolean |
parseOptionalBoolean(javax.servlet.jsp.PageContext context,
String param,
boolean defaultValue)
Parse an optionally present boolean from a request parameter.
|
static Date |
parseOptionalDate(javax.servlet.jsp.PageContext context,
String param,
String format,
Date defaultValue)
Parse an optionally present date-value from a request parameter.
|
static Long |
parseOptionalLong(javax.servlet.jsp.PageContext context,
String param,
Long defaultValue)
Parse an optionally present long-value from a request parameter.
|
static void |
setUTF8(javax.servlet.http.HttpServletRequest request)
Sets the character encoding for reading parameters and content from a request in a JSP page.
|
public static String encode(String s)
s
- the string to encodepublic static String decode(String s)
s
- the string to decodepublic static void generateHeader(javax.servlet.jsp.PageContext context) throws IOException
context
- The context of the web page request.IOException
- if an error occurs during writing of output.public static void generateHeader(javax.servlet.jsp.PageContext context, String... jsToInclude) throws IOException
context
- The context of the web page request.IOException
- if an error occurs during writing of output.public static void generateHeader(javax.servlet.jsp.PageContext context, long refreshInSeconds) throws IOException
context
- The context of the web page request.refreshInSeconds
- auto-refresh time in secondsIOException
- if an error occurs during writing of output.public static void generateHeader(String title, javax.servlet.jsp.PageContext context, String... jsToInclude) throws IOException
title
- An internationalised title of the page.context
- The context of the web page request.jsToInclude
- path(s) to external .js files to include in header.IOException
- if an error occurs during writing to output.public static void generateHeader(String title, long refreshInSeconds, javax.servlet.jsp.PageContext context) throws IOException
title
- An internationalised title of the page.context
- The context of the web page request.refreshInSeconds
- auto-refresh time in secondsIOException
- if an error occurs during writing to output.public static Locale getLocaleObject(javax.servlet.jsp.PageContext context)
context
- The context of the web page request.public static void generateFooter(javax.servlet.jsp.JspWriter out) throws IOException
out
- the writer to which the information is writtenIOException
- if the output cannot be writtenpublic static String makeTableElement(String s)
s
- An unescaped string. Any HTML tags in this string will end up escaped away.public static String makeTableHeader(String contents)
contents
- An unescaped string. Any HTML tags in this string will end up escaped away.public static String makeTableRow(String... contents)
contents
- The contents to put into the table row. The entries will be delimited by newline characters.public static String makeDate(Date d)
d
- A datepublic static String nullToHyphen(Object o)
o
- the given objectpublic static String escapeHtmlValues(String input)
input
- a stringpublic static String encodeAndEscapeHTML(String input)
input
- A stringpublic static String escapeJavascriptQuotes(String input)
input
- a stringpublic static void setUTF8(javax.servlet.http.HttpServletRequest request)
request
- The servlet request objectpublic static String getTitle(String url, Locale locale)
url
- a given URLlocale
- the current localeArgumentNotValid
- if the given url or locale is null or url is empty.public static String getRowClass(int rowCount)
rowCount
- The number of the rowpublic static String getLocale(javax.servlet.http.HttpServletRequest request)
request
- The request to get the locale for.public static void forwardWithErrorMessage(javax.servlet.jsp.PageContext context, I18n I18N, String label, Object... args)
context
- The context that the error happened in (the JSP-defined pageContext, typically)I18N
- The i18n informationlabel
- An i18n label for the error. This label should begin with "errormsg;".args
- Any extra args for i18nIOFailure
- If the forward failspublic static void forwardWithRawErrorMessage(javax.servlet.jsp.PageContext context, I18n i18n, String label, Object... args)
context
- The context that the error happened in (the JSP-defined pageContext, typically)i18n
- The i18n informationlabel
- An i18n label for the error. This label should begin with "errormsg;".args
- Any extra args for i18n. These must be valid HTML.IOFailure
- If the forward fails.public static void forwardWithErrorMessage(javax.servlet.jsp.PageContext context, I18n i18n, Throwable e, String label, Object... args)
context
- The context that the error happened in (the JSP-defined pageContext, typically)i18n
- The i18n informatione
- The exception that is being handled.label
- An i18n label for the error. This label should begin with "errormsg;".args
- Any extra args for i18nIOFailure
- If the forward failspublic static void forwardOnMissingParameter(javax.servlet.jsp.PageContext context, String... parameters) throws ForwardedToErrorPage
context
- The context of the current JSP pageparameters
- List of parameters that must existIOFailure
- If the forward failsForwardedToErrorPage
- If a parameter is missingpublic static void forwardOnEmptyParameter(javax.servlet.jsp.PageContext context, String... parameters)
context
- The context of the current JSP pageparameters
- List of parameters that must exist and be non-emptyIOFailure
- If the forward failsForwardedToErrorPage
- if a parameter was missing or emptypublic static void forwardOnIllegalParameter(javax.servlet.jsp.PageContext context, String parameter, String... legalValues) throws ForwardedToErrorPage
context
- The context of the current JSP pageparameter
- parameter that must existlegalValues
- legal values for the parameterIOFailure
- If the forward failsForwardedToErrorPage
- if the parameter is none of the given valuespublic static int parseAndCheckInteger(javax.servlet.jsp.PageContext context, String param, int minValue, int maxValue) throws ForwardedToErrorPage
context
- The context this call happens inparam
- A parameter to parse.minValue
- The minimum allowed valuemaxValue
- The maximum allowed valueForwardedToErrorPage
- if the parameter doesn't exist, is not a parseable integer, or doesn't lie within
the limits.public static Long parseOptionalLong(javax.servlet.jsp.PageContext context, String param, Long defaultValue)
context
- The context of the web request.param
- The name of the parameter to parse.defaultValue
- A value to return if the parameter is not present (may be null).ForwardedToErrorPage
- if the parameter is present but not parseable as a long value.public static Date parseOptionalDate(javax.servlet.jsp.PageContext context, String param, String format, Date defaultValue)
context
- The context of the web request.param
- The name of the parameter to parseformat
- The format of the date, in the format defined by SimpleDateFormatdefaultValue
- A value to return if the parameter is not present (may be null)ForwardedToErrorPage
- if the parameter is present but not parseable as a datepublic static boolean parseOptionalBoolean(javax.servlet.jsp.PageContext context, String param, boolean defaultValue)
context
- The context of the web request.param
- The name of the parameter to parsedefaultValue
- A value to return if the parameter is not present (may be null)public static String localiseLong(long i, javax.servlet.jsp.PageContext context)
i
- A long integercontext
- The given JSP contextpublic static String localiseLong(long i, Locale locale)
i
- A long integerlocale
- The given locale.public static Long parseLong(Locale loc, String paramValue, String parameterName, Long defaultValue)
loc
- The given Locale.paramValue
- The given parameter valueparameterName
- The given parameter name (used for debugging)defaultValue
- The default value for the parameter, in case the string cannot be parsedCopyright © 2005–2016 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.