org.yawlfoundation.yawl.scheduling.util
Class Utils

java.lang.Object
  extended by org.yawlfoundation.yawl.scheduling.util.Utils
All Implemented Interfaces:
Constants

public class Utils
extends Object
implements Constants


Nested Class Summary
static class Utils.ValueComparer
           
 
Field Summary
static String DATE_PATTERN
           
static String DATE_PATTERN_XML
           
static String DATETIME_PATTERN
           
static String DATETIME_PATTERN_XML
           
static String TIME_PATTERN
           
static String TIME_PATTERN_XML
           
 
Fields inherited from interface org.yawlfoundation.yawl.scheduling.Constants
ADDRESS_TYPE_EMAIL, ADDRESS_TYPE_IP, ADDRESS_TYPE_SMS, CSS_BOOLEANINPUT, CSS_DATEINPUT, CSS_DURATIONINPUT, CSS_ERRORINPUT, CSS_ERRORTEXT, CSS_INTINPUT, CSS_REQUIRED, CSS_TEXTINPUT, CSS_WARNINGINPUT, CSS_WARNINGTEXT, CSV_DELIMITER, DELIMITER, LANGUAGE_ATTRIBUTE_NAME, LANGUAGE_DEFAULT, LANGUAGES, MSGREL_AFTER, MSGREL_BEFORE, RESOURCE_STATUS_AVAILABLE, RESOURCE_STATUS_NOTAVAILABLE, RESOURCE_STATUS_REQUESTED, RESOURCE_STATUS_RESERVED, RESOURCE_STATUS_UNCHECKED, RESOURCE_STATUS_UNKNOWN, UTILISATION_TYPE_BEGIN, UTILISATION_TYPE_END, UTILISATION_TYPE_PLAN, WORD_SEPARATORS, XML_ACTIVITY, XML_ACTIVITYNAME, XML_ACTIVITYTYPE, XML_ADDRESS, XML_ADDRESSTYPE, XML_CAPABILITY, XML_CASEID, XML_CATEGORY, XML_CHANNEL, XML_DUMMY, XML_DURATION, XML_ENDTASKID, XML_ERROR, XML_EVENT_RECEIVE, XML_FILTERMODEL, XML_FROM, XML_ID, XML_MAX, XML_MESSAGE_SEND, XML_MESSAGEPUSH_SEND, XML_MESSAGES, XML_MIN, XML_MSGBODY, XML_MSGDURATION, XML_MSGREL, XML_MSGTO, XML_MSGTRANSFER, XML_MSGUTILISATIONTYPE, XML_OTHERACTIVITYNAME, XML_OTHERUTILISATIONTYPE, XML_PAYLOAD, XML_REQUESTTYPE, XML_RESCHEDULING, XML_RESERVATION, XML_RESERVATIONID, XML_RESOURCE, XML_RESOURCE_TYPE, XML_ROLE, XML_RUP, XML_RUP_LIGHT, XML_STARTTASKID, XML_STATUS, XML_STATUSTOBE, XML_SUBCATEGORY, XML_TEXT, XML_THISUTILISATIONTYPE, XML_TIMESTAMP, XML_TO, XML_UNIT, XML_UTILISATION, XML_UTILISATION_TYPE, XML_UTILISATIONREL, XML_UTILISATIONTYPE, XML_WARNING, XML_WORKLOAD, XSDDatatypes_Boolean, XSDDatatypes_DateTime, XSDDatatypes_Double, XSDDatatypes_Duration, XSDDatatypes_Int, XSDDatatypes_Long, XSDDatatypes_String
 
Constructor Summary
Utils()
           
 
Method Summary
static void addString2Map(String key, String value, Map<String,String> map, String separator)
          adds a value to a map at given key if a previous value at given key already exists, a separator and the new value will be added
static String attribute2String(org.jdom.Attribute a)
           
static String capitalize(String word)
          Transforms a string's first character to upper case
static String copy(String s, int n)
          copy String n times
static String date2String(Date date, String pattern)
           
static String date2String(Date date, String pattern, TimeZone timeZone)
           
static Object deepCopy(Object o)
          creates deep copy of serializable object see http://www.tutego.de/java/articles/Tiefe-Objektkopien-Java.html
static String document2String(org.jdom.Document doc, boolean formatted)
           
static int duration2Minutes(Duration d)
          converts duration, e.g.
