| Package | org.granite.reflect.visitor |
| Class | public class Guide |
Guide class is the entry point of the visitor pattern
implementation. It uses an array of IHandlers in order to
explore and expose to a visitor the properties of a given bean.
Exploring a beans graph is a sequence of two-phases processes: for each
bean, first, the visitor is asked if it accepts to visit each property
of the current bean; second, for each accepted property of this bean,
the property is visited and cascaded.
A Guide instance is not intended to be used more than once.
Any attempt to reuse an already used intance will throw an error.
A typical usage would be:
var guide:Guide = new Guide(new MyVisitorImpl()); guide.explore(myBean);
See also
| Property | Defined by | ||
|---|---|---|---|
| defaultHandlers : Array [static][read-only]
The array of the default handlers (not including the
NullHandler)used when visiting a given bean. | Guide | ||
| handlers : Array [read-only]
The array
IHandlers used by this Guide instance. | Guide | ||
| recursionStrategy : String [read-only]
The recursion strategy used by this
Guide instance. | Guide | ||
| visitor : IVisitor
[read-only]
The
IVisitor implementation used by this Guide instance. | Guide | ||
| Method | Defined by | ||
|---|---|---|---|
|
Constructs a new
Guide that will explore a given bean and
expose its properties to the supplied visitor implementation. | Guide | ||
|
explore(o:*):void
Explore the supplied bean, exposing its properties to the current visitor.
| Guide | ||
|
exploreVisitable(visitable:Visitable):void
Explore the supplied
Visitable, exposing its properties to the
current visitor. | Guide | ||
| Method | Defined by | ||
|---|---|---|---|
|
Try to find a
IHandler instance that will handle the visit of the visitable
item by the visitor object. | Guide | ||
|
isInContext(value:*):Boolean
Checks if the supplied parameter is already in the recursion context (ie.
| Guide | ||
|
popFromContext(value:*):void
Remove the supplied parameter from the recursion context (this method does nothing when
the recursion strategy is "dictionary").
| Guide | ||
|
pushInContext(value:*):void
Put the supplied parameter in the recursion context (so it is marked as already visited).
| Guide | ||
| Constant | Defined by | ||
|---|---|---|---|
| RS_DICTIONARY : String = "dictionary" [static]
The constant for "dictionary" recursion strategy: an instance of a
bean is only visited once, even if it appears several times in an
objects graph (this is the default).
| Guide | ||
| RS_STACK : String = "stack" [static]
The constant for "stack" recursion strategy: an instance of a
bean is visited if and only if it wasn't already visited in the
current path fo the objects graph.
| Guide | ||
| defaultHandlers | property |
defaultHandlers:Array [read-only]
The array of the default handlers (not including the
NullHandler)used when visiting a given bean.
This array may be modified in order to globally add a specific
handler (or replace an existing one).
public static function get defaultHandlers():Array
| handlers | property |
handlers:Array [read-only]
The array IHandlers used by this Guide instance.
public function get handlers():Array
| recursionStrategy | property |
recursionStrategy:String [read-only]
The recursion strategy used by this Guide instance.
public function get recursionStrategy():String
| visitor | property |
visitor:IVisitor [read-only]
The IVisitor implementation used by this Guide instance.
public function get visitor():IVisitor
| Guide | () | constructor |
public function Guide(visitor:IVisitor, handlers:Array = null, recursionStrategy:String)
Constructs a new Guide that will explore a given bean and
expose its properties to the supplied visitor implementation.
visitor:IVisitor — a IVisitor implementation.
|
|
handlers:Array (default = null) — an array of specific handlers to insert between the
NullHandler and the default handlers.
|
|
recursionStrategy:String — the recursion strategy to be used when visiting a
bean (must be RS_DICTIONARY or RS_STACK). Default is RS_DICTIONARY.
|
See also
| accept | () | method |
protected function accept(visitor:IVisitor, visitable:Visitable):void
Try to find a IHandler instance that will handle the visit of the visitable
item by the visitor object.
visitor:IVisitor — the IVisitor that will visit the item.
|
|
visitable:Visitable — the Visitable item to visit.
|
| explore | () | method |
public function explore(o:*):voidExplore the supplied bean, exposing its properties to the current visitor.
This method is a shortcut for:
exploreVisitable(new Visitable(null, Type.forInstance(o), o)).
o:* — the bean to explore.
|
| exploreVisitable | () | method |
public function exploreVisitable(visitable:Visitable):void
Explore the supplied Visitable, exposing its properties to the
current visitor.
visitable:Visitable — the visitable to explore.
|
| isInContext | () | method |
protected function isInContext(value:*):BooleanChecks if the supplied parameter is already in the recursion context (ie. already visited).
Parametersvalue:* — the value to check against the current recursion context.
|
Boolean — true if value is already in the recursion context, false
otherwise.
|
| popFromContext | () | method |
protected function popFromContext(value:*):voidRemove the supplied parameter from the recursion context (this method does nothing when the recursion strategy is "dictionary").
Parametersvalue:* — the value to remove from the recursion context.
|
| pushInContext | () | method |
protected function pushInContext(value:*):voidPut the supplied parameter in the recursion context (so it is marked as already visited).
Parametersvalue:* — the value to put in the recursion context.
|
| RS_DICTIONARY | constant |
public static const RS_DICTIONARY:String = "dictionary"The constant for "dictionary" recursion strategy: an instance of a bean is only visited once, even if it appears several times in an objects graph (this is the default).
| RS_STACK | constant |
public static const RS_STACK:String = "stack"The constant for "stack" recursion strategy: an instance of a bean is visited if and only if it wasn't already visited in the current path fo the objects graph.