Class CommandHelper


  • public final class CommandHelper
    extends Object
    Utility class for getting and setting context attributes.
    • 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.
      • 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.
      • 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<Item> getItems​(org.apache.commons.chain.Context ctx,
                                              Node node,
                                              String pattern)
                                       throws RepositoryException
        Gets the Items 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