Openfire 3.9.3 Javadoc

org.jivesoftware.openfire.clearspace
Class WSUtils

java.lang.Object
  extended by org.jivesoftware.openfire.clearspace.WSUtils

public class WSUtils
extends Object

Several utilities to handle REST webservices.


Constructor Summary
WSUtils()
           
 
Method Summary
static String formatDate(Date date)
          Formats a date into yyyy-MM-dd'T'HH:mm:ss.SSSZ, for example 2008-02-13T18:54:29.147-03:00
protected static String getElementText(org.dom4j.Node node, String name)
          Returns the text of the first an element with name 'name'.
protected static String getReturn(org.dom4j.Element element)
          Returns the text of the first an element with name 'return'.
protected static String marshallList(List<String> data)
           
protected static void modifyElementText(org.dom4j.Element element, String[] path, String newValue)
           
protected static void modifyElementText(org.dom4j.Node node, String name, String newValue)
          Modifies the text of the elmement with name 'name'.
static Date parseDate(String date)
          Parses a date of the form 1969-12-31T21:00:00-03:00, or 2008-02-13T18:54:29.147-03:00.
protected static List<String> parseStringArray(org.dom4j.Element element)
          Parse REST responses of the type String[], that are XML of the form:
protected static List<String> parseUsernameArray(org.dom4j.Element element)
          Parse REST responses of the type String[] that represent usernames, that are XML of the form:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WSUtils

public WSUtils()
Method Detail

getReturn

protected static String getReturn(org.dom4j.Element element)
Returns the text of the first an element with name 'return'.

Parameters:
element - the element to search for a return element.
Returns:
the text of the return element.

getElementText

protected static String getElementText(org.dom4j.Node node,
                                       String name)
Returns the text of the first an element with name 'name'.

Parameters:
node - the element to search for a "name" element.
name - the name of the element to search
Returns:
the text of the corresponding element

modifyElementText

protected static void modifyElementText(org.dom4j.Node node,
                                        String name,
                                        String newValue)
Modifies the text of the elmement with name 'name'.

Parameters:
node - the element to search
name - the name to search
newValue - the new value of the text

modifyElementText

protected static void modifyElementText(org.dom4j.Element element,
                                        String[] path,
                                        String newValue)

parseStringArray

protected static List<String> parseStringArray(org.dom4j.Element element)
Parse REST responses of the type String[], that are XML of the form:
 <something>
 <return>text1</return>
 <return>text2</return>
 <return>text3</return>
 </something>
 
 

Parameters:
element - Element from REST response to be parsed.
Returns:
An array of strings from the REST response.

parseUsernameArray

protected static List<String> parseUsernameArray(org.dom4j.Element element)
Parse REST responses of the type String[] that represent usernames, that are XML of the form:
 <something>
 <return>text1</return>
 <return>text2</return>
 <return>text3</return>
 </something>
 
 

Parameters:
element - Element from REST response to be parsed.
Returns:
An array of strings from the REST response.

marshallList

protected static String marshallList(List<String> data)

parseDate

public static Date parseDate(String date)
Parses a date of the form 1969-12-31T21:00:00-03:00, or 2008-02-13T18:54:29.147-03:00. If the string is null or there is a problem parsing the date, returns null.

Parameters:
date - the string to parse
Returns:
the corresponding date, or null if t

formatDate

public static String formatDate(Date date)
Formats a date into yyyy-MM-dd'T'HH:mm:ss.SSSZ, for example 2008-02-13T18:54:29.147-03:00

Parameters:
date - the date to format
Returns:
a string representation of the date

Openfire 3.9.3 Javadoc

Copyright © 2003-2008 Jive Software.