org.yawlfoundation.yawl.scheduling.util
Class XMLUtils

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

public class XMLUtils
extends Object
implements Constants

Version:
$Id: java 18313 2010-04-30 10:14:09Z tbe $
Author:
tbe

Field Summary
 
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
XMLUtils()
           
 
Method Summary
static void addAttributeValue(org.jdom.Element e, String attr, String value, String... args)
           
static void addErrorValue(org.jdom.Element e, boolean withValidation, String value, String... args)
           
static void addWarningValue(org.jdom.Element e, String value, String... args)
           
static boolean different(org.jdom.Element e1, org.jdom.Element e2)
           
static Set<String> getActivityNames(org.jdom.Element e)
          returns all activity names from element e recursively
static org.jdom.Attribute getAttribute(org.jdom.Document doc, String xpath)
           
static Boolean getBooleanValue(org.jdom.Element element, boolean withValidation)
           
static String getCaseId(org.jdom.Document rup)
           
static Date getDateValue(org.jdom.Element element, boolean withValidation)
           
static String getDefaultFromSchema(String elementName)
           
static Double getDoubleValue(org.jdom.Element element, boolean withValidation)
           
static Duration getDurationValue(org.jdom.Element element, boolean withValidation)
           
static Integer getDurationValueInMinutes(org.jdom.Element element, boolean withValidation)
           
static Date getEarliestBeginDate(org.jdom.Document rup)
          find earliest FROM date of rup
static org.jdom.Element getEarliestBeginElement(org.jdom.Document rup, String[] possibleActivities)
          find earliest FROM element of rup
static org.jdom.Element getElement(org.jdom.Document doc, String xpath)
           
static List<org.jdom.Element> getElements(org.jdom.Document doc, String xpath)
           
static List<String> getEnumerationFromSchema(String name)
          return constants defined in XSD enumerations sind als simpleType definiert
static Set<String> getErrors(org.jdom.Element element)
           
static String getErrorValue(org.jdom.Element e)
           
static Integer getIntegerValue(org.jdom.Element element, boolean withValidation)
           
static Date getLatestEndDate(org.jdom.Document rup)
          find latest TO date of rup
static org.jdom.Element getLatestEndElement(org.jdom.Document rup, String[] possibleActivities)
          find latest TO element of rup
static Long getLongValue(org.jdom.Element element, boolean withValidation)
           
static Collection<org.jdom.Document> getSchemaDocs()
           
static String getStringValue(org.jdom.Element element, boolean withValidation)
           
static String getUnitFromSchema(String elementName)
           
static String getWarningValue(org.jdom.Element e)
           
static List getXMLObjects(org.jdom.Document doc, String xpath)
           
static String getXPATH_Activities(String... activityNames)
           
static String getXPATH_ActivitiesElement(String[] activityNames, String elementName, Integer index)
           
static String getXPATH_ActivityElement(String activityName, String elementName, Integer index)
           
static String getXPATH_ResOrUtilElement(String activityName, String resOrUtilName, Integer resOrUtilIdx, String elementName)
           
static String getXPATH_Resource(String activityName, Integer resIdx)
           
static String getXPATH_ResourceElement(String activityName, Integer resIdx, String elementName)
           
static String getXPATH_ResourceElement(String activityName, Integer resIdx, String elementName, String elementText)
           
static String getXPATH_RUP()
           
static boolean hasErrors(org.jdom.Element element)
           
static boolean hasWarnings(org.jdom.Element element)
           
static boolean isEnumerationFromSchema(String elementName)
           
static boolean isEqualXMLText(String t1, String t2)
          compares textual content of two elements which are get with element.getChildText() content of a non-existing element is equal to content of an element without text
static boolean isReadonlyFromSchema(String elementName)
           
static boolean isRequiredFromSchema(String elementName)
           
static boolean isVisibleFromSchema(String elementName)
           
static boolean mergeElements(org.jdom.Element minor, org.jdom.Element major)
          merges content of two elements recursively into element minor following content will be copied: Text, Element, Attribute if conflicts, minor will be overwrite with content of major
static void removeAttribute(org.jdom.Element e, String attr)
           
static void removeAttributes(org.jdom.Element element, String attr)
           
static void setChildText(org.jdom.Element elem, String childName, String childText)
          set childText on elem's child, if child doesn't exist, it will be created
static void setDateValue(org.jdom.Element element, Date value)
           
static void setDefaults(org.jdom.Element elem)
           
static void setDurationValue(org.jdom.Element element, long value)
           
static void setLongValue(org.jdom.Element element, Long value)
           
static void setStringValue(org.jdom.Element element, String value)
           
static void sortChilds(org.jdom.Element parent)
          sort childs of xml element by name ascending
static void validate(org.jdom.Element msg)
           
static void validate(String msgText)
          Datentyp�berpr�fung und angabe des betroffenen elements, es werden alle gefundenen Fehler ausgegeben Xerces DocumentBuilder method, called by validator.validate(), isn't thread safe
static String validateElement(org.jdom.Element element, org.jdom.Element typeElement, List<org.jdom.Element> restrictions, boolean withValidation)
          validates element of resource utilisation plan against type element from schema return cs class for element
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtils

public XMLUtils()
Method Detail

getSchemaDocs

public static Collection<org.jdom.Document> getSchemaDocs()

getEnumerationFromSchema

public static List<String> getEnumerationFromSchema(String name)
return constants defined in XSD enumerations sind als simpleType definiert

Returns:

getDefaultFromSchema

public static String getDefaultFromSchema(String elementName)

getUnitFromSchema

public static String getUnitFromSchema(String elementName)

isVisibleFromSchema

public static boolean isVisibleFromSchema(String elementName)

isReadonlyFromSchema

public static boolean isReadonlyFromSchema(String elementName)

isEnumerationFromSchema

public static boolean isEnumerationFromSchema(String elementName)

isRequiredFromSchema

public static boolean isRequiredFromSchema(String elementName)

setDefaults

public static void setDefaults(org.jdom.Element elem)

validate

public static void validate(String msgText)
                     throws IOException,
                            SAXException
Datentyp�berpr�fung und angabe des betroffenen elements, es werden alle gefundenen Fehler ausgegeben Xerces DocumentBuilder method, called by validator.validate(), isn't thread safe

Parameters:
msgText -
Throws:
IOException
SAXException

validate

public static void validate(org.jdom.Element msg)
                     throws IOException,
                            SAXException
Throws:
IOException
SAXException

validateElement

public static String validateElement(org.jdom.Element element,
                                     org.jdom.Element typeElement,
                                     List<org.jdom.Element> restrictions,
                                     boolean withValidation)
                              throws DatatypeConfigurationException,
                                     IOException,
                                     org.jdom.JDOMException
validates element of resource utilisation plan against type element from schema return cs class for element

Throws:
DatatypeConfigurationException
IOException
org.jdom.JDOMException

getErrorValue

public static String getErrorValue(org.jdom.Element e)

getWarningValue

public static String getWarningValue(org.jdom.Element e)

addErrorValue

public static void addErrorValue(org.jdom.Element e,
                                 boolean withValidation,
                                 String value,
                                 String... args)

addWarningValue

public static void addWarningValue(org.jdom.Element e,
                                   String value,
                                   String... args)

addAttributeValue

public static void addAttributeValue(org.jdom.Element e,
                                     String attr,
                                     String value,
                                     String... args)

removeAttributes

public static void removeAttributes(org.jdom.Element element,
                                    String attr)

removeAttribute

public static void removeAttribute(org.jdom.Element e,
                                   String attr)

hasErrors

public static boolean hasErrors(org.jdom.Element element)

hasWarnings

public static boolean hasWarnings(org.jdom.Element element)

getErrors

public static Set<String> getErrors(org.jdom.Element element)

getDateValue

public static Date getDateValue(org.jdom.Element element,
                                boolean withValidation)

setDateValue

public static void setDateValue(org.jdom.Element element,
                                Date value)

setDurationValue

public static void setDurationValue(org.jdom.Element element,
                                    long value)

setLongValue

public static void setLongValue(org.jdom.Element element,
                                Long value)

getStringValue

public static String getStringValue(org.jdom.Element element,
                                    boolean withValidation)

setStringValue

public static void setStringValue(org.jdom.Element element,
                                  String value)

getDurationValue

public static Duration getDurationValue(org.jdom.Element element,
                                        boolean withValidation)

getDurationValueInMinutes

public static Integer getDurationValueInMinutes(org.jdom.Element element,
                                                boolean withValidation)

getDoubleValue

public static Double getDoubleValue(org.jdom.Element element,
                                    boolean withValidation)

getIntegerValue

public static Integer getIntegerValue(org.jdom.Element element,
                                      boolean withValidation)

getLongValue

public static Long getLongValue(org.jdom.Element element,
                                boolean withValidation)

getBooleanValue

public static Boolean getBooleanValue(org.jdom.Element element,
                                      boolean withValidation)

getXPATH_RUP

public static String getXPATH_RUP()

getXPATH_Activities

public static String getXPATH_Activities(String... activityNames)

getXPATH_ActivitiesElement

public static String getXPATH_ActivitiesElement(String[] activityNames,
                                                String elementName,
                                                Integer index)

getXPATH_ActivityElement

public static String getXPATH_ActivityElement(String activityName,
                                              String elementName,
                                              Integer index)

getXPATH_ResOrUtilElement

public static String getXPATH_ResOrUtilElement(String activityName,
                                               String resOrUtilName,
                                               Integer resOrUtilIdx,
                                               String elementName)

getXPATH_Resource

public static String getXPATH_Resource(String activityName,
                                       Integer resIdx)

getXPATH_ResourceElement

public static String getXPATH_ResourceElement(String activityName,
                                              Integer resIdx,
                                              String elementName)

getXPATH_ResourceElement

public static String getXPATH_ResourceElement(String activityName,
                                              Integer resIdx,
                                              String elementName,
                                              String elementText)

different

public static boolean different(org.jdom.Element e1,
                                org.jdom.Element e2)
                         throws IOException,
                                SAXException
Throws:
IOException
SAXException

isEqualXMLText

public static boolean isEqualXMLText(String t1,
                                     String t2)
compares textual content of two elements which are get with element.getChildText() content of a non-existing element is equal to content of an element without text

Parameters:
t1 -
t2 -
Returns:

getXMLObjects

public static List getXMLObjects(org.jdom.Document doc,
                                 String xpath)

getElements

public static List<org.jdom.Element> getElements(org.jdom.Document doc,
                                                 String xpath)

getElement

public static org.jdom.Element getElement(org.jdom.Document doc,
                                          String xpath)

getAttribute

public static org.jdom.Attribute getAttribute(org.jdom.Document doc,
                                              String xpath)

sortChilds

public static void sortChilds(org.jdom.Element parent)
sort childs of xml element by name ascending

Parameters:
parent -

setChildText

public static void setChildText(org.jdom.Element elem,
                                String childName,
                                String childText)
set childText on elem's child, if child doesn't exist, it will be created

Parameters:
elem -
childName -
childText -

mergeElements

public static boolean mergeElements(org.jdom.Element minor,
                                    org.jdom.Element major)
                             throws Exception
merges content of two elements recursively into element minor following content will be copied: Text, Element, Attribute if conflicts, minor will be overwrite with content of major

Parameters:
minor -
major -
Throws:
Exception

getActivityNames

public static Set<String> getActivityNames(org.jdom.Element e)
returns all activity names from element e recursively

Parameters:
e -
Returns:

getCaseId

public static String getCaseId(org.jdom.Document rup)

getEarliestBeginElement

public static org.jdom.Element getEarliestBeginElement(org.jdom.Document rup,
                                                       String[] possibleActivities)
find earliest FROM element of rup


getEarliestBeginDate

public static Date getEarliestBeginDate(org.jdom.Document rup)
find earliest FROM date of rup


getLatestEndElement

public static org.jdom.Element getLatestEndElement(org.jdom.Document rup,
                                                   String[] possibleActivities)
find latest TO element of rup


getLatestEndDate

public static Date getLatestEndDate(org.jdom.Document rup)
find latest TO date of rup



Copyright © 2004-2012 The YAWL Foundation.