static String element2String(org.jdom.Element elem, boolean formatted)
           
static String elements2String(List<org.jdom.Element> elems, boolean formatted)
           
static String encodeData(Map<String,Object[]> params)
          Encodes parameter values for HTTP transport copy of @see org.yawlfoundation.yawl.engine.interfce.Interface_Client.encodeData
static boolean equals(Object o1, Object o2)
           
static String extractCaseId(String input)
           
static String getCSV(Collection list)
          returns comma separated list of objects
static String getCSV(Collection list, int maxLength)
          returns comma separated list of objects
static Object getJsCalendarFormat(String localizedString)
          calendar format for JS_Calendar in javascript format
static String getJSON(List<String> list)
          serialize String values in JSON format
static String getJSON(List<String> sortedList, Map<String,Object> map)
          serialize String keys and String values in JSON format, sort keys according to order in sortedList
static String getJSON(Map<String,Object> map)
          serialize String keys and String values in JSON format
static String getJSON(String[] array)
          serialize String values in JSON format
static String getLogRequestParameters(Map<String,Object> parameterMap)
           
static String getLogSessionAttributes(javax.servlet.http.HttpSession session)
           
static long getMedian(List<Long> values)
           
static boolean isEqual(Object o1, Object o2)
          compares two objects
static String[] jsonObject2Array(Object json)
           
static List<String> parseCSV(String csv)
           
static List<String> parseCSV(String csv, String delimiters)
           
static String[] parseJSON2Array(String json)
           
static Map<String,String> parseJSON2Map(String json)
           
static String sendRequest(String urlStr, Map<String,Object[]> parameters)
          possible charsets: UTF-8, ISO-8859-1, US-ASCII, UTF-16, UTF-16BE, UTF-16LE
static Date string2Date(String date, String pattern)
           
static org.jdom.Document string2Document(String s)
           
static org.jdom.Element string2Element(String s)
           
static List<org.jdom.Element> string2Elements(String s)
           
static String stringMinutes2stringXMLDuration(String minutes)
          converts minute string x to lexical representation of duration
static Duration stringXML2Duration(String lexicalRepresentation)
           
static String stringXMLDuration2stringMinutes(String value)
          converts duration, e.g.
static String toString(Object o)
           
static String truncate(String s, int i)
          truncate String s to length i, if s > i, the last 3 characters will be replace by ...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TIME_PATTERN_XML

public static final String TIME_PATTERN_XML
See Also:
Constant Field Values

DATE_PATTERN_XML

public static final String DATE_PATTERN_XML
See Also:
Constant Field Values

DATETIME_PATTERN_XML

public static final String DATETIME_PATTERN_XML
See Also:
Constant Field Values

TIME_PATTERN

public static final String TIME_PATTERN
See Also:
Constant Field Values

DATE_PATTERN

public static final String DATE_PATTERN
See Also:
Constant Field Values

DATETIME_PATTERN

public static final String DATETIME_PATTERN
See Also:
Constant Field Values
Constructor Detail

Utils

public Utils()
Method Detail

getCSV

public static String getCSV(Collection list)
returns comma separated list of objects

Parameters:
list -
Returns:

getCSV

public static String getCSV(Collection list,
                            int maxLength)
returns comma separated list of objects

Parameters:
list -
maxLength -
Returns:

truncate

public static String truncate(String s,
                              int i)
truncate String s to length i, if s > i, the last 3 characters will be replace by ...

Parameters:
s -
i -
Returns:

copy

public static String copy(String s,
                          int n)
copy String n times

Parameters:
s -
n -
Returns:

getMedian

public static long getMedian(List<Long> values)

toString

public static String toString(Object o)

date2String

public static String date2String(Date date,
                                 String pattern,
                                 TimeZone timeZone)

date2String

public static String date2String(Date date,
                                 String pattern)

string2Date

public static Date string2Date(String date,
                               String pattern)
                        throws ParseException
Throws:
ParseException

stringMinutes2stringXMLDuration

public static String stringMinutes2stringXMLDuration(String minutes)
                                              throws DatatypeConfigurationException
converts minute string x to lexical representation of duration

Parameters:
minutes -
Returns:
Throws:
DatatypeConfigurationException

stringXMLDuration2stringMinutes

public static String stringXMLDuration2stringMinutes(String value)
converts duration, e.g. PTxxxM to minute string xxx

