flux
Class EngineHelper

java.lang.Object
  extended by flux.EngineHelper

public abstract class EngineHelper
extends java.lang.Object

Helper methods to be used when interacting with the engine and the Flux system as a whole.

Author:
Copyright 2014 Flux Corporation. All rights reserved.

Constructor Summary
EngineHelper()
           
 
Method Summary
static boolean after(java.util.Date date1, java.util.Date date2)
          Determines if date1 comes after date2.
static java.util.Date applyTimeExpression(java.util.Date relativeTo, java.lang.String timeExpression, AllowableBusinessInterval businessInterval, java.util.TimeZone timeZone)
          Applies the given time expression to the specified date.
static java.util.Date applyTimeExpression(java.util.Date relativeTo, java.lang.String timeExpression, AllowableBusinessInterval businessInterval, java.util.TimeZone timeZone, int count)
          Applies the given time expression to the specified date several times.
static java.util.Date applyTimeExpression(java.lang.String timeExpression, AllowableBusinessInterval businessInterval, java.util.TimeZone timeZone)
          Applies the given time expression to the current date.
static java.util.Date applyTimeExpression(java.lang.String timeExpression, AllowableBusinessInterval businessInterval, java.util.TimeZone timeZone, int count)
          Applies the given time expression to the current date several times.
static boolean before(java.util.Date date1, java.util.Date date2)
          Determines if date1 comes before date2.
static int compareTo(java.util.Date date1, java.util.Date date2)
          Compares two dates for ordering.
static java.lang.Object deserialize(byte[] serializedObject)
          Deserializes the specified array of bytes to an object.
static boolean equals(java.util.Date date1, java.util.Date date2)
          Compares two dates for equality.
static boolean fallsOn(java.util.Date date, java.lang.String unit)
          Determines if the specified date falls on the specified unit.
static boolean fallsOn(java.util.Date date, java.lang.String unit, AllowableBusinessInterval businessInterval, java.util.TimeZone timeZone)
          Determines if the specified date falls on the specified unit.
static CatalogNode getActionCatalog()
          Returns a tree of triggers and actions that can be used to construct flow charts.
static java.util.Properties getApplicationProperties()
          Loads application-specific properties from the "factories.properties" file, which must be located on the system class path, on the current class loader's class path, or in the directory where the JVM is started, which is specified by the system property "user.dir".
static java.beans.BeanInfo getBeanInfo(Action action)
          Returns a BeanInfo object for the specified action, which describes the properties that are defined on a class of triggers or actions.
static java.beans.BeanInfo getBeanInfo(FlowChart flowChart)
          Returns a BeanInfo object for the specified flow chart, which describes the properties that are defined on all flow charts.
static java.util.List<java.lang.String> getNameComponents(java.lang.String namespace)
          Accepts a string that contains "/" symbols and returns each component of that string separately after removing all "/" symbols.
static java.util.SortedSet getPersistentVariableFields(java.lang.Class persistentVariable)
          To aid in working with persistent variables, returns all public fields of the given class, including super classes but not java.lang.Object, that meet certain criteria.
static java.util.TimeZone getTimeZone(java.lang.String timeZone)
          Returns a TimeZone object for the specified time zone.
static BusinessInterval makeBusinessInterval(java.lang.String name)
          Returns a new BusinessInterval with the given name.
static BusinessIntervalFactory makeBusinessIntervalFactory()
          Returns a BusinessIntervalFactory for the creation and manipulation of complex BusinessInterval objects.
static Cron makeCron()
          Makes a new Cron object for manipulating Cron-style time expressions.
static Cron makeCron(CronSlice slice)
          Makes a new Cron object based on a CronSlice.
static CronForLoop makeCronForLoop(CronSlice startConstraint, CronSlice endConstraint, CronSlice incrementConstraint)
          Makes a new Cron "for" loop that represents a timing loop.
static CronForLoop makeCronForLoop(CronSlice startConstraint, CronSlice endConstraint, CronSlice incrementConstraint, int count)
          Makes a new Cron "for" loop that represents a timing loop.
static CronForLoop makeCronForLoop(CronSlice startConstraint, CronSlice incrementConstraint, int count)
          Makes a new Cron "for" loop that represents a timing loop.
static CronOr makeCronOr(java.util.Set<CronSlice> cronSlices)
          Makes a new Cron "or" that represents a logical "or" of many Cron slices.
static CronSlice makeCronSlice(CronColumn start, CronColumn end)
          Makes a new CronSlice object based on the specified starting and ending Cron columns.
static java.lang.String makeDate(java.util.Date date)
          Makes a string date from the date object using the default time zone; the time zone is displayed in the string date.
