Package edu.uiuc.ncsa.security.core.cf
Class CFNode
- java.lang.Object
-
- edu.uiuc.ncsa.security.core.cf.CFNode
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetAttributeInNode(String nodeName, String attributeName)Looks for the given node and returns the first attribute.Map<String,String>getAttributes()Return all the attributes as a map.List<String>getAttributes(String name)Returns all attributes as strings.List<Boolean>getBooleanAttributes(String name)returns the boolean values for the attribute.List<CFNode>getChildren()Get non-text (so type is text or comment) child nodes.List<CFNode>getChildren(boolean nonTextOnly)Return children with possible filtering for text nodes.List<CFNode>getChildren(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,...StringgetFirstAttribute(String name)Get the very first attribute with the given name found in the nodes.StringgetFirstAttribute(String name, String defaultValue)BooleangetFirstBooleanValue(String attrib)Get the first attribute and return a boolean.booleangetFirstBooleanValue(String attrib, boolean defaultValue)Finds the first attribute with the given name and then converts to boolean.CFNodegetFirstChild(String name)Convenience method to get the zero-th node or null if there is none.LonggetFirstLongAttribute(String attrib)Return the value as a longLong.longgetFirstLongAttribute(String attrib, long defaultValue)Get the first attribute that is a long.CFNodegetFirstNode(String name)Return the first named child configuration node of the given node or null if there is no such named child.List<Long>getLongAttributes(String name)Returns all the long values for the attribute.StringgetName()StringgetNodeContents()Get the contents of the current node.StringgetNodeContents(String name)Convenience method for getting the value of a single node, i.e.StringgetNodeContents(String name, String defaultValue)Convenience method for getting the value of a single named child node, i.e.List<Node>getNodes()CFNodegetNodes(String name)Use this to get all the named nodes off the list.CFNodegetParent()StringgetValue()Synonym forgetNodeContents()BooleanhasAttribute(String attrib)booleanhasNodes()voidsetNodes(List<Node> nodes)intsize()
-
-
-
Method Detail
-
size
public int size()
-
hasNodes
public boolean hasNodes()
-
getName
public String getName()
-
getFirstAttribute
public String getFirstAttribute(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:
name-- Returns:
-
getAttributes
public List<String> getAttributes(String name)
Returns all attributes as strings.- Parameters:
name-- Returns:
-
getAttributes
public Map<String,String> getAttributes()
Return all the attributes as a map. You must convert these to whatever they are supposed to be. Note that this does resolve overrides.- Returns:
-
getLongAttributes
public List<Long> getLongAttributes(String name)
Returns all the long values for the attribute. This does not flag errors, it just skips them.- Parameters:
name-- Returns:
-
getBooleanAttributes
public List<Boolean> getBooleanAttributes(String name)
returns the boolean values for the attribute. It does not flag bad ones, it just skips them.- Parameters:
name-- Returns:
-
getFirstNode
public CFNode getFirstNode(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:
name-- Returns:
-
getChildren
public List<CFNode> getChildren(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.- Returns:
-
getChildren
public List<CFNode> getChildren()
Get non-text (so type is text or comment) child nodes.- Returns:
-
getChildren
public List<CFNode> getChildren(boolean nonTextOnly)
Return children with possible filtering for text nodes. In most applications you do not want just whitespace.- Parameters:
nonTextOnly-- Returns:
-
getParent
public CFNode getParent()
-
getValue
public String getValue()
Synonym forgetNodeContents()- Returns:
-
getFirstChild
public CFNode getFirstChild(String name)
Convenience method to get the zero-th node or null if there is none. In many cases you know there is exactly a single node and you just want that.- Parameters:
name-- Returns:
-
getNodes
public CFNode getNodes(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:
name-- Returns:
-
getNodeContents
public String getNodeContents(String name, String defaultValue)
Convenience method for getting the value of a single named child 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:
name-defaultValue-- Returns:
-
getNodeContents
public String getNodeContents()
Get the contents of the current node.- Returns:
-
getNodeContents
public String getNodeContents(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:
name-- Returns:
-
getFirstBooleanValue
public boolean getFirstBooleanValue(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:
attrib-defaultValue-- Returns:
-
getFirstBooleanValue
public Boolean getFirstBooleanValue(String attrib)
Get the first attribute and return a boolean. Note that this supports values ofStringUtils.LOGICAL_TRUESandStringUtils.LOGICAL_FALSES. If no such value is found, an error is raised, since use of this method asserts the value is a boolean.- Parameters:
attrib-- Returns:
-
getFirstLongAttribute
public Long getFirstLongAttribute(String attrib)
Return the value as a longLong. If no such value, a null is returned. If the value fails to parse as a long, an illegal argument exception is raised- Parameters:
attrib-- Returns:
-
getFirstLongAttribute
public long getFirstLongAttribute(String attrib, long defaultValue)
Get the first attribute that is a long. If no such attribute, return the default value.- Parameters:
attrib-defaultValue-- Returns:
-
-