org.modeshape.jcr.query

## Interface JcrQueryContext

-     public interface JcrQueryContext

  The context in which queries are executed. This interface is implemented in the components that instantiate `JcrQuery` instances and which can provide the required functionality needed by the JcrQuery and `JcrQueryResult` classes.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `canRead(CachedNode node)` Checks if there is a `ModeShapePermissions.READ` permission for the given node in this context.
    `void` | `checkValid()` Method that verifies that this query context is still valid for use.
    `CancellableQuery` | `createExecutableQuery(QueryCommand query, PlanHints hints, Map<String,Object> variables)` Create a query object that can be `executed` and optionally `cancelled`.
    `Value` | `createValue(int propertyType, Object value)` Create a JCR `Value` instance given the supplied value and property type.
    `BufferManager` | `getBufferManager()` Get the buffer manager.
    `long` | `getChildCount(CachedNode node)` Get the number of children of the supplied cached node.
    `long` | `getDepth(CachedNode node)` Get the depth of the supplied cached node.
    `ExecutionContext` | `getExecutionContext()` Get the execution context that should be used by the query.
    `String` | `getIdentifier(CachedNode node)` Get the internal `public JCR identifier` of the supplied cached node.
    `Name` | `getName(CachedNode node)` Get the internal `Name` of the supplied cached node.
    `Node` | `getNode(CachedNode node)` Obtain the JCR node given the supplied cached node.
    `Path` | `getPath(CachedNode node)` Get the internal `Path` of the supplied cached node.
    `String` | `getUuid(CachedNode node)` Get the UUID identifier of the supplied cached node.
    `String` | `getWorkspaceName()` Get the name of the current workspace.
    `void` | `recordDuration(long duration, TimeUnit unit, String query, String language)` Record the duration of a query.
    `Node` | `storeQuery(String absolutePath, Name nodeType, String language, String statement)` Store the query at the given location.

- - ### Method Detail

    - #### checkValid

          void checkValid()
                          throws RepositoryException

      Method that verifies that this query context is still valid for use.
      Throws:
        `RepositoryException` - if session has been closed and is no longer usable.

    - #### getExecutionContext

          ExecutionContext getExecutionContext()

      Get the execution context that should be used by the query.
      Returns:
        the execution context; never null

    - #### getBufferManager

          BufferManager getBufferManager()

      Get the buffer manager.
      Returns:
        the buffer manager; never null

    - #### getWorkspaceName

          String getWorkspaceName()

      Get the name of the current workspace.
      Returns:
        the workspace name; never null

    - #### storeQuery

          Node storeQuery(String absolutePath,
                        Name nodeType,
                        String language,
                        String statement)
                          throws RepositoryException

      Store the query at the given location.
      Parameters:
        `absolutePath` - the location at which the query should be stored; may not be null
        `nodeType` - the node type for the node; may not be null
        `language` - the query language; may not be null
        `statement` - the query statement; may not be null
      Returns:
        the node at which the query was stored; never null
      Throws:
        `RepositoryException` - if there was a problem storing the query

    - #### createExecutableQuery

          CancellableQuery createExecutableQuery(QueryCommand query,
                                               PlanHints hints,
                                               Map<String,Object> variables)
                                                 throws RepositoryException

      Create a query object that can be `executed` and optionally `cancelled`.
      Parameters:
        `query` - the abstract query command; may not be null
        `hints` - the hints
        `variables` - the map of variables and the corresonding values
      Returns:
        the cancellable query
      Throws:
        `RepositoryException` - if there is a problem accessing or using the repository

    - #### getNode

          Node getNode(CachedNode node)

      Obtain the JCR node given the supplied cached node.
      Parameters:
        `node` - the cached node obtained from the query results
      Returns:
        the JCR node instance that corresponds to the supplied cached node; may be null if the node does not exist or is not visible

    - #### canRead

          boolean canRead(CachedNode node)

      Checks if there is a `ModeShapePermissions.READ` permission for the given node in this context.
      Parameters:
        `node` - a `CachedNode`, never `null`
      Returns:
        `true` if the current context can read the given node, `false` otherwise

    - #### createValue

          Value createValue(int propertyType,
                          Object value)

      Create a JCR `Value` instance given the supplied value and property type.
      Parameters:
        `propertyType` - the JCR property type
        `value` - the value
      Returns:
        the JCR value instance

    - #### recordDuration

          void recordDuration(long duration,
                            TimeUnit unit,
                            String query,
                            String language)

      Record the duration of a query.
      Parameters:
        `duration` - the duration in nanoseconds; must be positive
        `unit` - the time unit for the duration; may not be null
        `query` - the query string; may not be null
        `language` - the query language; may not be null

    - #### getPath

          Path getPath(CachedNode node)

      Get the internal `Path` of the supplied cached node.
      Parameters:
        `node` - the cached node; may not be null
      Returns:
        the path; never null

    - #### getName

          Name getName(CachedNode node)

      Get the internal `Name` of the supplied cached node.
      Parameters:
        `node` - the cached node; may not be null
      Returns:
        the node name; never null

    - #### getIdentifier

          String getIdentifier(CachedNode node)

      Get the internal `public JCR identifier` of the supplied cached node.
      Parameters:
        `node` - the cached node; may not be null
      Returns:
        the JCR identifier; never null

    - #### getDepth

          long getDepth(CachedNode node)

      Get the depth of the supplied cached node.
      Parameters:
        `node` - the cached node; may not be null
      Returns:
        the depth

    - #### getChildCount

          long getChildCount(CachedNode node)

      Get the number of children of the supplied cached node.
      Parameters:
        `node` - the cached node; may not be null
      Returns:
        the child count

    - #### getUuid

          String getUuid(CachedNode node)

      Get the UUID identifier of the supplied cached node. Note that the node must have the 'mix:referenceable' mixin for it to have a UUID.
      Parameters:
        `node` - the cached node; may not be null
      Returns:
        the UUID, or null if the node is not referenceable

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