static java.util.Date makeDate(java.lang.String date)
          Makes a date from the given string date; the time zone is included in the string date.
static java.lang.String makeDateInDefaultTimeZone(java.util.Date date)
          Makes a string date from the date object using the default time zone; the default time zone is not displayed in the string date.
static java.util.Date makeDateInDefaultTimeZone(java.lang.String date)
          Makes a date from the given string date in the default time zone; any time zone in the string date is ignored.
static FlowChart makeFlowChart()
          Creates a new flow chart with a name equal to "/".
static FlowChart makeFlowChart(java.lang.String name)
          Creates a new flow chart with the given name.
static java.util.List<FlowChart> makeFlowChartsFromCrontab(java.io.InputStream crontabInputStream)
          Creates a list of flow charts from a Crontab input stream, which represents a standard Unix Crontab file that contains Unix Cron jobs.
static java.util.List<FlowChart> makeFlowChartsFromXml(java.io.InputStream xmlStream)
          Creates a list of flow charts from an XML input stream.
static java.util.List<FlowChart> makeFlowChartsFromXml(java.io.InputStream xmlStream, boolean verify)
          Creates a list of flow charts from an XML input stream.
static java.lang.Object makeJavaBeanFromXml(java.io.InputStream xmlStream)
          Creates a JavaBean from an XML input stream, which conforms to the XML DTD file java-bean-5-0.dtd.
static Relative makeRelative()
          Makes a new Relative object for manipulating Relative time expressions.
static TimeExpression makeTimeExpression(java.lang.String timeExpression)
          Makes either a Cron time expression object or a Relative time expression object, based on the specified time expression string.
static java.sql.Timestamp makeTimestamp(java.lang.String timestamp)
          Makes a timestamp from the given string timestamp; the time zone is included in the string timestamp.
static java.lang.String makeTimestamp(java.sql.Timestamp timestamp)
          Makes a string timestamp from the timestamp object using the default time zone; the time zone is displayed in the string timestamp.
static java.sql.Timestamp makeTimestampInDefaultTimeZone(java.lang.String timestamp)
          Makes a timestamp from the given string timestamp in the default time zone; any time zone in the string timestamp is ignored.
static java.lang.String makeTimestampInDefaultTimeZone(java.sql.Timestamp timestamp)
          Makes a string timestamp from the timestamp object using the default time zone; the default time zone is not displayed in the string timestamp.
static void makeXmlFromFlowCharts(java.util.List<FlowChart> flowCharts, java.io.OutputStream xmlStream, boolean verify)
          Writes one or more flow charts to an XML output stream.
static void makeXmlFromJavaBean(java.lang.Object javaBean, java.io.OutputStream xmlStream)
          Writes a JavaBean to an XML output stream, which conforms to the XML DTD file java-bean-5-0.dtd.
static java.util.Date max(java.util.Date date1, java.util.Date date2)
          Returns the greater date.
static java.util.Date min(java.util.Date date1, java.util.Date date2)
          Returns the lesser date.
static byte[] serialize(java.lang.Object object)
          Serializes the specified object to an array of bytes.
static java.util.Date skip(java.util.Date start, java.util.Date limit, java.lang.String timeExpression, AllowableBusinessInterval businessInterval)
          Repeatedly applies the time expression to the start date to derive the smallest date that meets or exceeds the limit date.
static java.util.Date skip(java.util.Date start, java.util.Date limit, java.lang.String timeExpression, AllowableBusinessInterval businessInterval, int count)
          Repeatedly applies the time expression to the start date until the repeat count expires or the smallest date that meets or exceeds the limit date is calculated.
static java.lang.String useLastResult()
          Generates a conditional expression that the engine will evaluate in a flow to access the previous action's result variable, which must be one of Java's built-in types: Boolean, Byte, Character, Double, Float, Integer, Long, Short, and String.
static java.lang.String useLastResult(java.lang.String field)
          Generates a conditional expression that the engine will evaluate in a flow to access the previous action's result variable, which must not be one of Java's built-in types.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EngineHelper

public EngineHelper()
Method Detail

after

public static boolean after(java.util.Date date1,
                            java.util.Date date2)
Determines if date1 comes after date2.

Parameters:
date1 - The first date.
date2 - The second date.
Returns:
true If and only if date1 > date2.

applyTimeExpression

public static java.util.Date applyTimeExpression(java.util.Date relativeTo,
                                                 java.lang.String timeExpression,
                                                 AllowableBusinessInterval businessInterval,
                                                 java.util.TimeZone timeZone)
                                          throws EngineException
Applies the given time expression to the specified date.

