|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.xpn.xwiki.api.Api
com.xpn.xwiki.api.Util
public class Util
Utility APIs, available to scripting environments under the util
variable.
Field Summary |
---|
Fields inherited from class com.xpn.xwiki.api.Api |
---|
context |
Constructor Summary | |
---|---|
Util(XWiki xwiki,
XWikiContext context)
Simple constructor, initializes a new utility API with the current context and
the current global XWiki object. |
Method Summary | |
---|---|
String |
clearAccents(String text)
Replace all accented characters by their ASCII equivalent. |
String |
clearName(String documentName)
Cleans up the passed text by removing all accents and special characters to make it a valid page name. |
String |
convertToAlphaNumeric(String text)
Removes all non alpha numerical characters from the passed text. |
String |
decodeURI(String text)
Decodes a application/x-www-form-urlencoded string, the reverse of #encodeURI(String) . |
String |
generateRandomString(int size)
Generate a random string, containing only alpha-numeric characters. |
Date |
getDate()
Creates a new Date object corresponding to the current time. |
Date |
getDate(long time)
Creates a new Date object corresponding to the specified time. |
String |
getNewline()
Get a New Line character. |
Object |
getNull()
Get a Null value. |
int |
getTimeDelta(long time)
Compute the elapsed time, in milliseconds, since the specified unix-epoch timestamp. |
void |
outputImage(BufferedImage image)
Output a BufferedImage object into the response outputstream. |
Boolean |
parseBoolean(String str)
Convert a String to a Boolean object. |
String |
printStrackTrace(Throwable e)
Get a stack trace as a String. |
Methods inherited from class com.xpn.xwiki.api.Api |
---|
convert, convert, convert, convertAttachments, getXWikiContext, hasAccessLevel, hasAdminRights, hasProgrammingRights, hasWikiAdminRights |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Util(XWiki xwiki, XWikiContext context)
context
and
the current global XWiki
object.
xwiki
- the current global XWiki objectcontext
- the current contextApi.Api(com.xpn.xwiki.XWikiContext)
Method Detail |
---|
public String decodeURI(String text)
application/x-www-form-urlencoded
string, the reverse of #encodeURI(String)
.
text
- the encoded text
#encodeURI(String)
public Date getDate()
Date
object corresponding to the current time. This is useful from Velocity since new
objects cannot be created.
public Date getDate(long time)
Date
object corresponding to the specified time. This is useful from Velocity since new
objects cannot be created.
time
- time in milliseconds since 1970, 00:00:00 GMT
Date
Objectpublic int getTimeDelta(long time)
time
- the time in milliseconds
public String printStrackTrace(Throwable e)
e
- the exception to convert to a String
public String generateRandomString(int size)
size
- the desired size of the string
public void outputImage(BufferedImage image) throws IOException
$context.setFinished(true)
to avoid template output. The image is served as
image/jpeg.
image
- the BufferedImage to output
IOException
- if the output failspublic Object getNull()
null
object for comparisons.
null
Objectpublic String getNewline()
public Boolean parseBoolean(String str)
String
to a Boolean
object.
str
- the String containing the boolean representation to be parsed
false
if the string is not representing a booleanpublic String clearAccents(String text)
text
- the text to parse
public String clearName(String documentName)
documentName
- the document name to normalize
public String convertToAlphaNumeric(String text)
text
- the text to convert
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |