org.yawlfoundation.yawl.util
Class YPredicateParser

java.lang.Object
  extended by org.yawlfoundation.yawl.util.YPredicateParser
Direct Known Subclasses:
DynTextParser, LogPredicateParser, YLogPredicateDecompositionParser, YLogPredicateParameterParser, YLogPredicateWorkItemParser, YNetElementDocoParser

public class YPredicateParser
extends Object

Parses strings, replacing substrings within of the form ${expression} with the result of the expression evaluation Author: Michael Adams Date: 02/04/2010 Known subclasses: logging.YLogPredicateDecompositionParser, logging.YLogPredicateParameterParser, logging.YLogPredicateWorkItemParser, resourcing.util.LogPredicateParser, resourcing.jsf.dynform.DynTextParser Subclasses should override the 'valueOf' method to handle their own pre-parsing.


Constructor Summary
YPredicateParser()
           
 
Method Summary
protected  String dateTimeString(long time)
          Converts a time value to a full date & time string
protected  String evaluateQuery(String s, org.jdom.Element data)
          Evaluates an XQuery embedded within a delimited expression
protected  String evaluateXQuery(String s, org.jdom.Document dataDoc)
           
protected  String evaluateXQuery(String s, org.jdom.Element data)
          Evaluates an XQuery
protected  String getAttributeValue(Map<String,String> map, String s)
          Extracts a key from the delimited expression passed, then seeks the value corresponding to that key from the map passed
protected  String namesToCSV(Set<String> names)
          Transforms a Set of Strings into a string of comma separated values
 String parse(String s)
          Parses a string, replacing substrings within of the form ${expression} with the result of the expression evaluation
protected  String stripDelimiters(String s)
          removes the surrounding ${...} from a String
protected  String valueOf(String s)
          Evaluates an expression and returns the result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

YPredicateParser

public YPredicateParser()
Method Detail

parse

public String parse(String s)
Parses a string, replacing substrings within of the form ${expression} with the result of the expression evaluation

Parameters:
s - the string to parse
Returns:
s, with any embedded expressions replaced with their evaluations

valueOf

protected String valueOf(String s)
Evaluates an expression and returns the result. Subclasses should override this class to do their own expression evaluations before calling this version for any general expression evaluations.

Parameters:
s - the string representing the expression, of the form ${expression}
Returns:
the result of the expression evaluation, or the unchanged string if the expression is unrecognised

dateTimeString

protected String dateTimeString(long time)
Converts a time value to a full date & time string

Parameters:
time - the time value
Returns:
a string representing the date & time value

getAttributeValue

protected String getAttributeValue(Map<String,String> map,
                                   String s)
Extracts a key from the delimited expression passed, then seeks the value corresponding to that key from the map passed

Parameters:
map - a map of String pairs
s - a string representing an expression, of the form ${expression:key}, containing the key
Returns:
the corresponding key value, or null if the map is null or the map does not contain the key

namesToCSV

protected String namesToCSV(Set<String> names)
Transforms a Set of Strings into a string of comma separated values

Parameters:
names - the Set of Strings to transform
Returns:
a string containing each of the Strings in the Set, spearated by a comma, or "Nil" if there are no Strings in the Set

evaluateQuery

protected String evaluateQuery(String s,
                               org.jdom.Element data)
Evaluates an XQuery embedded within a delimited expression

Parameters:
s - the delimited expression, either of the form ${query} or ${expression:query}
data - XML'd data that may be referenced by the expression. May be null if the expression doesn't reference any data
Returns:
the result of the evaluation, or "__evaluation_error__" if there's a problem evaluating the expression

evaluateXQuery

protected String evaluateXQuery(String s,
                                org.jdom.Element data)
Evaluates an XQuery

Parameters:
s - the query expression
data - XML'd data that may be referenced by the expression. May be null if the expression doesn't reference any data
Returns:
the result of the evaluation, or "__evaluation_error__" if there's a problem evaluating the expression

evaluateXQuery

protected String evaluateXQuery(String s,
                                org.jdom.Document dataDoc)

stripDelimiters

protected String stripDelimiters(String s)
removes the surrounding ${...} from a String

Parameters:
s - the delimited String
Returns:
the inner contents of the String with the delimiters removed


Copyright © 2004-2012 The YAWL Foundation.