For example, if the specified date is 9:00 and the specified time expression is "+15m", this method returns a date representing 9:15 in the local time zone. Any time expression can be used. If the time expression references business time, a business interval must be supplied. Finally, if the time expression is dependent on a time zone, which is almost always the case with Cron-style time expressions, a time zone other than the local time zone can be used if a separate time zone is supplied.

As an example of using a separate time zone, the Cron-style time expression "0 0 0 6" fires daily at 6:00 in the local time zone. To fire daily at 6:00 in the Singapore time zone, supply a time zone object for the Singapore time zone.

Parameters:
relativeTo - The date to which the time expression is applied.
timeExpression - The time expression to apply to the given relative date.
businessInterval - The optional business interval to use. May be null.
timeZone - The optional time zone to use. May be null.
Returns:
The generated date.
Throws:
EngineException - If the time expression is invalid.

applyTimeExpression

public static java.util.Date applyTimeExpression(java.util.Date relativeTo,
                                                 java.lang.String timeExpression,
                                                 AllowableBusinessInterval businessInterval,
                                                 java.util.TimeZone timeZone,
                                                 int count)
                                          throws EngineException
Applies the given time expression to the specified date several times.

For example, if the specified date is 9:00, the count is one, and the specified time expression is "+15m", this method returns a date representing 9:15 in the local time zone. Similarly, if the count is two, this method returns 9:30.

Any time expression can be used. If the time expression references business time, a business interval must be supplied. Finally, if the time expression is dependent on a time zone, which is almost always the case with Cron-style time expressions, a time zone other than the local time zone can be used if a separate time zone is supplied.

As an example of using a separate time zone, the Cron-style time expression "0 0 0 6" fires daily at 6:00 in the local time zone. To fire daily at 6:00 in the Singapore time zone, supply a time zone object for the Singapore time zone.

Parameters:
relativeTo - The date to which the time expression is applied.
timeExpression - A time expression.
businessInterval - The optional business interval to use. May be null.
timeZone - The optional time zone to use. May be null.
count - The number of times to apply the time expression.
Returns:
A date after repeatedly applying the time expression to the given starting date.
Throws:
EngineException - If the time expression is invalid.

applyTimeExpression

public static java.util.Date applyTimeExpression(java.lang.String timeExpression,
                                                 AllowableBusinessInterval businessInterval,
                                                 java.util.TimeZone timeZone)
                                          throws EngineException
Applies the given time expression to the current date.

For example, if the current time is 9:00 and the specified time expression is "+15m", this method returns a date representing 9:15 in the local time zone. Any time expression can be used. If the time expression references business time, a business interval must be supplied. Finally, if the time expression is dependent on a time zone, which is almost always the case with Cron-style time expressions, a time zone other than the local time zone can be used if a separate time zone is supplied.

As an example of using a separate time zone, the Cron-style time expression "0 0 0 6" fires daily at 6:00 in the local time zone. To fire daily at 6:00 in the Singapore time zone, supply a time zone object for the Singapore time zone.

Parameters:
timeExpression - The time expression to apply to the current date.
businessInterval - The optional business interval to use. May be null.
timeZone - The optional time zone to use. May be null.
Returns:
The generated date.
Throws:
EngineException - If the time expression is invalid.

applyTimeExpression

public static java.util.Date applyTimeExpression(java.lang.String timeExpression,
                                                 AllowableBusinessInterval businessInterval,
                                                 java.util.TimeZone timeZone,
                                                 int count)
                                          throws EngineException
Applies the given time expression to the current date several times.

For example, if the current time is 9:00, the count is one, and the specified time expression is "+15m", this method returns a date representing 9:15 in the local time zone. Similarly, if the count is two, this method returns 9:30.

Any time expression can be used. If the time expression references business time, a business interval must be supplied. Finally, if the time expression is dependent on a time zone, which is almost always the case with Cron-style time expressions, a time zone other than the local time zone can be used if a separate time zone is supplied.

As an example of using a separate time zone, the Cron-style time expression "0 0 0 6" fires daily at 6:00 in the local time zone. To fire daily at 6:00 in the Singapore time zone, supply a time zone object for the Singapore time zone.

Parameters:
timeExpression - A time expression.
businessInterval - The optional business interval to use. May be null.
timeZone - The optional time zone to use. May be null.
count - The number of times to apply the time expression.
Returns:
A date after repeatedly applying the time expression to the current time.
Throws:
EngineException - If the time expression is invalid.

before

public static boolean before(java.util.Date date1,
                             java.util.Date date2)
Determines if date1 comes before date2.

Parameters:
date1 - The first date.
date2 - The second date.
Returns:
true If and only if date1 < date2.

compareTo

public static int compareTo(java.util.Date date1,
                            java.util.Date date2)
Compares two dates for ordering.

Parameters:
date1 - The first date.
date2 - The second date.
Returns:
The value 0 if date1 is equal to date2; a value less than 0 if date1 is before date2; and a value greater than 0 if date1 is after date2.

deserialize

public static java.lang.Object deserialize(byte[] serializedObject)
                                    throws java.io.IOException,
                                           java.lang.ClassNotFoundException
Deserializes the specified array of bytes to an object.

Parameters:
serializedObject - The object to deserialize.
Returns:
The deserialized object.
Throws:
java.io.IOException - If a deserialization error occurs.
java.lang.ClassNotFoundException - If the deserialized class cannot be found.

equals

public static boolean equals(java.util.Date date1,
                             java.util.Date date2)
Compares two dates for equality.

Parameters:
date1 - The first date.
date2 - The second date.
Returns:
true If and only if date1 is equivalent to date2.

fallsOn

public static boolean fallsOn(java.util.Date date,
                              java.lang.String unit)
Determines if the specified date falls on the specified unit. For example, this method can calculate if the specified date is a Tuesday.

Parameters:
date - The date to check.
unit - Day-of-week, month-of-year, holiday, non-holiday, weekday, weekend day, or business day.
Returns:
true If and only if the date falls on the unit.

fallsOn

public static boolean fallsOn(java.util.Date date,
                              java.lang.String unit,
                              AllowableBusinessInterval businessInterval,
                              java.util.TimeZone timeZone)
Determines if the specified date falls on the specified unit. For example, this method can calculate if the specified date is a Tuesday.

Parameters:
date - The date to check.
unit - Day-of-week, month-of-year, holiday, non-holiday, weekday, weekend day, or business day.
businessInterval - Used if the unit requires it.
timeZone - if this date is to be oriented to a time zone other than the default. May be null.
Returns:
true If and only if the date falls on the unit.

getActionCatalog

public static CatalogNode getActionCatalog()
                                    throws EngineException
Returns a tree of triggers and actions that can be used to construct flow charts. Any custom factories that are described in the file "factories.properties" are included in the result.

The result can be used to list all triggers and actions available to the Flux engine. The result can also be used to find the names of all the action factories. Each node in the result tree that has at least one child represents an action factory.

Returns:
A tree of triggers and actions that can be used to construct flow charts.
Throws:
EngineException - If a system error occurs.
See Also:
FlowChart.makeFactory(java.lang.String)

getApplicationProperties

public static java.util.Properties getApplicationProperties()
                                                     throws EngineException
Loads application-specific properties from the "factories.properties" file, which must be located on the system class path, on the current class loader's class path, or in the directory where the JVM is started, which is specified by the system property "user.dir".

Returns:
Application-specific properties.
Throws:
EngineException - If a system error occurs.

getBeanInfo

public static java.beans.BeanInfo getBeanInfo(Action action)
Returns a BeanInfo object for the specified action, which describes the properties that are defined on a class of triggers or actions. Different instances of the same trigger or action use the same BeanInfo object to enumerate and describe action properties.

Parameters:
action - A trigger or action object.
Returns:
A BeanInfo object for the specified action.

getBeanInfo

public static java.beans.BeanInfo getBeanInfo(FlowChart flowChart)
Returns a BeanInfo object for the specified flow chart, which describes the properties that are defined on all flow charts.

Parameters:
flowChart - A flow chart object.
Returns:
A BeanInfo object for the specified flow chart.

getNameComponents

public static java.util.List<java.lang.String> getNameComponents(java.lang.String namespace)
Accepts a string that contains "/" symbols and returns each component of that string separately after removing all "/" symbols.

Parameters:
namespace - A string to parse into components.
Returns:
Returns each component separately after removing all "/" symbols.
Throws:
java.lang.IllegalArgumentException - If namespace is null.

getPersistentVariableFields

public static java.util.SortedSet getPersistentVariableFields(java.lang.Class persistentVariable)
To aid in working with persistent variables, returns all public fields of the given class, including super classes but not java.lang.Object, that meet certain criteria. These criteria are:

  1. The public field must not be declared "static", "final", or "transient".
  2. The public field must not be a collection.

Parameters:
persistentVariable - A kind of persistent variable.
Returns:
Sorted by field name. Each set element represents a field in a persistent variable that meets the above criteria.

getTimeZone

public static java.util.TimeZone getTimeZone(java.lang.String timeZone)
Returns a TimeZone object for the specified time zone.

Parameters:
timeZone - A time zone such as "America/New_York".
Returns:
A corresponding TimeZone object.
Throws:
java.lang.IllegalArgumentException - If the JVM does not recognize the time zone.

makeBusinessInterval

public static BusinessInterval makeBusinessInterval(java.lang.String name)
Returns a new BusinessInterval with the given name.

Parameters:
name - The name of the new BusinessInterval.
Returns:
A new BusinessInterval with the given name.

makeBusinessIntervalFactory

public static BusinessIntervalFactory makeBusinessIntervalFactory()
Returns a BusinessIntervalFactory for the creation and manipulation of complex BusinessInterval objects.

Returns:
A new BusinessIntervalFactory object.
See Also:
for creating simple BusinessInterval objects.

makeCron

public static Cron makeCron()
Makes a new Cron object for manipulating Cron-style time expressions.

Returns:
A new Cron object.

makeCron

public static Cron makeCron(CronSlice slice)
Makes a new Cron object based on a CronSlice. Any Cron columns not represented in the CronSlice receive default values.

Parameters:
slice - A contiguous subset of Cron columns.
Returns:
A new Cron object based on a CronSlice.

makeCronForLoop

public static CronForLoop makeCronForLoop(CronSlice startConstraint,
                                          CronSlice endConstraint,
                                          CronSlice incrementConstraint)
Makes a new Cron "for" loop that represents a timing loop. The timing loop begins with the specified startConstraint, finishes with the specified endConstraint, and contains intermittent timing points as specified by the increment constraint.

Parameters:
startConstraint - The constraint when the timing loop begins.
endConstraint - The constraint when the timing loop finishes.
incrementConstraint - Specifies intermittent timing points between the start and end constraint.
Returns:
A new Cron "for" loop that represents a timing loop.

makeCronForLoop

public static CronForLoop makeCronForLoop(CronSlice startConstraint,
                                          CronSlice endConstraint,
                                          CronSlice incrementConstraint,
                                          int count)
Makes a new Cron "for" loop that represents a timing loop. The timing loop begins with the specified startConstraint, finishes with the specified endConstraint, and contains intermittent timing points as specified by the increment constraint. The timing loop finishes when the endConstraint is reached or when the loop count is exhausted, whichever comes first.

Parameters:
startConstraint - The constraint when the timing loop begins.
endConstraint - The constraint when the timing loop finishes.
incrementConstraint - Specifies intermittent timing points between the start and end constraint.
count - The maximum number of times the timing loop will fire. The constant INFINITY may be used.
Returns:
A new Cron "for" loop that represents a timing loop.
See Also:
CronForLoop.INFINITY

makeCronForLoop

public static CronForLoop makeCronForLoop(CronSlice startConstraint,
                                          CronSlice incrementConstraint,
                                          int count)
Makes a new Cron "for" loop that represents a timing loop. The timing loop begins with the specified startConstraint, and contains intermittent timing points as specified by the increment constraint. The timing loop finishes when the loop count is exhausted.

Parameters:
startConstraint - The constraint when the timing loop begins.
incrementConstraint - Specifies intermittent timing points between the start and end constraint.
count - The maximum number of times the timing loop will fire. The constant INFINITY may be used.
Returns:
A new Cron "for" loop that represents a timing loop.
See Also:
CronForLoop.INFINITY

makeCronOr

public static CronOr makeCronOr(java.util.Set<CronSlice> cronSlices)
Makes a new Cron "or" that represents a logical "or" of many Cron slices. This logical "or" defines a new Cron "or" where any of the sub-Cron slices may be used, depending on which one represents an earlier point in time. The Cron columns spanned by all Cron slices must be identical.

Parameters:
cronSlices - Each Cron slice forms the logical "or".
Returns:
A new Cron "or" that represents a logical "or" of many Cron slices.
Throws:
java.lang.IllegalArgumentException - If any of the Cron slices is a Cron "for" loop. Cron "for" loops may not be used in a Cron "or".

makeCronSlice

public static CronSlice makeCronSlice(CronColumn start,
                                      CronColumn end)
Makes a new CronSlice object based on the specified starting and ending Cron columns. The new CronSlice represents a contiguous subset of Cron columns.

Parameters:
start - The starting Cron column for the new CronSlice.
end - The ending Cron column for the new CronSlice.
Returns:
A new CronSlice that represents a contiguous subset of Cron columns.
Throws:
java.lang.IllegalArgumentException - If the ending Cron column precedes the starting Cron column.

makeDate

public static java.lang.String makeDate(java.util.Date date)
Makes a string date from the date object using the default time zone; the time zone is displayed in the string date. The string date is of the form, "yyyy MMM d HH:mm:ss.SSS zzzz", which is a format used by java.text.SimpleDateFormat. For example, the date specification "2002 Mar 13 12:30:15.500 Eastern Standard Time" specifies an instant in time, using the EST time zone as a reference point. The month is spelled using the standard spellings in the United States, which is the same as the month spellings used in time expressions.

