Class ParsedNode


  • public class ParsedNode
    extends Object
    Acts as a standard abstract syntax layer for changelogs defined in different formats. 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:

    • Keys include a namespace as well as the node name
    • There can be multiple children nodes with the same node namespace+name
    • There is an unkeyed "value" object in addition to the children nodes
    • The value node cannot be a ParsedNode. If you attempt to set value to be or contain a ParsedNode it will actually be set as a child
    • Constructor Detail

      • ParsedNode

        public ParsedNode​(String namespace,
                          String name)
    • Method Detail

      • getNamespace

        public String getNamespace()
        Each node key contains both a namespace and a name which together identifies the node.
      • getName

        public String getName()
        Each node key contains both a namespace and a name which together identifies the node.
      • getChildren

        public List<ParsedNode> getChildren()
        Returns the child ParsedNodes of this node. Returned list is unmodifiableList.
      • getChildren

        public List<ParsedNode> getChildren​(String namespace,
                                            String nodename)
        Returns all child nodes with the given namespace and name. If none match, an empty list is returned. Returned list is unmodifiableList.
      • getValue

        public Object getValue()
        Return the value associated with this node.
      • setValue

        public ParsedNode setValue​(Object value)
                            throws ParsedNodeException
        Sets the value of this ParsedNode. If the passed value is a ParsedNode, it is added as a child, not as the value. If the passed value is a Map, it is converted to a ParsedNode and added as a child, not as the value. If the passed value is a Collection, each object is added as a child if it is a ParsedNode or a Map. If there are multiple simple values in a passed collection, value is set to a List. If there is a single value in a collection, value is set to the single value.
        Throws:
        ParsedNodeException
      • getValue

        public <T> T getValue​(Class<T> type)
                       throws ParsedNodeException
        Return the value associated with this node converted to the given type.
        Throws:
        ParsedNodeException - if the current value type cannot be converted
      • nodeMatches

        protected boolean nodeMatches​(ParsedNode node,
                                      String namespace,
                                      String nodename)
        Matches the namespace and name of this node. Matching is performed case-insensitively.
        Parameters:
        node - The node to match against.
        namespace - The namespace to match against.
        nodename - The name to match against.
        Returns:
        true if the namespace and name of the node match the specified namespace and name, ignoring case; false otherwise.
      • namespaceMatches

        protected boolean namespaceMatches​(ParsedNode node,
                                           String namespace)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object