org.apache.jackrabbit.command
Class CommandHelper

java.lang.Object
  extended byorg.apache.jackrabbit.command.CommandHelper

public final class CommandHelper
extends Object

Utility class for getting and setting context attributes.


Method Summary
static ResourceBundle getBundle()
           
static javax.jcr.Node getCurrentNode(org.apache.commons.chain.Context ctx)
          Gets the current working Node
static javax.jcr.Item getItem(org.apache.commons.chain.Context ctx, String path)
          Gets the Item at the given path.
static Iterator getItems(org.apache.commons.chain.Context ctx, javax.jcr.Node node, String pattern)
          Gets the Item s under the given Node that match the pattern
static javax.jcr.Node getNode(org.apache.commons.chain.Context ctx, String path)
          Gets the Node at the given path.
static javax.jcr.NodeIterator getNodes(org.apache.commons.chain.Context ctx, javax.jcr.Node node, String pattern)
          Gets the Node s under the given Node that match the given pattern.
static PrintWriter getOutput(org.apache.commons.chain.Context ctx)
          Gets the current PrintWriter
static javax.jcr.PropertyIterator getProperties(org.apache.commons.chain.Context ctx, javax.jcr.Node node, String pattern)
          Gets the Property s under the current working node for the given pattern
static javax.jcr.Repository getRepository(org.apache.commons.chain.Context ctx)
          Gets the current working Repository
static javax.jcr.Session getSession(org.apache.commons.chain.Context ctx)
          Gets the current working Session
static boolean hasNode(org.apache.commons.chain.Context ctx, String path)
          Checks Node existence.
static void setCurrentNode(org.apache.commons.chain.Context ctx, javax.jcr.Node node)
          Sets the current working Node.
static void setOutput(org.apache.commons.chain.Context ctx, PrintWriter out)
          Sets the current PrintWriter.
static void setRepository(org.apache.commons.chain.Context ctx, javax.jcr.Repository repository)
          Sets the current working Repository
static void setSession(org.apache.commons.chain.Context ctx, javax.jcr.Session session)
          Sets the current working Session
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setOutput

public static void setOutput(org.apache.commons.chain.Context ctx,
                             PrintWriter out)
Sets the current PrintWriter.

Parameters:
ctx - the Context
out - the PrintWriter

setCurrentNode

public static void setCurrentNode(org.apache.commons.chain.Context ctx,
                                  javax.jcr.Node node)
Sets the current working Node.

Parameters:
ctx - the Context
node - the current working Node.

setRepository

public static void setRepository(org.apache.commons.chain.Context ctx,
                                 javax.jcr.Repository repository)
Sets the current working Repository

Parameters:
ctx - the Context
repository - the current working Repository

setSession

public static void setSession(org.apache.commons.chain.Context ctx,
                              javax.jcr.Session session)
                       throws CommandException
Sets the current working Session

Parameters:
ctx - the Context
session - the current working Session
Throws:
CommandException - if there's an open working Session

getOutput

public static PrintWriter getOutput(org.apache.commons.chain.Context ctx)
Gets the current PrintWriter

Parameters:
ctx - the Context
Returns:
the current PrintWriter

getCurrentNode

public static javax.jcr.Node getCurrentNode(org.apache.commons.chain.Context ctx)
                                     throws CommandException
Gets the current working Node

Parameters:
ctx - the Context
Returns:
the current working Node
Throws:
CommandException - if the current working Node can't be found.

getRepository

public static javax.jcr.Repository getRepository(org.apache.commons.chain.Context ctx)
                                          throws CommandException
Gets the current working Repository

Parameters:
ctx - the Context
Returns:
the current working Repository
Throws:
CommandException - if the current working Repository is unset.

getSession

public static javax.jcr.Session getSession(org.apache.commons.chain.Context ctx)
                                    throws CommandException
Gets the current working Session

Parameters:
ctx - the Context
Returns:
the current working Session
Throws:
CommandException - if the current working Session is unset.

getNode

public static javax.jcr.Node getNode(org.apache.commons.chain.Context ctx,
                                     String path)
                              throws CommandException,
                                     javax.jcr.RepositoryException
Gets the Node at the given path.

Parameters:
ctx - the Context
path - the path to the Node
Returns:
the Node at the given path
Throws:
CommandException - if the Node isn't found.
javax.jcr.RepositoryException - if the underlying repository throws a RepositoryException

getItem

public static javax.jcr.Item getItem(org.apache.commons.chain.Context ctx,
                                     String path)
                              throws CommandException,
                                     javax.jcr.PathNotFoundException,
                                     javax.jcr.RepositoryException
Gets the Item at the given path.
If the path is null it returns the current working Node.

Parameters:
ctx - the Context
path - the path to the Item
Returns:
the Item at the given path
Throws:
CommandException - if a Command internal error occurs.
javax.jcr.PathNotFoundException - if there's no Node at the given path.
javax.jcr.RepositoryException - if the underlying repository throws a RepositoryException

hasNode

public static boolean hasNode(org.apache.commons.chain.Context ctx,
                              String path)
                       throws CommandException,
                              javax.jcr.RepositoryException
Checks Node existence.

Parameters:
ctx - the Context
path - the path to the Node
Returns:
true if the Node exists at the given path
Throws:
CommandException - if the current working Session is unset.
javax.jcr.RepositoryException - if the underlying repository throws a RepositoryException

getNodes

public static javax.jcr.NodeIterator getNodes(org.apache.commons.chain.Context ctx,
                                              javax.jcr.Node node,
                                              String pattern)
                                       throws javax.jcr.RepositoryException
Gets the Node s under the given Node that match the given pattern.

Parameters:
ctx - the Context
node - the parent Node
pattern - the pattern
Returns:
an Iterator that contains the matching nodes
Throws:
javax.jcr.RepositoryException - if the underlying repository throws a RepositoryException

getProperties

public static javax.jcr.PropertyIterator getProperties(org.apache.commons.chain.Context ctx,
                                                       javax.jcr.Node node,
                                                       String pattern)
                                                throws javax.jcr.RepositoryException
Gets the Property s under the current working node for the given pattern

Parameters:
ctx - the Context
node - the parent Node
pattern - the pattern
Returns:
a PropertyIterator
Throws:
javax.jcr.RepositoryException - if the underlying repository throws a RepositoryException

getBundle

public static ResourceBundle getBundle()
Returns:
the default ResourceBundle

getItems

public static Iterator getItems(org.apache.commons.chain.Context ctx,
                                javax.jcr.Node node,
                                String pattern)
                         throws javax.jcr.RepositoryException
Gets the Item s under the given Node that match the pattern

Parameters:
ctx - the Context
node - the parent Node
pattern - the pattern
Returns:
an Iterator with the Item s that match the given pattern.
Throws:
javax.jcr.RepositoryException - if the underlying repository throws a RepositoryException


Copyright © 2005 . All Rights Reserved.