com.frevvo.forms.client
Class Helper

java.lang.Object
  extended by com.frevvo.forms.client.Helper

public class Helper
extends Object

Helper class


Field Summary
static Pattern FORM_INSTANCE_URL_PATTERN
           
static String MEDIATYPE_APP_XML
           
static String MEDIATYPE_TEXT_HTML
           
static String MEDIATYPE_TEXT_JAVASCRIPT
           
 
Constructor Summary
Helper()
           
 
Method Summary
static void addParts(org.apache.commons.httpclient.methods.MultipartPostMethod post, List<MediaSource> documents)
           
static void cancelInstance(FormsService service, URL fUrl)
           
static URL createFormInstance(Service service, Link link, Map<String,Object> linkParams, List<MediaSource> documents, boolean embed)
           
protected static String decode(String s)
           
protected static String encode(String s)
          Encodes a string using UTF-8.
static String generateData(Map<String,Object> data)
          Generate a data value that can be used to initialize controls in a form
static Link getFirstLink(List<Link> links, String rel, String type)
           
static String getInstanceState(FormsService service, URL url)
           
static String getInstanceXHTML(FormsService service, URL url)
           
static String getParameterValue(Object value)
           
static String getQueryParameters(Map<String,Object> params, boolean encode)
           
static String getSubmissionIdFromInstance(URL formInstanceUrl)
          Given the url to a form instance created using the FormTypeEntry.createFormInstance() method, use this method to return the SubmissionEntry id.
static void nextActivity(FormsService service, URL formUrl)
           
static void previousActivity(FormsService service, URL formUrl)
           
static void readStream(InputStream is, OutputStream os)
          Reads the given input stream and writes the content to the given output stream
static URL removeQuery(URL url)
           
static FormTypeEntry replaceFormType(FormsService fs, ApplicationEntry appEntry, String existingFormId, InputStream newForm)
          Replace the FormType identified by id with the given form stream
static void saveInstance(FormsService service, URL url)
           
static Link setParameters(Link link, Map<String,Object> params)
           
static Link setParameters(Link link, String name, Object value)
           
static String stripParameter(String url, String parameterKey)
           
static void submitInstance(FormsService service, URL formUrl)
           
static String updateControlValue(FormsService service, URL url, String id, String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MEDIATYPE_APP_XML

public static final String MEDIATYPE_APP_XML
See Also:
Constant Field Values

MEDIATYPE_TEXT_JAVASCRIPT

public static final String MEDIATYPE_TEXT_JAVASCRIPT
See Also:
Constant Field Values

MEDIATYPE_TEXT_HTML

public static final String MEDIATYPE_TEXT_HTML
See Also:
Constant Field Values

FORM_INSTANCE_URL_PATTERN

public static final Pattern FORM_INSTANCE_URL_PATTERN
Constructor Detail

Helper

public Helper()
Method Detail

getFirstLink

public static Link getFirstLink(List<Link> links,
                                String rel,
                                String type)

getParameterValue

public static String getParameterValue(Object value)

getQueryParameters

public static String getQueryParameters(Map<String,Object> params,
                                        boolean encode)

setParameters

public static Link setParameters(Link link,
                                 String name,
                                 Object value)

setParameters

public static Link setParameters(Link link,
                                 Map<String,Object> params)

stripParameter

public static String stripParameter(String url,
                                    String parameterKey)

encode

protected static String encode(String s)
Encodes a string using UTF-8.

Parameters:
s - string to be encoded
Throws:
RuntimeException - when the JVM does not support UTF-8

decode

protected static String decode(String s)

generateData

public static String generateData(Map<String,Object> data)
Generate a data value that can be used to initialize controls in a form

Parameters:
data - The Map containing the name of the controls and the values that should be used to initialize them
Returns:
The generate url parameter value

addParts

public static void addParts(org.apache.commons.httpclient.methods.MultipartPostMethod post,
                            List<MediaSource> documents)
                     throws IOException
Throws:
IOException

createFormInstance

public static URL createFormInstance(Service service,
                                     Link link,
                                     Map<String,Object> linkParams,
                                     List<MediaSource> documents,
                                     boolean embed)
                              throws ServiceException
Throws:
ServiceException

readStream

public static void readStream(InputStream is,
                              OutputStream os)
                       throws IOException
Reads the given input stream and writes the content to the given output stream

Parameters:
is -
os -
Throws:
IOException

nextActivity

public static void nextActivity(FormsService service,
                                URL formUrl)

previousActivity

public static void previousActivity(FormsService service,
                                    URL formUrl)

submitInstance

public static void submitInstance(FormsService service,
                                  URL formUrl)

cancelInstance

public static void cancelInstance(FormsService service,
                                  URL fUrl)

saveInstance

public static void saveInstance(FormsService service,
                                URL url)

getInstanceXHTML

public static String getInstanceXHTML(FormsService service,
                                      URL url)

getInstanceState

public static String getInstanceState(FormsService service,
                                      URL url)

updateControlValue

public static String updateControlValue(FormsService service,
                                        URL url,
                                        String id,
                                        String value)

getSubmissionIdFromInstance

public static String getSubmissionIdFromInstance(URL formInstanceUrl)
Given the url to a form instance created using the FormTypeEntry.createFormInstance() method, use this method to return the SubmissionEntry id.

Parameters:
formInstanceUrl -
Returns:
The SubmissionEntry id

removeQuery

public static URL removeQuery(URL url)

replaceFormType

public static FormTypeEntry replaceFormType(FormsService fs,
                                            ApplicationEntry appEntry,
                                            String existingFormId,
                                            InputStream newForm)
                                     throws ServiceException,
                                            IOException
Replace the FormType identified by id with the given form stream

Parameters:
fs -
appEntry -
existingFormId -
newForm -
Returns:
Throws:
ServiceException
IOException


Copyright © 2006-2011 frevvo Inc. All Rights Reserved.