Class CFMultiConfigurations

  • All Implemented Interfaces:
    MultiConfigurationsInterface

    public class CFMultiConfigurations
    extends Object
    implements MultiConfigurationsInterface
    Configuration Utility that allows for inheritance from other configurations. This also has sseveral static methods to help with migration of existing 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

    • Constructor Detail

      • CFMultiConfigurations

        public CFMultiConfigurations()
    • Method Detail

      • getNamedNodes

        public InheritanceMap getNamedNodes()
        Every named node that does not have an alias, i.e. "real" nodes
      • getAllNodes

        public Map<String,​Node> getAllNodes()
        Every node with a name attribute
      • ingestConfig

        public void ingestConfig​(CFBundle cfg,
                                 String tagName)
      • getNamedConfig

        public CFNode getNamedConfig​(String cfgName)
        This will return all the Nodes with the given name.
        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 static String getFirstAttribute​(CFNode node,
                                               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:
        node -
        name -
        Returns:
      • getFirstNode

        public static CFNode getFirstNode​(CFNode node,
                                          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:
        node -
        name -
        Returns:
      • getChildren

        public static CFNode getChildren​(CFNode node,
                                         String name)
        The contract is that this will return all the named children 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:
        node -
        Returns:
      • getAllNodes

        public static CFNode getAllNodes​(CFNode node,
                                         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:
        node -
        name -
        Returns:
      • getNodeContents

        public static String getNodeContents​(CFNode node,
                                             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:
        node -
        name -
        defaultValue -
        Returns:
      • getNodeContents

        public static String getNodeContents​(CFNode node,
                                             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:
        node -
        name -
        Returns:
      • getFirstBooleanValue

        public static boolean getFirstBooleanValue​(CFNode node,
                                                   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:
        node -
        attrib -
        defaultValue -
        Returns:
      • getFirstBooleanValue

        public static boolean getFirstBooleanValue​(CFNode node,
                                                   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:
        node -
        attrib -
        Returns:
      • getFirstLongValue

        public static long getFirstLongValue​(CFNode node,
                                             String attrib)
      • getFirstLongValue

        public static long getFirstLongValue​(CFNode node,
                                             String attrib,
                                             long defaultValue)
      • getAttributeInNode

        public static String getAttributeInNode​(CFNode node,
                                                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:
        node -
        nodeName -
        attributeName -
        Returns: