templates.model
Class Validator

java.lang.Object
  extended by templates.model.Validator

public class Validator
extends java.lang.Object

Validator of the consistency of TemplateModels.

Author:
Lenko Grigorov

Nested Class Summary
static class Validator.ValidatorResult
          Encapsulates a consistency issue found by the validator.
 
Field Summary
static java.lang.String ERROR_FORKED_EVENT
          A channel event is linked to multiple module events.
static java.lang.String ERROR_MERGED_EVENT
          A module event is linked to multiple events from the same channel.
static java.lang.String ERROR_MODULE_CHANNEL
          A link connects two modules or two channels.
static java.lang.String ERROR_NO_EVENT
          A linked event is not contained in the FSAModel of the corresponding TemplateComponent.
static java.lang.String ERROR_NO_MODEL
          A TemplateComponent does not have an assigned FSAModel.
static java.lang.String ERROR_NO_MODULE
          No module is present in the model.
static java.lang.String ERROR_NONUNIQUE_NAME
          The FSAModels of two or more TemplateComponents share the same name.
static java.lang.String WARNING_FREE_COMPONENT
          There is a TemplateComponent which is not connected.
static java.lang.String WARNING_FREE_EVENT
          A channel contains one or more events which are not linked.
static java.lang.String WARNING_NO_CHANNEL
          There is no channel in the model.
 
Constructor Summary
Validator()
           
 
Method Summary
static boolean canComputeSup(TemplateModel model, long channelId)
          Checks if a it is safe to compute the local supervisor for a channel, i.e., if the part of the model involving the channel and the immediate neighbors of the channel contains any consistency issues of type Validator.ValidatorResult.ERROR.
protected static java.util.Collection<TemplateLink> linksWithEvent(TemplateModel model, TemplateComponent component, java.lang.String event)
          Retrieve all TemplateLinks which link a given event of a given TemplateComponent.
static java.util.List<Validator.ValidatorResult> validate(TemplateModel model)
          Validate the consistency of a given TemplateModel and return a collection of all consistency issues discovered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR_NO_MODULE

public static final java.lang.String ERROR_NO_MODULE
No module is present in the model.

See Also:
Constant Field Values

ERROR_NO_MODEL

public static final java.lang.String ERROR_NO_MODEL
A TemplateComponent does not have an assigned FSAModel.

See Also:
Constant Field Values

ERROR_MODULE_CHANNEL

public static final java.lang.String ERROR_MODULE_CHANNEL
A link connects two modules or two channels.

See Also:
Constant Field Values

ERROR_NO_EVENT

public static final java.lang.String ERROR_NO_EVENT
A linked event is not contained in the FSAModel of the corresponding TemplateComponent.

See Also:
Constant Field Values

ERROR_FORKED_EVENT

public static final java.lang.String ERROR_FORKED_EVENT
A channel event is linked to multiple module events.

See Also:
Constant Field Values

ERROR_MERGED_EVENT

public static final java.lang.String ERROR_MERGED_EVENT
A module event is linked to multiple events from the same channel.

See Also:
Constant Field Values

ERROR_NONUNIQUE_NAME

public static final java.lang.String ERROR_NONUNIQUE_NAME
The FSAModels of two or more TemplateComponents share the same name. This becomes a problem when auto-renaming events to indicate which model they belong to.

See Also:
Constant Field Values

WARNING_NO_CHANNEL

public static final java.lang.String WARNING_NO_CHANNEL
There is no channel in the model.

See Also:
Constant Field Values

WARNING_FREE_COMPONENT

public static final java.lang.String WARNING_FREE_COMPONENT
There is a TemplateComponent which is not connected.

See Also:
Constant Field Values

WARNING_FREE_EVENT

public static final java.lang.String WARNING_FREE_EVENT
A channel contains one or more events which are not linked.

See Also:
Constant Field Values
Constructor Detail

Validator

public Validator()
Method Detail

validate

public static java.util.List<Validator.ValidatorResult> validate(TemplateModel model)
Validate the consistency of a given TemplateModel and return a collection of all consistency issues discovered.

Parameters:
model - the TemplateModel to be validated
Returns:
a collection of all consistency issues discovered

canComputeSup

public static boolean canComputeSup(TemplateModel model,
                                    long channelId)
Checks if a it is safe to compute the local supervisor for a channel, i.e., if the part of the model involving the channel and the immediate neighbors of the channel contains any consistency issues of type Validator.ValidatorResult.ERROR.

Parameters:
model - the model containing the channel
channelId - the id of the channel TemplateComponent
Returns:
true if the part of the model involving the channel and the immediate neighbors of the channel does not contain any consistency issues of type Validator.ValidatorResult.ERROR; false otherwise

linksWithEvent

protected static java.util.Collection<TemplateLink> linksWithEvent(TemplateModel model,
                                                                   TemplateComponent component,
                                                                   java.lang.String event)
Retrieve all TemplateLinks which link a given event of a given TemplateComponent.

Parameters:
model - the TemplateModel containing the TemplateComponent
component - the TemplateComponent for which links have to be retrieved
event - the event name for which links have to be retrieved
Returns:
all TemplateLinks which link the given event of the given TemplateComponent