|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.arsdigita.acs.Utilities
Utility procedures for ACS.
Constructor Summary | |
Utilities()
|
Method Summary | |
static void |
copyFile(File src,
File dest)
|
static boolean |
emailValidP(String email)
|
static boolean |
emptyString(String s)
|
static String |
exportFormValue(String val)
Returns "value="form_value"", URL-encoded appropriately for inclusion in an HTML form. |
static String |
exportFormVar(String key,
String value)
Exports a single variable for use in a form, as input type=hidden. |
static String |
exportFormVars(AdSet vars)
Exports variables for use in a form, as input type=hidden. |
static String |
exportFormVars(AdSet vars,
String exclusionList)
Exports variables for use in a form, as input type=hidden. |
static String |
exportFormVars(DataSource ds,
String vars)
Exports variables for use in a form, as input type=hidden |
static String |
exportFormVars(HttpServletRequest req,
String vars)
|
static String |
exportFormVars(ResultSet rs,
String vars)
Exports variables for use in a form, as hidden input fields. |
static String |
exportURLVars(AdSet vars)
Exports variables for use in a URL, as name=value&name=value... |
static String |
exportURLVars(AdSet vars,
String exclusionList)
Exports variables for use in a URL, as name=value&name=value... |
static String |
exportURLVars(DataSource ds,
String vars)
Exports variables for use in a URL, as name=value&name=value..., |
static String |
exportURLVars(HttpServletRequest req,
String vars)
Exports variables for use in a URL, as name=value&name=value..., |
static String |
exportURLVars(ResultSet rs,
String vars)
Exports variables for use in a URL, as name=value&name=value... |
static String |
exportVars(DataSource ds,
String vars,
boolean form)
Exports variables for use in a URL, as name=value&name=value..., or in a form (input type=hidden name=... |
static String |
exportVars(HttpServletRequest req,
String vars,
boolean form)
Exports variables for use in a URL, as name=value&name=value..., or in a form (input type=hidden name=... |
static String |
generateRandomString()
|
static String |
generateRandomString(int u)
|
static String |
getCookieValue(HttpServletRequest request,
String withName)
Returns a cookie value as a String, given a cookie name. |
static String |
htmlToText(String s)
Removes tags and substitutes P tags with newlines. |
static boolean |
isNumber(String s)
Return true if the input string looks like a number. |
static String |
join(Object[] o,
String s)
Converts an array to a String joined on another String. |
static String |
join(Vector v,
String s)
Converts a java.util.Vector to a String joined on
another String. |
static String |
maybeHtmlToText(String s,
String html_p)
|
static String |
prettyBoolean(Object in)
|
static String |
quoteHtml(String s)
Quotes "special" characters in HTML text (ampersand, angle brackets, quote). |
static void |
removeDups(Vector v)
Removes duplicate entries from a Vector. |
static String |
secDigestString(String str)
Digests a string into eight ASCII characters (horribly insecurely). |
static char |
secRandomChar()
Generates a single random character. |
static String |
secRandomToken()
Generates a random token, using the TokenLength as the token length. |
static void |
sendMail(String to,
String from,
String subject,
String body)
Sends a single e-mail message; analogous to ns_sendmail. |
static void |
sendRedirect(HttpServletResponse response,
String location)
Analogous to HttpServletResponse.sendRedirect(), but necessary for redirecting if there have been any headers set (such as cookie headers), since (in at least the Tomcat implementation) sendRedirect() ignores any header objects attached to the response. |
static String |
textToHtml(String s)
Takes a plaintext string, and returns an HTML string that, when rendered by a web browser, will appear as the original input string |
static String |
URLDecode(String str)
This method decodes the given urlencoded string. |
static String |
URLEncode(String s)
URL-encodes a string. |
static boolean |
URLValidP(String queryURL)
|
Methods inherited from class java.lang.Object |
|
Constructor Detail |
public Utilities()
Method Detail |
public static final String quoteHtml(String s)
s
- The string to quotepublic static final String textToHtml(String s)
s
- The input plaintext stringand ampersands/angle brackets escaped.
public static final String htmlToText(String s)
public static final String maybeHtmlToText(String s, String html_p)
public static final String exportFormVars(AdSet vars)
vars
- An AdSet
of variable names and values.public static final String exportFormVars(AdSet vars, String exclusionList)
vars
- An AdSet
of variable names and values.exclusionList
- A space-separated list of fields in the AdSet to ignore (or null to export all of them)public static final String exportURLVars(AdSet vars)
vars
- An AdSet
of variable names and values.public static final String exportURLVars(AdSet vars, String exclusionList)
vars
- An AdSet
of variable names and values.exclusionList
- A space-separated list of fields in the AdSet to ignore (or null to export all of them)public static final String exportURLVars(ResultSet rs, String vars)
rs
- A ResultSet
.vars
- A space-separated list of fields from the result set
to export. If null, all fields are exported.public static final String exportFormVars(ResultSet rs, String vars)
rs
- A ResultSet
.vars
- A space-separated list of fields from the result set
to export. If null, all fields are exported.public static final String exportVars(DataSource ds, String vars, boolean form)
ds
- A DataSource
.vars
- A space-separated list of fields from the result set
to export. If null, all fields are exported.form
- if true
, export as form vars, else export
as URL varspublic static final String exportFormVar(String key, String value)
key
- Variable name.value
- Variable value.public static final String exportVars(HttpServletRequest req, String vars, boolean form)
req
- A servlet requestvars
- A space-separated list of fields from the result set
to export. If null, all form variables are exported.form
- if true
, export as form vars, else export
as URL varspublic static final String exportURLVars(DataSource ds, String vars)
ds
- A DataSource
.vars
- A space-separated list of fields from the result set
to export. If null, all fields are exported.public static final String exportFormVars(DataSource ds, String vars)
ds
- A DataSource
.vars
- A space-separated list of fields from the result set
to export. If null, all fields are exported.public static final String exportURLVars(HttpServletRequest req, String vars)
req
- A servlet requestvars
- A space-separated list of fields from the result set
to export. If null, all fields are exported.public static final String exportFormVars(HttpServletRequest req, String vars)
public static final String URLEncode(String s)
s
- The string to encodepublic static final String exportFormValue(String val)
val
- The value to encode.public static final String URLDecode(String str) throws NumberFormatException, StringIndexOutOfBoundsException
str
- the url-encoded stringIllegalArgumentException
- If a '%' is not
followed by a valid 2-digit hex number.public static final String getCookieValue(HttpServletRequest request, String withName)
request
- The servlet requestwithName
- The cookie nameCookie
,
HttpServletRequest.getCookies()
public static final String join(Vector v, String s)
java.util.Vector
to a String joined on
another String. Analogous to the join
procedure in
Tcl or Perl.v
- The Vector
to join.s
- The string inserted between each element of v
v
, separated by
s
public static final String join(Object[] o, String s)
join
procedure in
Tcl or Perl.v
- The Vector
to join.s
- The string inserted between each element of v
v
, separated by
s
public static final char secRandomChar()
public static final String secDigestString(String str)
str
- The string inputpublic static final String secRandomToken()
TokenLength
and TokenSecret
parameters from Parameters
, in no module.public static final boolean emptyString(String s)
s
- A string to testtrue
if s
is null or empty;
otherwise false
public static final void sendRedirect(HttpServletResponse response, String location) throws IOException
response
- Response object to send redirect with.location
- URL to redirect to.public static final void removeDups(Vector v)
v
- The Vector to modifypublic static final String prettyBoolean(Object in)
public static final void copyFile(File src, File dest) throws IOException
public static final void sendMail(String to, String from, String subject, String body) throws Exception
public static final boolean emailValidP(String email)
public static final boolean URLValidP(String queryURL)
public static String generateRandomString()
public static String generateRandomString(int u)
public static final boolean isNumber(String s)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |