Package org.apache.logging.log4j.plugins
Class Node
java.lang.Object
org.apache.logging.log4j.plugins.Node
Configurations are represented as a tree of Node instances. Each Node may have
attributes, children nodes,
an optional value (which is a special kind of attribute for certain configuration file
formats which support the concept), and a name which corresponds to a
Plugin
class in the Core namespace and is specified via an element name or
the type
attribute. Configuration factories parse a configuration resource into a tree of Nodes with a
single root Node.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Main plugin namespace for plugins which are represented as a configuration node.Key describing the current node being configured. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
getName()
<T> T
<T> T
Returns this node's object cast to the given class.PluginType<?>
getType()
getValue()
boolean
boolean
isInstanceOf
(Class<?> clazz) Determines if this node's object is an instance of the given class.boolean
isRoot()
static Node.Builder
removeMatchingAttribute
(String name, Collection<String> aliases) Finds and removes the attribute with a name equaling ignoring case either the provided name or one of the provided aliases.void
void
void
toString()
-
Field Details
-
CORE_NAMESPACE
Main plugin namespace for plugins which are represented as a configuration node. Such plugins tend to be available as XML elements in a configuration file.- Since:
- 2.1
- See Also:
-
CURRENT_NODE
Key describing the current node being configured.
-
-
Constructor Details
-
Node
Creates a new instance ofNode
and initializes it with a name and the corresponding XML element.- Parameters:
parent
- the node's parent.name
- the node's name.type
- The Plugin Type associated with the node.
-
Node
public Node()Constructs a root node. Root nodes have no defined type, name, or parent node. -
Node
Constructs a fresh copy of the provided Node.- Parameters:
node
- original node to copy
-
-
Method Details
-
setParent
-
getAttributes
-
getChildren
-
addChild
-
hasChildren
public boolean hasChildren() -
getValue
-
setValue
-
getParent
-
getName
-
isRoot
public boolean isRoot() -
setObject
-
getObject
public <T> T getObject() -
getObject
Returns this node's object cast to the given class.- Type Parameters:
T
- the type to cast to.- Parameters:
clazz
- the class to cast this node's object to.- Returns:
- this node's object.
- Since:
- 2.1
-
isInstanceOf
Determines if this node's object is an instance of the given class.- Parameters:
clazz
- the class to check.- Returns:
true
if this node's object is an instance of the given class.- Since:
- 2.1
-
getType
-
removeMatchingAttribute
Finds and removes the attribute with a name equaling ignoring case either the provided name or one of the provided aliases.- Parameters:
name
- name of attribute to findaliases
- aliases of attribute to find- Returns:
- the removed attribute value if found or empty if no attributes match
-
toString
-
newBuilder
-