public class ParsedNode extends Object
ChangeLogParser
implementations and other classes that work with multiple formats can create objects
directs or create instances of this class which can then be passed to the load() method of the object they want to configure.
For example, LiquibaseSerializable.load(ParsedNode, liquibase.resource.ResourceAccessor)
.
ParsedNodes are a simple key/value structure with the following characteristics:
Constructor and Description |
---|
ParsedNode(String namespace,
String name) |
Modifier and Type | Method and Description |
---|---|
ParsedNode |
addChild(ParsedNode node)
Adds the given ParsedNode as a child
|
ParsedNode |
addChild(String namespace,
String nodeName,
Object value)
Convenience method to add a new ParsedNode with the passed namespace/name and value
|
ParsedNode |
addChildren(Map<String,Object> child)
Adds the given map as children of this node.
|
protected <T> T |
convertObject(Object rawValue,
Class<T> type) |
protected ParsedNode |
createNode(String namespace,
String nodeName) |
boolean |
equals(Object obj) |
ParsedNode |
getChild(String namespace,
String name)
Returns the ParsedNode defined by the given namespace and name.
|
List<ParsedNode> |
getChildren()
Returns the child ParsedNodes of this node.
|
List<ParsedNode> |
getChildren(String namespace,
String nodename)
Returns all child nodes with the given namespace and name.
|
Object |
getChildValue(String namespace,
String nodename)
Returns the value of the given node with no conversion attempted.
|
<T> T |
getChildValue(String namespace,
String nodename,
Class<T> type)
Returns the value of the given node, converted to the passed type.
|
<T> T |
getChildValue(String namespace,
String nodename,
T defaultValue)
Convenience method for
getChildValue(String, String, Class) but returns the passed defaultValue if the given node is null or not defined. |
String |
getName()
Each node key contains both a namespace and a name which together identifies the node.
|
String |
getNamespace()
Each node key contains both a namespace and a name which together identifies the node.
|
Object |
getValue()
Return the value associated with this node.
|
<T> T |
getValue(Class<T> type)
Return the value associated with this node converted to the given type.
|
int |
hashCode() |
protected boolean |
namespaceMatches(ParsedNode node,
String namespace) |
protected boolean |
nodeMatches(ParsedNode node,
String namespace,
String nodename)
Match the namespace and name of this node.
|
ParsedNode |
removeChild(String namespace,
String name) |
ParsedNode |
setValue(Object value)
Sets the value of this ParsedNode.
|
String |
toString() |
public String getNamespace()
public String getName()
public List<ParsedNode> getChildren()
public List<ParsedNode> getChildren(String namespace, String nodename)
public Object getValue()
public ParsedNode setValue(Object value) throws ParsedNodeException
ParsedNodeException
public <T> T getValue(Class<T> type) throws ParsedNodeException
ParsedNodeException
- if the current value type cannot be convertedpublic ParsedNode addChild(String namespace, String nodeName, Object value) throws ParsedNodeException
ParsedNodeException
protected ParsedNode createNode(String namespace, String nodeName)
public ParsedNode addChild(ParsedNode node) throws ParsedNodeException
ParsedNodeException
public ParsedNode addChildren(Map<String,Object> child) throws ParsedNodeException
setValue(Object)
) logic) is the value.ParsedNodeException
public ParsedNode getChild(String namespace, String name) throws ParsedNodeException
ParsedNodeException
- if multiple nodes match.public ParsedNode removeChild(String namespace, String name) throws ParsedNodeException
ParsedNodeException
protected boolean nodeMatches(ParsedNode node, String namespace, String nodename)
node
- namespace
- nodename
- protected boolean namespaceMatches(ParsedNode node, String namespace)
public <T> T getChildValue(String namespace, String nodename, T defaultValue) throws ParsedNodeException
getChildValue(String, String, Class)
but returns the passed defaultValue if the given node is null or not defined.ParsedNodeException
public <T> T getChildValue(String namespace, String nodename, Class<T> type) throws ParsedNodeException
ParsedNodeException
- if there is an error converting the valueprotected <T> T convertObject(Object rawValue, Class<T> type) throws ParsedNodeException
ParsedNodeException
public Object getChildValue(String namespace, String nodename) throws ParsedNodeException
ParsedNodeException
Copyright © 2023 Liquibase.org. All rights reserved.