|
|||||||||
| 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.
| Field Summary | |
static java.lang.String |
cvsId
|
| Constructor Summary | |
Utilities()
|
|
| Method Summary | |
static java.lang.String |
commifyNumber(long num)
putting commas into numbers (thank you, Michael Bryzek) |
static java.lang.String |
commifyNumber(java.lang.String num)
putting commas into numbers (thank you, Michael Bryzek) |
static void |
copyFile(java.io.File src,
java.io.File dest)
|
static java.lang.String |
decorateTop(java.lang.String simpleHeadline,
java.lang.String potentialDecoration)
Use this for pages that might or might not have an im\age defined in ad.ini; if the second argument isn't the empty string, this will make a one-row table for the top of the page. |
static boolean |
emailValidP(java.lang.String email)
|
static boolean |
emptyString(java.lang.Object o)
|
static boolean |
emptyString(java.lang.String s)
|
static java.lang.String |
exportFormValue(java.lang.String val)
Returns "value="form_value"", URL-encoded appropriately for inclusion in an HTML form. |
static java.lang.String |
exportFormVar(java.lang.String key,
java.lang.Object value)
Exports a single variable for use in a form, as input type=hidden. |
static java.lang.String |
exportFormVars(AdSet vars)
Exports variables for use in a form, as input type=hidden. |
static java.lang.String |
exportFormVars(AdSet vars,
java.util.List inclusionList,
java.lang.String exclusionList)
Exports variables for use in a form, as input type=hidden. |
static java.lang.String |
exportFormVars(AdSet vars,
java.lang.String inclusionList,
java.lang.String exclusionList)
Exports variables for use in a form, as input type=hidden. |
static java.lang.String |
exportFormVars(DataSource ds,
java.lang.String vars)
Exports variables for use in a form, as input type=hidden |
static java.lang.String |
exportFormVars(javax.servlet.http.HttpServletRequest req,
java.lang.String vars)
|
static java.lang.String |
exportFormVars(java.sql.ResultSet rs,
java.lang.String vars)
Exports variables for use in a form, as hidden input fields. |
static java.lang.String |
exportURLVar(java.lang.String key,
java.lang.Object value)
Exports a single variable for use in a URL |
static java.lang.String |
exportURLVars(AdSet vars)
Exports variables for use in a URL, as name=value&name=value... |
static java.lang.String |
exportURLVars(AdSet vars,
java.util.List inclusionList,
java.lang.String exclusionList)
Exports variables for use in a URL, as name=value&name=value... |
static java.lang.String |
exportURLVars(AdSet vars,
java.lang.String inclusionList,
java.lang.String exclusionList)
Exports variables for use in a URL, as name=value&name=value... |
static java.lang.String |
exportURLVars(DataSource ds,
java.lang.String vars)
Exports variables for use in a URL, as name=value&name=value..., |
static java.lang.String |
exportURLVars(javax.servlet.http.HttpServletRequest req,
java.lang.String vars)
Exports variables for use in a URL, as name=value&name=value..., |
static java.lang.String |
exportURLVars(java.sql.ResultSet rs,
java.lang.String vars)
Exports variables for use in a URL, as name=value&name=value... |
static java.lang.String |
exportURLVars(java.lang.String key,
java.lang.Object[] values)
Exports a "multiple" variable, where the same name is used for multiple values. |
static java.lang.String |
exportVars(DataSource ds,
java.lang.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 java.lang.String |
exportVars(javax.servlet.http.HttpServletRequest req,
java.lang.String vars,
boolean form)
Deprecated. use ACSForm.exportXXX routines instead as URL vars |
static java.lang.String |
fileToString(java.io.File f)
Return a file's contents as a string. |
static java.lang.String |
fileToString(java.io.File f,
java.lang.String exc_message)
Return a file's contents as a string. |
static java.util.Vector |
findAllFiles(java.io.File path)
|
static java.util.Vector |
findAllFiles(java.io.File path,
boolean include_dirs,
boolean include_backup,
int max_depth)
Returns a list of Files under path in the directory tree (descending the tree to a depth of up to max_depth). |
static java.lang.String |
generateRandomString()
|
static java.lang.String |
generateRandomString(int u)
|
static java.lang.String |
getCookieValue(javax.servlet.http.HttpServletRequest request,
java.lang.String withName)
Returns a cookie value as a String, given a cookie name. |
static java.lang.String |
getFirstPackageURL(java.lang.String package_key,
ACSRequest req)
Same as above, but uses ACSRequest instead of HttpServletRequest. |
static java.lang.String |
getFirstPackageURL(java.lang.String package_key,
javax.servlet.http.HttpServletRequest req)
Returns the URL to the first package named package_key. |
static float |
getRandomFloat()
Gets a random number between 0.0 and 1.0. |
static java.lang.String |
htmlToText(java.lang.String s)
Removes tags and substitutes P tags with newlines. |
static boolean |
ignoreFile(java.io.File file)
Return true if path should, in general, be ignored for package operations. |
static boolean |
ignoreFile(java.io.File file,
boolean includeBackup)
Return true if path should, in general, be ignored for package operations. |
static boolean |
isBackupFile(java.io.File file)
Returns 1 if $path is a backup file, or 0 if not. |
static boolean |
isFalse(java.lang.String s)
False if argument equals "f", "0", "n", "false", "no", or "off". |
static boolean |
isNumber(java.lang.String s)
Return true if the input string looks like a number. |
static boolean |
isTrue(java.lang.String s)
! isFalse. |
static java.lang.String |
join(java.lang.Object[] o,
java.lang.String s)
Converts an array to a String joined on another String. |
static java.lang.String |
join(java.util.Vector v,
java.lang.String s)
Converts a java.util.Vector to a String joined on
another String. |
static boolean |
linkResponding(java.lang.String url)
Return true/false about whether a url is responding. |
static boolean |
linkResponding(java.lang.String url,
int[] bad_codes)
Return true/false about whether a url is responding. |
static java.lang.String |
makeRelativePath(java.io.File path)
|
static java.lang.String |
makeRelativePath(java.lang.String path)
|
static java.lang.String |
maybeHtmlToText(java.lang.String s,
java.lang.String html_p)
|
static AdSet |
parseQuery(java.lang.String query)
Equivalent to ns_parsequery Parses given query string and returns an AdSet of the key value pairs. |
static java.lang.String |
quoteHtml(java.lang.String s)
Quotes "special" characters in HTML text (ampersand, angle brackets, quote). |
static void |
removeDups(java.util.Vector v)
/** Removes duplicate entries from a Vector. |
static char |
secRandomChar()
Generates a single random character. |
static void |
sendRedirect(javax.servlet.http.HttpServletResponse resp,
java.lang.String url)
Redirects to the response, setting the status code and location headers directly. |
static void |
sendRedirect(javax.servlet.http.HttpServletResponse resp,
Url url)
|
static boolean |
stringGlobMatch(java.lang.String pattern,
java.lang.String s)
This is a utility proc for performing a TCL-style glob (i.e. |
static java.lang.String |
textToHtml(java.lang.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 java.lang.String |
toPrettyDate(java.util.Date date)
Converts java.util.Date to a "pretty" date |
static java.lang.String |
toPrettyDate(java.lang.String ansiDate)
Converts an ANSI yyyy-mm-dd date to a "pretty" date |
static java.lang.String |
URLDecode(java.lang.String str)
This method decodes the given urlencoded string. |
static java.lang.String |
URLEncode(java.lang.String s)
URL-encodes a string. |
static boolean |
URLValidP(java.lang.String queryURL)
|
static void |
writeStringToResponse(javax.servlet.http.HttpServletResponse resp,
java.lang.String s)
Write out a string as a full http response. |
static void |
writeStringToResponse(javax.servlet.http.HttpServletResponse resp,
java.lang.String s,
int status,
java.lang.String content_type)
Write out a string as a full http response. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String cvsId
| Constructor Detail |
public Utilities()
| Method Detail |
public static final java.lang.String quoteHtml(java.lang.String s)
s - The string to quotepublic static final java.lang.String textToHtml(java.lang.String s)
s - The input plaintext stringand ampersands/angle brackets escaped.
public static final java.lang.String htmlToText(java.lang.String s)
public static final java.lang.String maybeHtmlToText(java.lang.String s,
java.lang.String html_p)
public static final java.lang.String exportFormVars(AdSet vars)
vars - An AdSet of variable names and values.
public static final java.lang.String exportFormVars(AdSet vars,
java.lang.String inclusionList,
java.lang.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)inclusionList - A space-separated list of fields in the AdSet to include
Note that the exclusionList takes precedence over the inclusionList.
Leave null to indicate "all that are not excluded."
public static final java.lang.String exportFormVars(AdSet vars,
java.util.List inclusionList,
java.lang.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)inclusionList - A List containing the only keys to include.
Note that the exclusionList takes precedence over the inclusionList.
Leave null to include all that are not excluded.public static final java.lang.String exportURLVars(AdSet vars)
vars - An AdSet of variable names and values.
public static final java.lang.String exportURLVars(java.lang.String key,
java.lang.Object[] values)
public static final java.lang.String exportURLVars(AdSet vars,
java.lang.String inclusionList,
java.lang.String exclusionList)
vars - An AdSet of variable names and values.inclusionList - A space-separated list of fields in the AdSet to include
Note that the exclusionList takes precedence over the inclusionList.
Leave null to indicate "all that are not excluded."exclusionList - A space-separated list of fields in the AdSet to ignore (or null to export all of them)
public static final java.lang.String exportURLVars(AdSet vars,
java.util.List inclusionList,
java.lang.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)inclusionList - A List containing the only keys to include.
Note that the exclusionList takes precedence over the inclusionList.
Leave null to include all that are not excluded.
public static final java.lang.String exportURLVars(java.sql.ResultSet rs,
java.lang.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 java.lang.String exportFormVars(java.sql.ResultSet rs,
java.lang.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 java.lang.String exportVars(DataSource ds,
java.lang.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 vars
public static final java.lang.String exportFormVar(java.lang.String key,
java.lang.Object value)
key - Variable name.value - Variable value.
public static final java.lang.String exportURLVar(java.lang.String key,
java.lang.Object value)
key - Variable name.value - Variable value.
public static final java.lang.String exportURLVars(DataSource ds,
java.lang.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 java.lang.String exportFormVars(DataSource ds,
java.lang.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 java.lang.String exportURLVars(javax.servlet.http.HttpServletRequest req,
java.lang.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 java.lang.String exportFormVars(javax.servlet.http.HttpServletRequest req,
java.lang.String vars)
public static final java.lang.String exportVars(javax.servlet.http.HttpServletRequest req,
java.lang.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 exportpublic static final java.lang.String URLEncode(java.lang.String s)
s - The string to encodepublic static final java.lang.String exportFormValue(java.lang.String val)
val - The value to encode.
public static final java.lang.String URLDecode(java.lang.String str)
throws java.lang.NumberFormatException,
java.lang.StringIndexOutOfBoundsException
str - the url-encoded stringjava.lang.IllegalArgumentException - If a '%' is not
followed by a valid 2-digit hex number.
public static final java.lang.String getCookieValue(javax.servlet.http.HttpServletRequest request,
java.lang.String withName)
request - The servlet requestwithName - The cookie nameCookie,
HttpServletRequest.getCookies()
public static void sendRedirect(javax.servlet.http.HttpServletResponse resp,
java.lang.String url)
throws java.io.IOException
public static void sendRedirect(javax.servlet.http.HttpServletResponse resp,
Url url)
throws java.io.IOException
public static final java.lang.String join(java.util.Vector v,
java.lang.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 vv, separated by
s
public static final java.lang.String join(java.lang.Object[] o,
java.lang.String s)
join procedure in
Tcl or Perl.v - The Vector to join.s - The string inserted between each element of vv, separated by
spublic static final char secRandomChar()
public static final float getRandomFloat()
public static final boolean emptyString(java.lang.String s)
s - A string to testtrue if s is null or empty;
otherwise falsepublic static final boolean emptyString(java.lang.Object o)
o - A string to testtrue if o is null or empty;
otherwise falsepublic static final void removeDups(java.util.Vector v)
v - The Vector to modify
public static final void copyFile(java.io.File src,
java.io.File dest)
throws java.io.IOException
public static final boolean emailValidP(java.lang.String email)
public static final boolean URLValidP(java.lang.String queryURL)
public static java.lang.String generateRandomString()
public static java.lang.String generateRandomString(int u)
public static final boolean isNumber(java.lang.String s)
public static final java.lang.String toPrettyDate(java.util.Date date)
public static final java.lang.String toPrettyDate(java.lang.String ansiDate)
public static final boolean stringGlobMatch(java.lang.String pattern,
java.lang.String s)
public static final java.lang.String fileToString(java.io.File f)
throws ACSException
public static final java.lang.String fileToString(java.io.File f,
java.lang.String exc_message)
throws ACSException
public static final void writeStringToResponse(javax.servlet.http.HttpServletResponse resp,
java.lang.String s)
throws ACSException
public static final void writeStringToResponse(javax.servlet.http.HttpServletResponse resp,
java.lang.String s,
int status,
java.lang.String content_type)
throws ACSException
public static final boolean linkResponding(java.lang.String url)
public static final boolean linkResponding(java.lang.String url,
int[] bad_codes)
public static final java.lang.String decorateTop(java.lang.String simpleHeadline,
java.lang.String potentialDecoration)
simple_headline - Headline.potential_decoration - Decoration string (usually an image reference).public static final AdSet parseQuery(java.lang.String query)
query - Query string to parse (a=b&c=d).public static java.lang.String commifyNumber(long num)
public static java.lang.String commifyNumber(java.lang.String num)
public static boolean isTrue(java.lang.String s)
public static boolean isFalse(java.lang.String s)
public static boolean ignoreFile(java.io.File file)
public static boolean ignoreFile(java.io.File file,
boolean includeBackup)
public static boolean isBackupFile(java.io.File file)
#
bak
bak and one or more non-alphanumeric characters
.old, .bak, or ~
public static java.util.Vector findAllFiles(java.io.File path)
public static java.util.Vector findAllFiles(java.io.File path,
boolean include_dirs,
boolean include_backup,
int max_depth)
public static java.lang.String makeRelativePath(java.lang.String path)
throws ACSException
public static java.lang.String makeRelativePath(java.io.File path)
throws ACSException
public static java.lang.String getFirstPackageURL(java.lang.String package_key,
javax.servlet.http.HttpServletRequest req)
throws java.sql.SQLException
public static java.lang.String getFirstPackageURL(java.lang.String package_key,
ACSRequest req)
throws java.sql.SQLException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||