Parameters:
value -
Returns:

duration2Minutes

public static int duration2Minutes(Duration d)
converts duration, e.g. PTxxxM to minute int xxx

Parameters:
d -
Returns:

stringXML2Duration

public static Duration stringXML2Duration(String lexicalRepresentation)
                                   throws DatatypeConfigurationException
Throws:
DatatypeConfigurationException

elements2String

public static String elements2String(List<org.jdom.Element> elems,
                                     boolean formatted)

document2String

public static String document2String(org.jdom.Document doc,
                                     boolean formatted)

element2String

public static String element2String(org.jdom.Element elem,
                                    boolean formatted)

attribute2String

public static String attribute2String(org.jdom.Attribute a)

string2Document

public static org.jdom.Document string2Document(String s)
Parameters:
s -
Returns:

string2Element

public static org.jdom.Element string2Element(String s)

string2Elements

public static List<org.jdom.Element> string2Elements(String s)

addString2Map

public static void addString2Map(String key,
                                 String value,
                                 Map<String,String> map,
                                 String separator)
adds a value to a map at given key if a previous value at given key already exists, a separator and the new value will be added

Parameters:
key -
value -
map -
separator -

getJSON

public static String getJSON(List<String> list)
                      throws Exception
serialize String values in JSON format

Parameters:
list -
Returns:
Throws:
Exception

getJSON

public static String getJSON(Map<String,Object> map)
                      throws Exception
serialize String keys and String values in JSON format

Parameters:
map -
Returns:
Throws:
Exception

getJSON

public static String getJSON(List<String> sortedList,
                             Map<String,Object> map)
                      throws Exception
serialize String keys and String values in JSON format, sort keys according to order in sortedList

Parameters:
map -
Returns:
Throws:
Exception

getJSON

public static String getJSON(String[] array)
                      throws Exception
serialize String values in JSON format

Parameters:
array -
Returns:
Throws:
Exception

jsonObject2Array

public static String[] jsonObject2Array(Object json)
                                 throws org.json.JSONException
Throws:
org.json.JSONException

parseJSON2Array

public static String[] parseJSON2Array(String json)
                                throws org.json.JSONException
Throws:
org.json.JSONException

parseJSON2Map

public static Map<String,String> parseJSON2Map(String json)
                                        throws org.json.JSONException
Throws:
org.json.JSONException

parseCSV

public static List<String> parseCSV(String csv)
Parameters:
csv -
Returns:

parseCSV

public static List<String> parseCSV(String csv,
                                    String delimiters)
Parameters:
csv -
Returns:

encodeData

public static String encodeData(Map<String,Object[]> params)
Encodes parameter values for HTTP transport copy of @see org.yawlfoundation.yawl.engine.interfce.Interface_Client.encodeData

Parameters:
params - a map of the data parameter values, of the form [param1=value1],[param2=value2]...
Returns:
a formatted http data string with the data values encoded

capitalize

public static String capitalize(String word)
Transforms a string's first character to upper case

Parameters:
word -
Returns:
capitalized word

isEqual

public static boolean isEqual(Object o1,
                              Object o2)
compares two objects

Parameters:
o1 -
o2 -
Returns:

getLogRequestParameters

public static String getLogRequestParameters(Map<String,Object> parameterMap)

getLogSessionAttributes

public static String getLogSessionAttributes(javax.servlet.http.HttpSession session)

sendRequest

public static String sendRequest(String urlStr,
                                 Map<String,Object[]> parameters)
                          throws Exception
possible charsets: UTF-8, ISO-8859-1, US-ASCII, UTF-16, UTF-16BE, UTF-16LE

Parameters:
urlStr -
parameters -
Returns:
Throws:
Exception

getJsCalendarFormat

public static Object getJsCalendarFormat(String localizedString)
calendar format for JS_Calendar in javascript format

Parameters:
localizedString -
Returns:

equals

public static boolean equals(Object o1,
                             Object o2)

extractCaseId

public static String extractCaseId(String input)

deepCopy

public static Object deepCopy(Object o)
                       throws Exception
creates deep copy of serializable object see http://www.tutego.de/java/articles/Tiefe-Objektkopien-Java.html

Parameters:
o -
Returns:
Throws:
Exception


Copyright © 2004-2012 The YAWL Foundation.