org.modeshape.jcr.query.model

## Class Visitors

- java.lang.Object
- - org.modeshape.jcr.query.model.Visitors

-     public class Visitors
      extends Object

  A set of common visitors that can be reused or extended, and methods that provide easy construction and calling of visitors.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Visitors.AbstractVisitor` A common base class for all visitors, which provides no-op implementations for all `visit(...)` methods.
    `static class` | `Visitors.JcrSql2Writer`
    `static class` | `Visitors.NavigationVisitor` An abstract visitor implementation that performs navigation of the query object.
    `static class` | `Visitors.ReadableVisitor`
    `static class` | `Visitors.WalkAllVisitor` A visitor implementation that walks the entire query object tree and delegates to another supplied visitor to do the actual work.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static char` | `CLOSE_SQUARE`
    `protected static char` | `DOUBLE_QUOTE`
    `protected static char` | `OPEN_SQUARE`
    `protected static char` | `SINGLE_QUOTE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Visitors()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Map<SelectorName,SelectorName>` | `getSelectorAliasesByName(Visitable visitable)` Get a map of the selector aliases keyed by their names.
    `static Map<SelectorName,SelectorName>` | `getSelectorNamesByAlias(Visitable visitable)` Get a map of the selector names keyed by their aliases.
    `static Set<SelectorName>` | `getSelectorsReferencedBy(Visitable visitable)` Get the names of the selectors referenced by the visitable object.
    `static String` | `readable(Object[] tuple)`
    `static String` | `readable(Object[] tuple, ExecutionContext context)`
    `static String` | `readable(Visitable visitable)` Using a visitor, obtain the readable string representation of the supplied `object`
    `static String` | `readable(Visitable visitable, ExecutionContext context)` Using a visitor, obtain the readable string representation of the supplied `object`
    `static Collection<Subquery>` | `subqueries(Visitable visitable, boolean includeNestedSubqueries)` Using a visitor, obtain the `Subquery` objects that are contained within the supplied `object`.
    `static <GeneralVisitor extends Visitor> GeneralVisitor` | `visit(Visitable visitable, GeneralVisitor visitor)` Visit the supplied `object` using the supplied `Visitor`, which must be responsible for navigation as well as any business logic.
    `static <StrategyVisitor extends Visitor> StrategyVisitor` | `visitAll(Visitable visitable, StrategyVisitor strategyVisitor)` Visit all objects in the supplied `object` using a `Visitors.NavigationVisitor` (specifically a `Visitors.WalkAllVisitor`), and with each of these visited objects calling the appropriate `visit(...)` method on the supplied `Visitor`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### OPEN_SQUARE

          protected static final char OPEN_SQUARE

      See Also:
        Constant Field Values

    - #### CLOSE_SQUARE

          protected static final char CLOSE_SQUARE

      See Also:
        Constant Field Values

    - #### DOUBLE_QUOTE

          protected static final char DOUBLE_QUOTE

      See Also:
        Constant Field Values

    - #### SINGLE_QUOTE

          protected static final char SINGLE_QUOTE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Visitors

          public Visitors()

  - ### Method Detail

    - #### visitAll

          public static <StrategyVisitor extends Visitor> StrategyVisitor visitAll(Visitable visitable,
                                                                   StrategyVisitor strategyVisitor)

      Visit all objects in the supplied `object` using a `Visitors.NavigationVisitor` (specifically a `Visitors.WalkAllVisitor`), and with each of these visited objects calling the appropriate `visit(...)` method on the supplied `Visitor`.
      Type Parameters:
        `StrategyVisitor` - the type of strategy visitor
      Parameters:
        `visitable` - the top-level object to be visited
        `strategyVisitor` - the visitor that is to be called for each visited objects, but that does not call `Visitable.accept(Visitor)`
      Returns:
        the strategy visitor, allowing the caller to easily invoke operations on the visitor after visitation has completed

    - #### visit

          public static <GeneralVisitor extends Visitor> GeneralVisitor visit(Visitable visitable,
                                                              GeneralVisitor visitor)

      Visit the supplied `object` using the supplied `Visitor`, which must be responsible for navigation as well as any business logic.
      Type Parameters:
        `GeneralVisitor` - the type of visitor
      Parameters:
        `visitable` - the top-level object to be visited
        `visitor` - the visitor that is to be used
      Returns:
        the visitor, allowing the caller to easily invoke operations on the visitor after visitation has completed

    - #### readable

          public static String readable(Visitable visitable)

      Using a visitor, obtain the readable string representation of the supplied `object`
      Parameters:
        `visitable` - the visitable
      Returns:
        the string representation

    - #### readable

          public static String readable(Visitable visitable,
                        ExecutionContext context)

      Using a visitor, obtain the readable string representation of the supplied `object`
      Parameters:
        `visitable` - the visitable
        `context` - the execution context in which the visitable should be converted to a string
      Returns:
        the string representation

    - #### readable

          public static String readable(Object[] tuple)

    - #### readable

          public static String readable(Object[] tuple,
                        ExecutionContext context)

    - #### subqueries

          public static Collection<Subquery> subqueries(Visitable visitable,
                                        boolean includeNestedSubqueries)

      Using a visitor, obtain the `Subquery` objects that are contained within the supplied `object`. This method does find Subquery objets nested in other Subquery objects.
      Parameters:
        `visitable` - the visitable
        `includeNestedSubqueries` - true if any Subquery objects within other Subquery objects should be included, or false if only the top-level Subquery objects should be included
      Returns:
        the collection of subqueries; never null but possibly empty if no subqueries were found

    - #### getSelectorNamesByAlias

          public static Map<SelectorName,SelectorName> getSelectorNamesByAlias(Visitable visitable)

      Get a map of the selector names keyed by their aliases.
      Parameters:
        `visitable` - the object to be visited
      Returns:
        the map from the aliases to the aliased selector name; never null but possibly empty

    - #### getSelectorAliasesByName

          public static Map<SelectorName,SelectorName> getSelectorAliasesByName(Visitable visitable)

      Get a map of the selector aliases keyed by their names.
      Parameters:
        `visitable` - the object to be visited
      Returns:
        the map from the selector names to their alias (or name if there is no alias); never null but possibly empty

    - #### getSelectorsReferencedBy

          public static Set<SelectorName> getSelectorsReferencedBy(Visitable visitable)

      Get the names of the selectors referenced by the visitable object.
      Parameters:
        `visitable` - the object to be visited
      Returns:
        the set of selector names referenced in some way by the visitable; never null

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.