Class ReflectiveVisitor

  • All Implemented Interfaces:
    Visitor

    public abstract class ReflectiveVisitor
    extends java.lang.Object
    implements Visitor
    This is a convenience class implementing a Visitor and it takes care of choosing the right methods to dispatch the Visitor.enter(Visitable) and Visitor.leave(Visitable) calls to.

    Classes extending this visitor need to provide corresponding enter and leave methods taking exactly one argument of the type of Visitable they are interested it.

    The type must be an exact match, this support class doesn't try to find a close match up in the class hierarchy if it doesn't find an exact match.

    Since:
    1.0
    Author:
    Michael J. Simons, Gerrit Meier
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Set<AliasedExpression> visitableToAliased
      A set of aliased expressions that already have been seen and for which an alias must be used on each following appearance.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void enter​(Visitable visitable)
      Enter a Visitable.
      void leave​(Visitable visitable)
      Leave a Visitable.
      protected abstract void postLeave​(Visitable visitable)
      This is a hook that is called with the uncasted, raw visitable just after leaving the visitable.
      protected abstract boolean preEnter​(Visitable visitable)
      This is a hook that is called with the uncasted, raw visitable just before entering a visitable.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • visitableToAliased

        protected final java.util.Set<AliasedExpression> visitableToAliased
        A set of aliased expressions that already have been seen and for which an alias must be used on each following appearance.
    • Constructor Detail

      • ReflectiveVisitor

        public ReflectiveVisitor()
    • Method Detail

      • preEnter

        protected abstract boolean preEnter​(Visitable visitable)
        This is a hook that is called with the uncasted, raw visitable just before entering a visitable.

        The hook is called regardless wither a matching enter is found or not.

        Parameters:
        visitable - The visitable that is passed on to a matching enter after this call.
        Returns:
        true, when visiting of elements should be stopped until this element is left again.
      • postLeave

        protected abstract void postLeave​(Visitable visitable)
        This is a hook that is called with the uncasted, raw visitable just after leaving the visitable.

        The hook is called regardless wither a matching leave is found or not.

        Parameters:
        visitable - The visitable that is passed on to a matching leave after this call.
      • enter

        public final void enter​(Visitable visitable)
        Description copied from interface: Visitor
        Enter a Visitable.
        Specified by:
        enter in interface Visitor
        Parameters:
        visitable - the segment to visit.
      • leave

        public final void leave​(Visitable visitable)
        Description copied from interface: Visitor
        Leave a Visitable.
        Specified by:
        leave in interface Visitor
        Parameters:
        visitable - the visited segment.