org.apache.jackrabbit.standalone.cli
Class CommandHelper

java.lang.Object
  extended by org.apache.jackrabbit.standalone.cli.CommandHelper

public final class CommandHelper
extends Object

Utility class for getting and setting context attributes.


Field Summary
static String CURRENT_NODE_KEY
          Current node key
static String OUTPUT_KEY
          output key
static String REPO_ADDRESS_KEY
          address key
static String REPOSITORY_KEY
          repository key
static String SESSION_KEY
          session key
 
Method Summary
static ResourceBundle getBundle()
           
static Node getCurrentNode(org.apache.commons.chain.Context ctx)
          Gets the current working Node
static 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, Node node, String pattern)
          Gets the Item s under the given Node that match the pattern
static Node getNode(org.apache.commons.chain.Context ctx, String path)
          Gets the Node at the given path.
static NodeIterator getNodes(org.apache.commons.chain.Context ctx, 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 PropertyIterator getProperties(org.apache.commons.chain.Context ctx, Node node, String pattern)
          Gets the Property s under the current working node for the given pattern
static Repository getRepository(org.apache.commons.chain.Context ctx)
          Gets the current working Repository
static String getRepositoryAddress(org.apache.commons.chain.Context ctx)
           
static 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, 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, Repository repository, String address)
          Sets the current working Repository
static void setSession(org.apache.commons.chain.Context ctx, 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
 

Field Detail

CURRENT_NODE_KEY

public static final String CURRENT_NODE_KEY
Current node key

See Also:
Constant Field Values

REPOSITORY_KEY

public static final String REPOSITORY_KEY
repository key

See Also:
Constant Field Values

SESSION_KEY

public static final String SESSION_KEY
session key

See Also:
Constant Field Values

OUTPUT_KEY

public static final String OUTPUT_KEY
output key

See Also:
Constant Field Values

REPO_ADDRESS_KEY

public static final String REPO_ADDRESS_KEY
address key

See Also:
Constant Field Values
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,
                                  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,
                                 Repository repository,
                                 String address)
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,
                              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 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 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.

getRepositoryAddress

public static String getRepositoryAddress(org.apache.commons.chain.Context ctx)
                                   throws CommandException
Throws:
CommandException

getSession

public static 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 Node getNode(org.apache.commons.chain.Context ctx,
                           String path)
                    throws CommandException,
                           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.
RepositoryException - if the underlying repository throws a RepositoryException

getItem

public static Item getItem(org.apache.commons.chain.Context ctx,
                           String path)
                    throws CommandException,
                           PathNotFoundException,
                           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.
PathNotFoundException - if there's no Node at the given path.
RepositoryException - if the underlying repository throws a RepositoryException

hasNode

public static boolean hasNode(org.apache.commons.chain.Context ctx,
                              String path)
                       throws CommandException,
                              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.
RepositoryException - if the underlying repository throws a RepositoryException

getNodes

public static NodeIterator getNodes(org.apache.commons.chain.Context ctx,
                                    Node node,
                                    String pattern)
                             throws 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:
RepositoryException - if the underlying repository throws a RepositoryException

getProperties

public static PropertyIterator getProperties(org.apache.commons.chain.Context ctx,
                                             Node node,
                                             String pattern)
                                      throws 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:
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,
                                Node node,
                                String pattern)
                         throws 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:
RepositoryException - if the underlying repository throws a RepositoryException


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.