Navigator - examples

Printer-friendly versionPrinter-friendly version
How to use the Navigator framework

 

In addition, each navigation starts with an initialization phase and ends with an finalization phase. These 2 phases are not related to any given navigable, but can be used to initialize respectively finalize the Navigator itself, e.g. to open and close system resources or any other algorithm which is to be executed just once and shall not be omitted.

See here an implementation of our Navigator with all "can..."-operations for NavigationPhases:

public class ConcreteNavigator1 extends AbstractParentNavigator {
    
    @Override
    public void access(ConcreteChild1 concreteChild1) {
        super.access(concreteChild1);
        if (canInitialize()) {
            // initialize this
        }
        if (canRoute(concreteChild1)) {
            // access public members of "concreteChild1"
        }
        if (canEnter(concreteChild1)) {
            // access public members of "concreteChild1"
        }
        if (canReenter(concreteChild1)) {
            // access public members of "concreteChild1"
        }
        if (canFinalize()) {
            // finalize this
        }
    }
    
}

In the routing phase ("canRoute") you may call e.g. omitEntry(Navigable), omitReentry(Navigable) or omitContinuation(Navigable), in order to skip NavigationPhases for a given Navigable. The routing phase is the first phase for each Navigable we navigate, but it requires that the routing is enabled (see NavigatorBase), which is the default. The routing can also take place before each and every following NavigationPhase. This is called rerouting and allows to change the routing during navigation (e.g. due to results from the previous phase which we cannot evaluate in the first routing and to skip the next phase). Rerouting is disabled by default (see NavigatorBase), but we could enable it even for individual Navigables in the first routing phase.

 

The NavigatorBase provides several hook methods which a concrete Navigator can override. E.g. hooks to initialize and finalize the navigation and hooks for a fine-grained control of if, which and how next Navigables are navigated. Here we can e.g. filter and sort the given children or skip all of them.

 

 

Páginas