public class Util extends Api
util
variable.Constructor and Description |
---|
Util(XWiki xwiki,
XWikiContext context)
|
Modifier and Type | Method and Description |
---|---|
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. |
String |
generateRandomString(int size)
Generate a random string, containing only alpha-numeric characters.
|
Date |
getDate()
Deprecated.
use
$datetool.date instead |
Date |
getDate(long time)
Deprecated.
use
$datetool.toDate(time) instead |
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.
|
convert, convert, convert, convertAttachments, getAuthorizationManager, getContextualAuthorizationManager, getXWikiContext, hasAccess, hasAccessLevel, hasAdminRights, hasProgrammingRights, hasWikiAdminRights
public Util(XWiki xwiki, XWikiContext context)
context
and
the current global XWiki
object.xwiki
- the current global XWiki objectcontext
- the current contextApi(com.xpn.xwiki.XWikiContext)
public String decodeURI(String text)
application/x-www-form-urlencoded
string.text
- the encoded text@Deprecated public Date getDate()
$datetool.date
insteadDate
object corresponding to the current time. This is useful from Velocity since new
objects cannot be created.@Deprecated public Date getDate(long time)
$datetool.toDate(time)
insteadDate
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 GMTDate
Objectpublic int getTimeDelta(long time)
time
- the time in millisecondspublic String printStrackTrace(Throwable e)
e
- the exception to convert to a Stringpublic String generateRandomString(int size)
size
- the desired size of the stringpublic void outputImage(BufferedImage image) throws IOException
$xcontext.setFinished(true)
to avoid template output. The image is served
as image/jpeg.image
- the BufferedImage to outputIOException
- 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 parsedfalse
if the string is not representing a booleanpublic String clearAccents(String text)
text
- the text to parsepublic String clearName(String documentName)
documentName
- the document name to normalizepublic String convertToAlphaNumeric(String text)
text
- the text to convertCopyright © 2004–2022 XWiki. All rights reserved.