public class WebUtil extends Object implements GlobalPropertyListener
Constructor and Description |
---|
WebUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
encodeForCDATA(String s)
Encodes data for an XML CDATA section.
|
static String |
encodeForCssString(String s)
Encodes for CSS strings.
|
static String |
encodeForCssUrl(String s)
Encodes for CSS URL contexts.
|
static String |
encodeForHtmlAttribute(String s)
Encodes for HTML text attributes.
|
static String |
encodeForHtmlContent(String s)
Encodes for HTML text content.
|
static String |
encodeForHtmlUnquotedAttribute(String s)
Encodes for unquoted HTML attribute values.
|
static String |
encodeForJava(String s)
Encodes for a Java string.
|
static String |
encodeForJavaScript(String s)
Encodes for a JavaScript string.
|
static String |
encodeForJavaScriptAttribute(String s)
This method encodes for JavaScript strings contained within HTML script attributes (such as onclick).
|
static String |
encodeForJavaScriptBlock(String s)
Encodes for JavaScript strings contained within HTML script blocks.
|
static String |
encodeForJavaScriptSource(String s)
Encodes for JavaScript strings contained within a JavaScript or JSON file.
|
static String |
encodeForUri(String s)
Performs percent-encoding of a URL according to RFC 3986.
|
static String |
encodeForUriComponent(String s)
Performs percent-encoding for a component of a URI, such as a query parameter name or value, path or query-string.
|
static String |
encodeForXml(String s)
Encodes for XML and XHTML.
|
static String |
encodeForXmlAttribute(String s)
Encodes for XML and XHTML attribute content.
|
static String |
encodeForXmlComment(String s)
Encodes for XML comments.
|
static String |
encodeForXmlContent(String s)
Encodes for XML and XHTML text content.
|
static String |
escapeHTML(String s)
Encodes for (X)HTML text content and text attributes.
|
static String |
escapeNewlines(String s) |
static String |
escapeQuotes(String s) |
static String |
escapeQuotesAndNewlines(String s) |
static String |
formatDate(Date date) |
static String |
formatDate(Date date,
Locale locale,
Format.FORMAT_TYPE type) |
static String |
getContextPath()
Method that returns WebConstants.WEBAPP_NAME or an empty string if WebConstants.WEBAPP_NAME
is empty.
|
void |
globalPropertyChanged(GlobalProperty newValue)
Called after a global property is created or updated
|
void |
globalPropertyDeleted(String propertyName)
Called after a global property is deleted
|
static Locale |
normalizeLocale(String localeString)
This method checks if input locale string contains control characters and tries to clean up
actually contained ones.
|
static String |
sanitizeLocales(String localesString)
Convenient method that parses the given string object, that contains locale parameters which
are separated by comma.
|
static String |
stripFilename(String filename)
Strips out the path from a string if "C:\documents\file.doc", will return "file.doc" if
"file.doc", will return "file.doc" if "/home/file.doc" will return "file.doc"
|
boolean |
supportsPropertyName(String propertyName)
Asks this listener whether it wants to be notified about the given property name
|
public static String escapeHTML(String s)
s
- public static String encodeForCDATA(String s)
s
- public static String encodeForCssString(String s)
s
- public static String encodeForCssUrl(String s)
s
- public static String encodeForHtmlAttribute(String s)
s
- public static String encodeForHtmlContent(String s)
s
- public static String encodeForHtmlUnquotedAttribute(String s)
s
- public static String encodeForJava(String s)
s
- public static String encodeForJavaScript(String s)
s
- public static String encodeForJavaScriptAttribute(String s)
s
- public static String encodeForJavaScriptBlock(String s)
s
- public static String encodeForJavaScriptSource(String s)
s
- public static String encodeForUri(String s)
s
- public static String encodeForUriComponent(String s)
s
- public static String encodeForXml(String s)
s
- public static String encodeForXmlAttribute(String s)
s
- public static String encodeForXmlComment(String s)
s
- public static String encodeForXmlContent(String s)
s
- public static String stripFilename(String filename)
filename
- public static Locale normalizeLocale(String localeString)
localeString
- input string with locale parameterpublic static String sanitizeLocales(String localesString)
localesString
- input string with locale parameters separeted by comma (e.g.
"en, fr_RW, gh")Should skip over invalid locales
Should not fail with empty string
public static String getContextPath()
public static String formatDate(Date date, Locale locale, Format.FORMAT_TYPE type)
public boolean supportsPropertyName(String propertyName)
GlobalPropertyListener
supportsPropertyName
in interface GlobalPropertyListener
GlobalPropertyListener.supportsPropertyName(java.lang.String)
public void globalPropertyChanged(GlobalProperty newValue)
GlobalPropertyListener
globalPropertyChanged
in interface GlobalPropertyListener
newValue
- the new value of the property that was just savedGlobalPropertyListener.globalPropertyChanged(org.openmrs.GlobalProperty)
public void globalPropertyDeleted(String propertyName)
GlobalPropertyListener
globalPropertyDeleted
in interface GlobalPropertyListener
propertyName
- the name of the property that was just deletedGlobalPropertyListener.globalPropertyDeleted(java.lang.String)
Copyright © 2024 OpenMRS Inc.. All rights reserved.