Class MultiConfigurations


  • public class MultiConfigurations
    extends Object
    Configuration Utility that allows for inheritance from other configurations For testing this see the MultipleInheritanceTest in the testing harness, which exercises this very well.

    Created by Jeff Gaynor
    on 1/31/21 at 4:59 PM

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      List<org.apache.commons.configuration.tree.ConfigurationNode> getAllNodes​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes, String name)
      Use this to get all the named nodes off the list.
      String getAttributeInNode​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes, String nodeName, String attributeName)
      Looks for the given node and returns the first attribute.
      List<org.apache.commons.configuration.tree.ConfigurationNode> getChildren​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes, String name)
      The contract is that this will return all the named https://localhost:9443/oauth2/authorize?scope=org.cilogon.userinfo+openid+profile+email+storage.read%3A%2F+wlcg.capabilityset%3A%2Fduneana+wlcg.groups&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A9443%2Fclient2%2Fready&state=vpfVnb1M4VfybbmZP3gCj724wahA0bYUJk2kbtmDy1k&nonce=kH9WLyty1xQ2EyMHjLz1MGgPZmDg1TFL-RORH7-2pC8&prompt=login&client_id=localhost%3Atest%2Ffnal&skin=dataOne hildren nodes of the given node in order So if the argument is [node0,node1,...] Then result is all the children of node0, followed by all the children of node1,...
      String getFirstAttribute​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes, String name)
      Get the very first attribute with the given name found in the nodes.
      boolean getFirstBooleanValue​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes, String attrib)
      Get the first attribute and return a boolean.
      boolean getFirstBooleanValue​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes, String attrib, boolean defaultValue)
      Finds the first attribute with the given name and then converts to boolean.
      long getFirstLongValue​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes, String attrib)  
      long getFirstLongValue​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes, String attrib, long defaultValue)  
      org.apache.commons.configuration.tree.ConfigurationNode getFirstNode​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes, String name)
      Return the first named child configuration node of the given node or null if there is no such named child.
      MultipleInheritanceEngine getInheritanceEngine()  
      List<org.apache.commons.configuration.tree.ConfigurationNode> getNamedConfig​(String cfgName)
      This being XML, it is possible to have elements with the same name -- stylistically very bad and no config should do that, but it is unavoidable.
      String getNodeContents​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes, String name)
      Convenience method for getting the value of a single node, i.e.
      String getNodeContents​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes, String name, String defaultValue)
      Convenience method for getting the value of a single node, i.e.
      void ingestConfig​(org.apache.commons.configuration.XMLConfiguration cfg, String topNodeTag)  
      protected List<String> splitParentList​(String rawList)
      If the list starts with one of the LIST_DELIMITERS, use that otherwise, use a blank.
    • Constructor Detail

      • MultiConfigurations

        public MultiConfigurations()
    • Method Detail

      • ingestConfig

        public void ingestConfig​(org.apache.commons.configuration.XMLConfiguration cfg,
                                 String topNodeTag)
      • getNamedConfig

        public List<org.apache.commons.configuration.tree.ConfigurationNode> getNamedConfig​(String cfgName)
        This being XML, it is possible to have elements with the same name -- stylistically very bad and no config should do that, but it is unavoidable. Therefore, this will return all the nodes with the given name and generally the calling program should either throw an exception if there is more than one or have some strategy for dealing with multiples.
        Parameters:
        cfgName -
        Returns:
      • splitParentList

        protected List<String> splitParentList​(String rawList)
        If the list starts with one of the LIST_DELIMITERS, use that otherwise, use a blank. Leading and trailing blanks on entries are ignored.

        E.g. a list of
         ;A;B;C
         
        means ; is the delimiter. You only need to put the delimeter first if it is not a blank, so "A B C" is fine. Different delimeter let you have embedded blanks etc. E.g. ";mairzy doats;and dozey;daots! and" parses as "mairzey doats", "and dozey", "doats! and"
        Parameters:
        rawList -
        Returns:
      • getFirstAttribute

        public String getFirstAttribute​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes,
                                        String name)
        Get the very first attribute with the given name found in the nodes. A null is returned if there is no such value.
        Parameters:
        nodes -
        name -
        Returns:
      • getFirstNode

        public org.apache.commons.configuration.tree.ConfigurationNode getFirstNode​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes,
                                                                                    String name)
        Return the first named child configuration node of the given node or null if there is no such named child. Very useful if your specification only allows for a single child node.
        Parameters:
        nodes -
        name -
        Returns:
      • getChildren

        public List<org.apache.commons.configuration.tree.ConfigurationNode> getChildren​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes,
                                                                                         String name)
        The contract is that this will return all the named https://localhost:9443/oauth2/authorize?scope=org.cilogon.userinfo+openid+profile+email+storage.read%3A%2F+wlcg.capabilityset%3A%2Fduneana+wlcg.groups&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A9443%2Fclient2%2Fready&state=vpfVnb1M4VfybbmZP3gCj724wahA0bYUJk2kbtmDy1k&nonce=kH9WLyty1xQ2EyMHjLz1MGgPZmDg1TFL-RORH7-2pC8&prompt=login&client_id=localhost%3Atest%2Ffnal&skin=dataOne hildren nodes of the given node in order So if the argument is [node0,node1,...] Then result is all the children of node0, followed by all the children of node1,... Note that you can feed the result of this list back in to get the next level of children.
        Parameters:
        nodes -
        Returns:
      • getAllNodes

        public List<org.apache.commons.configuration.tree.ConfigurationNode> getAllNodes​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes,
                                                                                         String name)
        Use this to get all the named nodes off the list. Rather than overrides, this returns the kitchen sink. This is the equivalent of glomming together all of the like-named nodes into one big virtual node. This also gets other nodes in the configuration too so if there are multiple ones in any configuration, they are added in as well.

        Sometimes this is necessary.

        Parameters:
        nodes -
        name -
        Returns:
      • getNodeContents

        public String getNodeContents​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes,
                                      String name,
                                      String defaultValue)
        Convenience method for getting the value of a single node, i.e. the contents, so

        <foo>value</foo>

        would have name equal to 'foo' and return the string 'value'. Returns the default value if no such value is found.
        Parameters:
        nodes -
        name -
        defaultValue -
        Returns:
      • getNodeContents

        public String getNodeContents​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes,
                                      String name)
        Convenience method for getting the value of a single node, i.e. the contents, so

        <foo>value</foo>

        would have name equal to 'foo' and return the string 'value'. Returns a null if no such value is found. This is also clever enough to pull things out of CDATA nodes.
        Parameters:
        nodes -
        name -
        Returns:
      • getFirstBooleanValue

        public boolean getFirstBooleanValue​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes,
                                            String attrib,
                                            boolean defaultValue)
        Finds the first attribute with the given name and then converts to boolean. If the conversion fails, the default is returned. This supports values of true, false, on, off.
        Parameters:
        nodes -
        attrib -
        defaultValue -
        Returns:
      • getFirstBooleanValue

        public boolean getFirstBooleanValue​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes,
                                            String attrib)
        Get the first attribute and return a boolean. Note that this supports values of true, false, on and off. If no such value is found, an exception is raised.
        Parameters:
        nodes -
        attrib -
        Returns:
      • getFirstLongValue

        public long getFirstLongValue​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes,
                                      String attrib)
      • getFirstLongValue

        public long getFirstLongValue​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes,
                                      String attrib,
                                      long defaultValue)
      • getAttributeInNode

        public String getAttributeInNode​(List<org.apache.commons.configuration.tree.ConfigurationNode> nodes,
                                         String nodeName,
                                         String attributeName)
        Looks for the given node and returns the first attribute. This is the method that lets you override a single attribute in a tag.
        Parameters:
        nodes -
        nodeName -
        attributeName -
        Returns: