| java.lang.Object org.sakaiproject.util.Validator
Validator | public class Validator (Code) | |
Validator is utility class that helps to validate stuff.
|
Method Summary | |
public static boolean | checkDate(int day, int month, int year) | public static boolean | checkEmailLocal(String id) | public static boolean | checkResourceId(String id) Check for a valid resource id. | public static boolean | checkUserId(String id) Check for a valid user id. | public static String | cleanInput(String value) Clean the user input string of strange newlines, etc.
Parameters: value - The user input string. | public static String | escapeHtml(String value) Escape a plaintext string so that it can be output as part of an HTML document. | public static String | escapeHtmlFixCopyright(String value) escapeHtml(), but also fix the case where we start with © and treat it as copyright (c) Note: ResourcesAction used to (before 1.1.05) place this as the copyright symbol. | public static String | escapeHtmlFormattedText(String value) Escape HTML-formatted text in preparation to include it in an HTML document. | public static String | escapeHtmlFormattedTextSupressNewlines(String value) Escape HTML-formatted text in preparation to include it in an HTML document, except that HTML line breaks ("<br />") will be supressed (removed). | public static String | escapeHtmlFormattedTextarea(String value) Escapes the given HTML-formatted text for editing within the WYSIWYG editor. | public static String | escapeHtmlSupressNewlines(String value) Escape a plaintext string so that it can be output as part of an HTML document, except that newlines are NOT escaped and therefore are treated as whitespace instead of displaying as line-breaks. | public static String | escapeHtmlTextarea(String value) Escape plaintext for display inside a plain textarea. | public static String | escapeJavascript(String value) Return a string based on value that is safe to place into a javascript / html identifier: anything not alphanumeric change to 'x'. | public static String | escapeJsQuoted(String value) Return a string based on value that is safe to place into a javascript value that is in single quiotes.
Parameters: value - The string to escape. | public static String | escapeQuestionMark(String id) Return a string based on id that is fully escaped the question mark.
Parameters: id - The string to escape. | public static String | escapeResourceName(String id) Return a string based on id that is fully escaped using Resource name validity rules.
Parameters: id - The string to escape. | public static String | escapeSql(String value) Return a string based on value that is safe to place into a sql statement: sql statements use the single quote, and this must be doubled as an escape.
Parameters: value - The string to escape. | public static String | escapeUrl(String id) Return a string based on id that is fully escaped using URL rules, using a UTF-8 underlying encoding.
Parameters: id - The string to escape. | public static String | escapeZipEntry(String id) Return a string based on id that is fully escaped to create a zip entry
Parameters: id - The string to escape. | public static String | getFileExtension(String fullName) Isolate and return just the file extension part of a full drive and path file name. | public static String | getFileName(String fullName) Isolate and return just the file name part of a full drive and path file name. | public static String | getFileSizeWithDividor(String size) | public static String | getResourceTarget(String contentType) Determine whether a file resource should be opened in the current window or a new window. | public static boolean | letBrowserInline(String type) Is this a mime type that the browser can handle inline, in a browser window? If so, links to this type should be to a _blank, and content-disposition should be inline. | public static String | limit(String value, Integer length) Limit the string to a certain number of characters, adding "..." if it was truncated.
Parameters: value - The string to limit. Parameters: the - length to limit to (as an Integer). | public static String | limit(String value, int length) Limit the string to a certain number of characters, adding "..." if it was truncated
Parameters: value - The string to limit. Parameters: the - length to limit to (as an int). | public static String | limitFormattedText(String value, int length) Limit the formatted to a certain number of DISPLAYED characters, adding "..." if it was truncated. | public static String | stripAllNewlines(String value) Clean the string parameter of all newlines (replace with space character) and trim leading and trailing spaces
Parameters: value - The user input string. |
ESCAPE_CHARS_IN_RESOURCE_ID | final protected static String ESCAPE_CHARS_IN_RESOURCE_ID(Code) | | These characters are allowed; but if escapeResourceName() is called, they are escaped (actually, removed) Certain characters cause problems with filenames in certain OSes - so get rid of these characters in filenames
|
ESCAPE_URL | final protected static String ESCAPE_URL(Code) | | These characters are escaped when making a URL
|
ESCAPE_URL_SPECIAL | final protected static String ESCAPE_URL_SPECIAL(Code) | | These can't be encoded in URLs safely even using %nn notation, so encode them using our own custom URL encoding, which the ParameterParser decodes
|
INVALID_CHARS_IN_RESOURCE_ID | final public static String INVALID_CHARS_IN_RESOURCE_ID(Code) | | These characters are not allowed in a resource id
|
INVALID_CHARS_IN_USER_ID | final protected static String INVALID_CHARS_IN_USER_ID(Code) | | These characters are not allowed in a user id
|
INVALID_CHARS_IN_ZIP_ENTRY | final protected static String INVALID_CHARS_IN_ZIP_ENTRY(Code) | | |
VALID_EMAIL | final protected static String VALID_EMAIL(Code) | | Valid special email local id characters (- those that are invalid resource ids)
|
checkDate | public static boolean checkDate(int day, int month, int year)(Code) | | Validate whether the date input is valid
|
checkEmailLocal | public static boolean checkEmailLocal(String id)(Code) | | Is this a valid local part of an email id?
|
checkResourceId | public static boolean checkResourceId(String id)(Code) | | Check for a valid resource id.
true if valid, false if not |
cleanInput | public static String cleanInput(String value)(Code) | | Clean the user input string of strange newlines, etc.
Parameters: value - The user input string. value cleaned of string newlines, etc. |
escapeHtml | public static String escapeHtml(String value)(Code) | | Escape a plaintext string so that it can be output as part of an HTML document. Amperstand, greater-than, less-than, newlines, etc, will be escaped so that they display (instead of being interpreted as formatting).
Parameters: value - The string to escape. value fully escaped for HTML. |
escapeHtmlFixCopyright | public static String escapeHtmlFixCopyright(String value)(Code) | | escapeHtml(), but also fix the case where we start with © and treat it as copyright (c) Note: ResourcesAction used to (before 1.1.05) place this as the copyright symbol. -ggolden
|
escapeHtmlFormattedText | public static String escapeHtmlFormattedText(String value)(Code) | | Escape HTML-formatted text in preparation to include it in an HTML document.
|
escapeHtmlFormattedTextSupressNewlines | public static String escapeHtmlFormattedTextSupressNewlines(String value)(Code) | | Escape HTML-formatted text in preparation to include it in an HTML document, except that HTML line breaks ("<br />") will be supressed (removed).
|
escapeHtmlFormattedTextarea | public static String escapeHtmlFormattedTextarea(String value)(Code) | | Escapes the given HTML-formatted text for editing within the WYSIWYG editor. All HTML meta-characters in the string (such as amperstand, less-than, etc), will be escaped.
Parameters: value - The formatted text to escape The string to use as the value of the formatted textarea widget |
escapeHtmlSupressNewlines | public static String escapeHtmlSupressNewlines(String value)(Code) | | Escape a plaintext string so that it can be output as part of an HTML document, except that newlines are NOT escaped and therefore are treated as whitespace instead of displaying as line-breaks. Amperstand, greater-than, less-than, etc, will be
escaped so that they display (instead of being interpreted as formatting).
Parameters: value - The string to escape. value fully escaped for HTML. |
escapeHtmlTextarea | public static String escapeHtmlTextarea(String value)(Code) | | Escape plaintext for display inside a plain textarea.
|
escapeJavascript | public static String escapeJavascript(String value)(Code) | | Return a string based on value that is safe to place into a javascript / html identifier: anything not alphanumeric change to 'x'. If the first character is not alphabetic, a letter 'i' is prepended.
Parameters: value - The string to escape. value fully escaped using javascript / html identifier rules. |
escapeJsQuoted | public static String escapeJsQuoted(String value)(Code) | | Return a string based on value that is safe to place into a javascript value that is in single quiotes.
Parameters: value - The string to escape. value escaped. |
escapeQuestionMark | public static String escapeQuestionMark(String id)(Code) | | Return a string based on id that is fully escaped the question mark.
Parameters: id - The string to escape. id fully escaped question mark. |
escapeResourceName | public static String escapeResourceName(String id)(Code) | | Return a string based on id that is fully escaped using Resource name validity rules.
Parameters: id - The string to escape. id fully escaped using Resource name validity rules. |
escapeSql | public static String escapeSql(String value)(Code) | | Return a string based on value that is safe to place into a sql statement: sql statements use the single quote, and this must be doubled as an escape.
Parameters: value - The string to escape. value escaped. |
escapeUrl | public static String escapeUrl(String id)(Code) | | Return a string based on id that is fully escaped using URL rules, using a UTF-8 underlying encoding.
Parameters: id - The string to escape. id fully escaped using URL rules. |
escapeZipEntry | public static String escapeZipEntry(String id)(Code) | | Return a string based on id that is fully escaped to create a zip entry
Parameters: id - The string to escape. id fully escaped to create a zip entry |
getFileExtension | public static String getFileExtension(String fullName)(Code) | | Isolate and return just the file extension part of a full drive and path file name.
Parameters: fullName - The full file name from a local os file system (mac, unix, windoze) Just the extension of the file, to the right of the dot, not including the dot, or blank if none. |
getFileName | public static String getFileName(String fullName)(Code) | | Isolate and return just the file name part of a full drive and path file name.
Parameters: fullName - The full file name from a local os file system (mac, unix, windoze) Just the name (and extension) of the file, without the drive or path. |
getFileSizeWithDividor | public static String getFileSizeWithDividor(String size)(Code) | | Put the dividor (comma) inside the size string, for example, 1,003 for 1003
Parameters: size - The string of size number The size string with the dividor added |
getResourceTarget | public static String getResourceTarget(String contentType)(Code) | | Determine whether a file resource should be opened in the current window or a new window.
Parameters: contentType - The content type to check A string identifying the window in which to open the resource: "_self" to open the resource in the current window, "_blank" for a new window, or an empty string if the resource is not a file. |
letBrowserInline | public static boolean letBrowserInline(String type)(Code) | | Is this a mime type that the browser can handle inline, in a browser window? If so, links to this type should be to a _blank, and content-disposition should be inline. If not, links to this type should be to _self, and content-disposition should be
attachment.
Parameters: type - The mime type to check. true if this type of resource the browser can handle in line, false if not. |
limit | public static String limit(String value, Integer length)(Code) | | Limit the string to a certain number of characters, adding "..." if it was truncated.
Parameters: value - The string to limit. Parameters: the - length to limit to (as an Integer). The limited string. |
limit | public static String limit(String value, int length)(Code) | | Limit the string to a certain number of characters, adding "..." if it was truncated
Parameters: value - The string to limit. Parameters: the - length to limit to (as an int). The limited string. |
limitFormattedText | public static String limitFormattedText(String value, int length)(Code) | | Limit the formatted to a certain number of DISPLAYED characters, adding "..." if it was truncated. For example, trim("Hello \nWorld!", 7) returns "Hello \nW..."
Parameters: value - The formatted text to limit. Parameters: the - length to limit to (as an int). The limited string. |
stripAllNewlines | public static String stripAllNewlines(String value)(Code) | | Clean the string parameter of all newlines (replace with space character) and trim leading and trailing spaces
Parameters: value - The user input string. value cleaned of newlines, etc. |
|
|