Parameters:
date - An instant in time.
Returns:
The corresponding string date.
See Also:
SimpleDateFormat

makeDate

public static java.util.Date makeDate(java.lang.String date)
Makes a date from the given string date; the time zone is included in the string date. The string date is of the form, "yyyy MMM d HH:mm:ss.SSS zzzz", which is a format used by java.text.SimpleDateFormat. For example, the date specification "2002 Mar 13 12:30:15.500 Eastern Standard Time" specifies an instant in time, using the EST time zone as a reference point. The month is spelled using the standard spellings in the United States, which is the same as the month spellings used in time expressions.

Parameters:
date - The date specification.
Returns:
A date from the given specification.
Throws:
java.lang.IllegalArgumentException - If the date specification is illegal.
See Also:
SimpleDateFormat

makeDateInDefaultTimeZone

public static java.lang.String makeDateInDefaultTimeZone(java.util.Date date)
Makes a string date from the date object using the default time zone; the default time zone is not displayed in the string date. The string date is of the form, "yyyy MMM d HH:mm:ss.SSS", which is a format used by java.text.SimpleDateFormat. For example, the date specification "2002 Mar 13 12:30:15.500" specifies an instant in time, using the default time zone as a reference point. The month is spelled using the standard spellings in the United States, which is the same as the month spellings used in time expressions.

Parameters:
date - An instant in time.
Returns:
The corresponding string date.
See Also:
SimpleDateFormat

makeDateInDefaultTimeZone

public static java.util.Date makeDateInDefaultTimeZone(java.lang.String date)
Makes a date from the given string date in the default time zone; any time zone in the string date is ignored. The string date is of the form, "yyyy MMM d HH:mm:ss.SSS", which is a format used by java.text.SimpleDateFormat. For example, the string date "2002 Mar 13 12:30:15.500" specifies an instant in time, using the default, local time zone as a reference point. The month is spelled using the standard spellings in the United States, which is the same as the month spellings used in time expressions.

Parameters:
date - The date specification.
Returns:
A date from the given specification.
Throws:
java.lang.IllegalArgumentException - If the date specification is illegal.
See Also:
SimpleDateFormat

makeFlowChart

public static FlowChart makeFlowChart()
Creates a new flow chart with a name equal to "/". After the flow chart is inserted into an engine, the engine automatically generates and returns a unique, fully-qualified flow chart name such as "/392".

Returns:
A new flow chart with a name equal to "/".

makeFlowChart

public static FlowChart makeFlowChart(java.lang.String name)
Creates a new flow chart with the given name. Each flow chart has a name. The name can be hierarchical. For example, the names "/my flow chart", "/heavyweights/my big job", and "/lightweights/my little job" are hierarchical and form a tree. The "/" symbol is the separator character that defines the different branches in the hierarchical tree. Collectively, all flow chart names form a hierarchical flow chart namespace, that is, a tree of jobs.

If a flow chart name is incomplete, because it refers to a directory in the namespace and not an actual flow chart name, the engine automatically generates and returns a unique, fully-qualified flow chart name, after the flow chart is inserted into an engine.

For example, if the flow chart name is null, empty, or "/", then the engine generates a unique name such as "/392" and returns it. Similarly, if the flow chart name is "/heavyweights/", then the engine returns a name such as "/heavyweights/72939".

The name may not contain any of the following characters: "*", "?", "%", "_", ".", or "$".

Parameters:
name - The name of the flow chart. The name may be null or empty.
Returns:
A new flow chart.

makeFlowChartsFromCrontab

public static java.util.List<FlowChart> makeFlowChartsFromCrontab(java.io.InputStream crontabInputStream)
                                                           throws EngineException
Creates a list of flow charts from a Crontab input stream, which represents a standard Unix Crontab file that contains Unix Cron jobs. The generated flow charts are equivalent to the Unix jobs in the Unix Crontab file. The input stream will not be closed.

Each generated flow chart is unnamed and consists of a timer trigger with a Cron-style time expression that is equivalent (but not identical) to the corresponding Unix Crontab entry. The timer trigger flows into a process action. Finally, the process action flows back to the timer trigger.

The process action executes a native process using the following command line:

 /bin/sh -c ''
 

The string "" in the above command line is replaced by the appropriate Unix command from the Unix Crontab file.

Parameters:
crontabInputStream - A Crontab input stream of Unix Cron jobs.
Returns:
The Unix Cron jobs represented as flow charts.
Throws:
EngineException - If a system error occurs.

makeFlowChartsFromXml

public static java.util.List<FlowChart> makeFlowChartsFromXml(java.io.InputStream xmlStream)
                                                       throws EngineException
Creates a list of flow charts from an XML input stream. The input stream will not be closed. Verifies that the incoming flow charts are valid.

Parameters:
xmlStream - An XML input stream of flow charts.
Returns:
The output flow charts.
Throws:
EngineException - If the XML stream could not be converted to flow charts.

makeFlowChartsFromXml

public static java.util.List<FlowChart> makeFlowChartsFromXml(java.io.InputStream xmlStream,
                                                              boolean verify)
                                                       throws EngineException
Creates a list of flow charts from an XML input stream. The input stream will not be closed.

Parameters:
xmlStream - An XML input stream of flow charts.
verify - Indicates whether to check if the incoming flow charts are valid.
Returns:
The output flow charts.
Throws:
EngineException - If the XML stream could not be converted to flow charts.

makeJavaBeanFromXml

public static java.lang.Object makeJavaBeanFromXml(java.io.InputStream xmlStream)
                                            throws EngineException
Creates a JavaBean from an XML input stream, which conforms to the XML DTD file java-bean-5-0.dtd. The input stream will not be closed.

Parameters:
xmlStream - An XML input stream containing a JavaBean.
Returns:
A JavaBean represented by the XML input stream.
Throws:
EngineException - If xmlStream could not be converted to a JavaBean.

makeRelative

public static Relative makeRelative()
Makes a new Relative object for manipulating Relative time expressions.

Returns:
A new Relative object.

makeTimeExpression

public static TimeExpression makeTimeExpression(java.lang.String timeExpression)
                                         throws EngineException
Makes either a Cron time expression object or a Relative time expression object, based on the specified time expression string. Both objects implement the TimeExpression interface.

Parameters:
timeExpression - A time expression in string form.
Returns:
Either a Cron time expression object or a Relative time expression object, based on the specified time expression string.
Throws:
EngineException - If the time expression is invalid.

makeTimestamp

public static java.sql.Timestamp makeTimestamp(java.lang.String timestamp)
Makes a timestamp from the given string timestamp; the time zone is included in the string timestamp. The string timestamp is of the form, "yyyy MMM d HH:mm:ss.nnnnnnnnn zzzz", which is a format used by java.text.SimpleDateFormat except that 'n' represents the number of nanoseconds that represent the fractional seconds. For example, the timestamp specification "2002 Mar 13 12:30:15.500100100 Eastern Standard Time" specifies an instant in time, using the EST time zone as a reference point. The month is spelled using the standard spellings in the United States, which is the same as the month spellings used in time expressions.

Parameters:
timestamp - The timestamp specification.
Returns:
A timestamp from the given specification.
Throws:
java.lang.IllegalArgumentException - If the date specification is illegal.
See Also:
SimpleDateFormat

makeTimestamp

public static java.lang.String makeTimestamp(java.sql.Timestamp timestamp)
Makes a string timestamp from the timestamp object using the default time zone; the time zone is displayed in the string timestamp. The string timestamp is of the form, "yyyy MMM d HH:mm:ss.nnnnnnnnn zzzz", which is a format used by java.text.SimpleDateFormat except that 'n' represents the number of nanoseconds that represent the fractional seconds. For example, the timestamp specification "2002 Mar 13 12:30:15.500100100 Eastern Standard Time" specifies an instant in time, using the EST time zone as a reference point. The month is spelled using the standard spellings in the United States, which is the same as the month spellings used in time expressions.

Parameters:
timestamp - An instant in time.
Returns:
The corresponding string timestamp.
See Also:
SimpleDateFormat

makeTimestampInDefaultTimeZone

public static java.sql.Timestamp makeTimestampInDefaultTimeZone(java.lang.String timestamp)
Makes a timestamp from the given string timestamp in the default time zone; any time zone in the string timestamp is ignored. The string timestamp is of the form, "yyyy MMM d HH:mm:ss.nnnnnnnnn", which is a format used by java.text.SimpleDateFormat except that 'n' represents the number of nanoseconds that represent the fractional seconds. For example, the string timestamp "2002 Mar 13 12:30:15.500100100" specifies an instant in time, using the default, local time zone as a reference point. The month is spelled using the standard spellings in the United States, which is the same as the month spellings used in time expressions.

Parameters:
timestamp - The timestamp specification.
Returns:
A timestamp from the given specification.
Throws:
java.lang.IllegalArgumentException - If the date specification is illegal.
See Also:
SimpleDateFormat

makeTimestampInDefaultTimeZone

