org.syrup.helpers
Class Utils

java.lang.Object
  extended byorg.syrup.helpers.Utils

public class Utils
extends java.lang.Object

Utility functions to aid the testing of Syrup objects.

Author:
Robbert van Dalen

Constructor Summary
Utils()
           
 
Method Summary
static java.lang.String asDate(long t)
          Utility function that maps a timestamp to a formatted date.
static boolean isDone(boolean in1_done, boolean in2_done, boolean out1_done, boolean out2_done, boolean in1_full, boolean in2_full, boolean out1_full, boolean out2_full, boolean orType, boolean outer_world)
          Returns true if a Task is done based on type and if its inputs are also done.
static boolean isExecutable(boolean firstInFull, boolean secondInFull, boolean firstOutFull, boolean secondOutFull, boolean orType, boolean isDone)
          Returns true if a Task is executable based on type and whether its inputs are filled and all its outputs are empty.
static boolean isFull(Link l)
          Returns true if the Link has content.
static Data manageError(java.util.logging.Logger logger, java.lang.Throwable error, java.lang.String msg)
           
static long parseDate(java.lang.String str)
          Utility function that parses a formatted date to a timestamp.
static void validate(Workflow workflow)
          Validates the Workflow.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

isFull

public static final boolean isFull(Link l)
Returns true if the Link has content.

Parameters:
l - The Link that is tested.
Returns:
true if the Link has content.

validate

public static final void validate(Workflow workflow)
                           throws java.lang.Exception
Validates the Workflow.

Parameters:
workflow - the Workflow to be validated.
Throws:
Execption - the invalid part of the Workflow
java.lang.Exception

isDone

public static final boolean isDone(boolean in1_done,
                                   boolean in2_done,
                                   boolean out1_done,
                                   boolean out2_done,
                                   boolean in1_full,
                                   boolean in2_full,
                                   boolean out1_full,
                                   boolean out2_full,
                                   boolean orType,
                                   boolean outer_world)
Returns true if a Task is done based on type and if its inputs are also done.

Parameters:
in1_done - true if the first input is done.
in2_done - true if the second input is done.
out1_done - true if the first output is done.
out2_done - true if the second output is done.
orType - true if the Task is of type OR.
outer_world - true if the Task represents the outer world.
Returns:
true if a Task is done based on type and if its inputs and if not, the if the outputs are also done.

isExecutable

public static final boolean isExecutable(boolean firstInFull,
                                         boolean secondInFull,
                                         boolean firstOutFull,
                                         boolean secondOutFull,
                                         boolean orType,
                                         boolean isDone)
Returns true if a Task is executable based on type and whether its inputs are filled and all its outputs are empty.

Parameters:
firstInFull - true if the first input is full.
secondInFull - true if the second input is full.
firstOutFull - true if the first output is full.
secondOutFull - true if the second output is full.
orType - true if the Task is of type OR.
isDone - true if the Task is done.
Returns:
true if a Task is executable based on type and whether its inputs are filled and all its outputs are empty.

manageError

public static Data manageError(java.util.logging.Logger logger,
                               java.lang.Throwable error,
                               java.lang.String msg)

asDate

public static final java.lang.String asDate(long t)
Utility function that maps a timestamp to a formatted date.

Parameters:
t - The timestamp to be formatted.
Returns:
The formatted date.

parseDate

public static final long parseDate(java.lang.String str)
                            throws java.lang.Exception
Utility function that parses a formatted date to a timestamp.

Parameters:
str - The date to be parsed.
Returns:
The resulting timestamp.
Throws:
java.lang.Exception