info.aduna.gee.spectacle.gee
Class NavigationRules

java.lang.Object
  extended by info.aduna.gee.spectacle.gee.NavigationRules

public class NavigationRules
extends Object

NavigationRules control the elements of a NavigationSpecification.

It can enforce e.g. the minimum (maximum) depth at which MetaNavigationStep may occur, allow (deny) sequences of labels.

As an application programmer, you should not use this class directly, unless you know what you are doing.


Field Summary
static int MAX_DEPTH
          The absolute maximum number of meta-steps in the navigation.
 
Constructor Summary
NavigationRules()
          Required for Jazzz (and until now the only constructor).
 
Method Summary
protected static Set _removeAll(Set first, Set second)
          This method saves memory by reusing the same set as much as possible.
protected  Set _sharedSetOf(Set s)
          This method saves memory by reusing the same set as much as possible.
protected static Set _unionOf(Set first, Set second)
          This method saves memory by reusing the same set as much as possible.
 void allow(String label, Set labels)
          This is a more friendly interface to NavigationSpecification's allowContentSteps.
 void apply(JitNavigationSpecification spec, Collection pastSteps, Collection futureSteps)
          Apply the current restrictions to a NavigationSpecification, given the collection of MetaNavigationSteps taken and the collection of MetaNavigationSteps still available.
 void deny(String label, Set labels)
          This is a more friendly interface to NavigationSpecification's denyContentSteps.
 void enforceDepth(Object id, int lower, int upper)
          Make sure that a meta step, identified by the id, occurs in a certain depth range only.
 void enforceMaximumDepth(Object id, int upper)
           
 void enforceMinimumDepth(Object id, int lower)
           
 void enforceSequence(Object firstId, Object secondId)
          Make sure that a meta step, identified by secondId, does not occur before a meta step, identified by firstId.
 int getMaxDepth()
          Get the maximum depth of the navigation (in Meta steps only).
 void mergeWith(NavigationRules other)
          Add the restrictions of other to this rules.
 void mutuallyExclusive(Object firstId, Object secondId)
          Make sure that two meta steps never occur in combination.
 void removeSequence(Object firstId, Object secondId)
          Make sure that a meta step, identified by the secondId, does not occur after a meta step, identified by firstId.
 void setMaxDepth(int maxDepth)
          Set the maximum depth of the navigation (in Meta steps only).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_DEPTH

public static final int MAX_DEPTH
The absolute maximum number of meta-steps in the navigation.

See Also:
Constant Field Values
Constructor Detail

NavigationRules

public NavigationRules()
Required for Jazzz (and until now the only constructor).

Method Detail

setMaxDepth

public void setMaxDepth(int maxDepth)
Set the maximum depth of the navigation (in Meta steps only). Note that the maximum should not exceed MAX_DEPTH.

Parameters:
maxDepth - the maximum depth of the navigation (in Meta steps only)
See Also:
MAX_DEPTH

getMaxDepth

public int getMaxDepth()
Get the maximum depth of the navigation (in Meta steps only).

Returns:
the maximum depth of the navigation (in Meta steps only)

enforceDepth

public void enforceDepth(Object id,
                         int lower,
                         int upper)
Make sure that a meta step, identified by the id, occurs in a certain depth range only. Note that depth is in meta navigation steps only and is 0 based.

Parameters:
id - the (internal) name of the meta step
lower - the minimum depth (inclusive)
upper - the maximum depth (inclusive)

enforceMinimumDepth

public void enforceMinimumDepth(Object id,
                                int lower)
See Also:
enforceDepth(java.lang.Object, int, int)

enforceMaximumDepth

public void enforceMaximumDepth(Object id,
                                int upper)
See Also:
enforceDepth(java.lang.Object, int, int)

removeSequence

public void removeSequence(Object firstId,
                           Object secondId)
Make sure that a meta step, identified by the secondId, does not occur after a meta step, identified by firstId.

Note: the effect is different from enforceSequence(secondId, firstId)!

Parameters:
firstId - the (internal) name of the first meta step
secondId - the (internal) name of the second meta step

mutuallyExclusive

public void mutuallyExclusive(Object firstId,
                              Object secondId)
Make sure that two meta steps never occur in combination.

Parameters:
firstId - the (internal) name of the first meta step
secondId - the (internal) name of the second meta step

enforceSequence

public void enforceSequence(Object firstId,
                            Object secondId)
Make sure that a meta step, identified by secondId, does not occur before a meta step, identified by firstId.

Parameters:
firstId - the (internal) name of the first meta step
secondId - the (internal) name of the second meta step

allow

public void allow(String label,
                  Set labels)
This is a more friendly interface to NavigationSpecification's allowContentSteps.

Parameters:
label - the label for which the restrictions apply
labels - the only labels allowed to follow the label -or- when currently labels are denied to follow label, these labels are again allowed

deny

public void deny(String label,
                 Set labels)
This is a more friendly interface to NavigationSpecification's denyContentSteps.

Parameters:
label - the label for which the restrictions apply
labels - the only labels denied to follow the label -or- when currently labels are allowed to follow label, these labels are again denied

apply

public void apply(JitNavigationSpecification spec,
                  Collection pastSteps,
                  Collection futureSteps)
Apply the current restrictions to a NavigationSpecification, given the collection of MetaNavigationSteps taken and the collection of MetaNavigationSteps still available. This method is used by the Spectacle Server internally only.

Parameters:
spec - the unrestricted NavigationSpecification
pastSteps - the MetaNavigationSteps taken
futureSteps - the MetaNavigationSteps still available

mergeWith

public void mergeWith(NavigationRules other)
Add the restrictions of other to this rules.

Parameters:
other - the NavigationRules object to merge with (unchanged)

_unionOf

protected static Set _unionOf(Set first,
                              Set second)
This method saves memory by reusing the same set as much as possible.

Returns:
one of the sets if the other one is null or does not introduce new elements, the union set otherwise.

_removeAll

protected static Set _removeAll(Set first,
                                Set second)
This method saves memory by reusing the same set as much as possible.

Returns:
first if the other one is null or does not remove any elements, the removeAll set otherwise.

_sharedSetOf

protected Set _sharedSetOf(Set s)
This method saves memory by reusing the same set as much as possible.

Returns:
the unique, cloned set equal to s


Copyright © 1997-2008 Aduna. All Rights Reserved.