public static java.lang.String makeTimestampInDefaultTimeZone(java.sql.Timestamp timestamp)
Makes a string timestamp from the timestamp object using the default time zone; the default time zone is not displayed in the string timestamp. The string timestamp is of the form, "yyyy MMM d HH:mm:ss.nnnnnnnnn", which is a format used by java.text.SimpleDateFormat except that 'n' represents the number of nanoseconds that represent the fractional seconds. For example, the timestamp specification "2002 Mar 13 12:30:15.500100100" specifies an instant in time, using the default time zone as a reference point. The month is spelled using the standard spellings in the United States, which is the same as the month spellings used in time expressions.

Parameters:
timestamp - An instant in time.
Returns:
The corresponding string timestamp.
See Also:
SimpleDateFormat

makeXmlFromFlowCharts

public static void makeXmlFromFlowCharts(java.util.List<FlowChart> flowCharts,
                                         java.io.OutputStream xmlStream,
                                         boolean verify)
                                  throws EngineException
Writes one or more flow charts to an XML output stream. The output stream will not be closed. Verifies that the outgoing flow charts are valid.

Parameters:
flowCharts - The flow charts to render into XML.
xmlStream - An XML output stream of flow charts.
verify - Indicates whether to check if the outgoing flow charts are valid.
Throws:
EngineException - If a system error occurs.

makeXmlFromJavaBean

public static void makeXmlFromJavaBean(java.lang.Object javaBean,
                                       java.io.OutputStream xmlStream)
                                throws EngineException
Writes a JavaBean to an XML output stream, which conforms to the XML DTD file java-bean-5-0.dtd. The output stream will not be closed.

Parameters:
javaBean - A JavaBean to write to xmlStream.
xmlStream - An XML output stream to receive the JavaBean.
Throws:
EngineException - If the JavaBean could not be written to xmlStream.

max

public static java.util.Date max(java.util.Date date1,
                                 java.util.Date date2)
Returns the greater date.

Parameters:
date1 - The first date.
date2 - The second date.
Returns:
date1 if date1 > date2; date2 if date1 < date2; and either date2 or date1 if they are equal.

min

public static java.util.Date min(java.util.Date date1,
                                 java.util.Date date2)
Returns the lesser date.

Parameters:
date1 - The first date.
date2 - The second date.
Returns:
date1 if date1 < date2; date2 if date1 > date2; and either date2 or date1 if they are equal.

serialize

public static byte[] serialize(java.lang.Object object)
                        throws java.io.IOException
Serializes the specified object to an array of bytes.

Parameters:
object - The object to serialize.
Returns:
The serialized object.
Throws:
java.io.IOException - If a serialization error occurs.

skip

public static java.util.Date skip(java.util.Date start,
                                  java.util.Date limit,
                                  java.lang.String timeExpression,
                                  AllowableBusinessInterval businessInterval)
                           throws EngineException
Repeatedly applies the time expression to the start date to derive the smallest date that meets or exceeds the limit date.

Parameters:
start - The Date to start the calculation from.
limit - When the calculation meets or exceeds this date, the method returns.
timeExpression - A time expression.
businessInterval - The optional business interval to use. May be null.
Returns:
The calculated date.
Throws:
EngineException - If the time expression is invalid.

skip

public static java.util.Date skip(java.util.Date start,
                                  java.util.Date limit,
                                  java.lang.String timeExpression,
                                  AllowableBusinessInterval businessInterval,
                                  int count)
                           throws EngineException
Repeatedly applies the time expression to the start date until the repeat count expires or the smallest date that meets or exceeds the limit date is calculated.

Parameters:
start - The Date to start the calculation from.
limit - If the calculation meets or exceeds this date, the method returns.
timeExpression - A time expression.
businessInterval - The optional business interval to use. May be null.
count - The maximum number of times to apply the Time Expression.
Returns:
The calculated date.
Throws:
EngineException - If the time expression is invalid.

useLastResult

public static java.lang.String useLastResult()
Generates a conditional expression that the engine will evaluate in a flow to access the previous action's result variable, which must be one of Java's built-in types: Boolean, Byte, Character, Double, Float, Integer, Long, Short, and String.

Returns:
The conditional expression.

useLastResult

public static java.lang.String useLastResult(java.lang.String field)
Generates a conditional expression that the engine will evaluate in a flow to access the previous action's result variable, which must not be one of Java's built-in types. If the previous actions' result variable is a built-in Java type, call useLastResult() instead.

Parameters:
field - The field name of the result variable to access.
Returns:
The conditional expression.
See Also:
useLastResult()


© 2014 Flux Corporation. All rights reserved.