Package edu.uiuc.ncsa.security.core.cf
Class CFMultiConfigurations
- java.lang.Object
-
- edu.uiuc.ncsa.security.core.cf.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
-
-
Field Summary
Fields Modifier and Type Field Description static StringALIAS_TAGstatic StringDEFAULT_PARENT_LIST_DELIMITERstatic StringEXTENDS_TAGstatic StringLIST_DELIMITERSstatic StringNAME_TAG
-
Constructor Summary
Constructors Constructor Description CFMultiConfigurations()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Node>getAllNodes()Every node with a name attributestatic CFNodegetAllNodes(CFNode node, String name)Use this to get all the named nodes off the list.static StringgetAttributeInNode(CFNode node, String nodeName, String attributeName)Looks for the given node and returns the first attribute.static List<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,...static StringgetFirstAttribute(CFNode node, String name)Get the very first attribute with the given name found in the nodes.static booleangetFirstBooleanValue(CFNode node, String attrib)Get the first attribute and return a boolean.static booleangetFirstBooleanValue(CFNode node, String attrib, boolean defaultValue)Finds the first attribute with the given name and then converts to boolean.static longgetFirstLongValue(CFNode node, String attrib)static longgetFirstLongValue(CFNode node, String attrib, long defaultValue)static CFNodegetFirstNode(CFNode node, String name)Return the first named child configuration node of the given node or null if there is no such named child.MultipleInheritanceEnginegetInheritanceEngine()CFNodegetNamedConfig(String cfgName)This will return all theNodes with the given name.InheritanceMapgetNamedNodes()Every named node that does not have an alias, i.e.static StringgetNodeContents(CFNode node, String name)Convenience method for getting the value of a single node, i.e.static StringgetNodeContents(CFNode node, String name, String defaultValue)Convenience method for getting the value of a single node, i.e.static StringgetNodeValue(CFNode node, String name)Synonym firgetNodeContents(CFNode, String)for backwards compatibilitystatic StringgetNodeValue(CFNode node, String name, String defaultValue)Synonym forgetNodeContents(CFNode, String, String)for backwards compatility.voidingestConfig(CFBundle cfg, String tagName)protected List<String>splitParentList(String rawList)If the list starts with one of theLIST_DELIMITERS, use that otherwise, use a blank.
-
-
-
Field Detail
-
EXTENDS_TAG
public static final String EXTENDS_TAG
- See Also:
- Constant Field Values
-
NAME_TAG
public static final String NAME_TAG
- See Also:
- Constant Field Values
-
ALIAS_TAG
public static final String ALIAS_TAG
- See Also:
- Constant Field Values
-
LIST_DELIMITERS
public static final String LIST_DELIMITERS
- See Also:
- Constant Field Values
-
DEFAULT_PARENT_LIST_DELIMITER
public static final String DEFAULT_PARENT_LIST_DELIMITER
- See Also:
- Constant Field Values
-
-
Method Detail
-
getNamedNodes
public InheritanceMap getNamedNodes()
Every named node that does not have an alias, i.e. "real" nodes
-
getInheritanceEngine
public MultipleInheritanceEngine getInheritanceEngine()
- Specified by:
getInheritanceEnginein interfaceMultiConfigurationsInterface
-
getNamedConfig
public CFNode getNamedConfig(String cfgName)
This will return all theNodes with the given name.- Parameters:
cfgName-- Returns:
-
splitParentList
protected List<String> splitParentList(String rawList)
If the list starts with one of theLIST_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 List<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:
-
getNodeValue
public static String getNodeValue(CFNode node, String name, String defaultValue)
Synonym forgetNodeContents(CFNode, String, String)for backwards compatility.- 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:
-
getNodeValue
public static String getNodeValue(CFNode node, String name)
Synonym firgetNodeContents(CFNode, String)for backwards compatibility- 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, long defaultValue)
-
-