Class AbstractNodeState

    • Field Summary

      • Fields inherited from interface org.apache.jackrabbit.oak.spi.state.NodeState

        EXISTS
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkValidName​(java.lang.String name)  
      boolean compareAgainstBaseState​(NodeState base, NodeStateDiff diff)
      Generic default comparison algorithm that simply walks through the property and child node lists of the given base state and compares the entries one by one with corresponding ones (if any) in this state.
      static boolean compareAgainstBaseState​(NodeState state, NodeState base, NodeStateDiff diff)
      Generic default comparison algorithm that simply walks through the property and child node lists of the given base state and compares the entries one by one with corresponding ones (if any) in this state.
      static boolean comparePropertiesAgainstBaseState​(NodeState state, NodeState base, NodeStateDiff diff)
      Compares the properties of base state with this state.
      boolean equals​(java.lang.Object that)
      Checks whether the given object is equal to this one.
      static boolean equals​(NodeState a, NodeState b)  
      boolean getBoolean​(@NotNull java.lang.String name)
      Returns the boolean value of the named property.
      static boolean getBoolean​(NodeState state, java.lang.String name)  
      long getChildNodeCount​(long max)
      Returns the number of iterable child nodes of this node.
      java.lang.Iterable<java.lang.String> getChildNodeNames()
      Returns the names of all iterable child nodes.
      long getLong​(java.lang.String name)
      Returns the long value of the named property.
      static long getLong​(NodeState state, java.lang.String name)  
      @Nullable java.lang.String getName​(@NotNull java.lang.String name)
      Returns the name value of the named property.
      static java.lang.String getName​(NodeState state, java.lang.String name)  
      @NotNull java.lang.Iterable<java.lang.String> getNames​(@NotNull java.lang.String name)
      Returns the name values of the named property.
      static java.lang.Iterable<java.lang.String> getNames​(NodeState state, java.lang.String name)  
      PropertyState getProperty​(@NotNull java.lang.String name)
      Returns the named property, or null if no such property exists.
      long getPropertyCount()
      Returns the number of properties of this node.
      java.lang.String getString​(java.lang.String name)
      Returns the string value of the named property.
      static java.lang.String getString​(NodeState state, java.lang.String name)  
      @NotNull java.lang.Iterable<java.lang.String> getStrings​(@NotNull java.lang.String name)
      Returns the string values of the named property.
      static java.lang.Iterable<java.lang.String> getStrings​(NodeState state, java.lang.String name)  
      int hashCode()
      Returns a hash code that's compatible with how the equals(Object) method is implemented.
      boolean hasProperty​(@NotNull java.lang.String name)
      Checks whether the named property exists.
      static boolean isValidName​(java.lang.String name)  
      java.lang.String toString()
      Returns a string representation of this node state.
      static java.lang.String toString​(NodeState state)  
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AbstractNodeState

        public AbstractNodeState()
    • Method Detail

      • isValidName

        public static boolean isValidName​(java.lang.String name)
      • checkValidName

        public static void checkValidName​(java.lang.String name)
                                   throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • getBoolean

        public static boolean getBoolean​(NodeState state,
                                         java.lang.String name)
      • getLong

        public static long getLong​(NodeState state,
                                   java.lang.String name)
      • getString

        public static java.lang.String getString​(NodeState state,
                                                 java.lang.String name)
      • getStrings

        public static java.lang.Iterable<java.lang.String> getStrings​(NodeState state,
                                                                      java.lang.String name)
      • getName

        public static java.lang.String getName​(NodeState state,
                                               java.lang.String name)
      • getNames

        public static java.lang.Iterable<java.lang.String> getNames​(NodeState state,
                                                                    java.lang.String name)
      • compareAgainstBaseState

        public static boolean compareAgainstBaseState​(NodeState state,
                                                      NodeState base,
                                                      NodeStateDiff diff)
        Generic default comparison algorithm that simply walks through the property and child node lists of the given base state and compares the entries one by one with corresponding ones (if any) in this state.
      • comparePropertiesAgainstBaseState

        public static boolean comparePropertiesAgainstBaseState​(NodeState state,
                                                                NodeState base,
                                                                NodeStateDiff diff)
        Compares the properties of base state with this state.
        Parameters:
        state - the head node state.
        base - the base node state.
        diff - the node state diff.
        Returns:
        true to continue the comparison, false to stop
      • toString

        public static java.lang.String toString​(NodeState state)
      • hasProperty

        public boolean hasProperty​(@NotNull
                                   @NotNull java.lang.String name)
        Description copied from interface: NodeState
        Checks whether the named property exists. The implementation is equivalent to getProperty(name) != null, but may be optimized to avoid having to load the property value.
        Specified by:
        hasProperty in interface NodeState
        Parameters:
        name - property name
        Returns:
        true if the named property exists, false otherwise
      • getBoolean

        public boolean getBoolean​(@NotNull
                                  @NotNull java.lang.String name)
        Description copied from interface: NodeState
        Returns the boolean value of the named property. The implementation is equivalent to the following code, but may be optimized.
         
         PropertyState property = state.getProperty(name);
         return property != null
             && property.getType() == Type.BOOLEAN
             && property.getValue(Type.BOOLEAN);
         
         
        Specified by:
        getBoolean in interface NodeState
        Parameters:
        name - property name
        Returns:
        boolean value of the named property, or false
      • getLong

        public long getLong​(java.lang.String name)
        Description copied from interface: NodeState
        Returns the long value of the named property. The implementation is equivalent to the following code, but may be optimized.
         
         PropertyState property = state.getProperty(name);
         if (property != null && property.getType() == Type.LONG) {
             return property.getValue(Type.LONG);
         } else {
             return 0;
         }
         
         
        Specified by:
        getLong in interface NodeState
        Parameters:
        name - property name
        Returns:
        long value of the named property, or zero
      • getString

        public java.lang.String getString​(java.lang.String name)
        Description copied from interface: NodeState
        Returns the string value of the named property. The implementation is equivalent to the following code, but may be optimized.
         
         PropertyState property = state.getProperty(name);
         if (property != null && property.getType() == Type.STRING) {
             return property.getValue(Type.STRING);
         } else {
             return null;
         }
         
         
        Specified by:
        getString in interface NodeState
        Parameters:
        name - property name
        Returns:
        string value of the named property, or null
      • getStrings

        @NotNull
        public @NotNull java.lang.Iterable<java.lang.String> getStrings​(@NotNull
                                                                        @NotNull java.lang.String name)
        Description copied from interface: NodeState
        Returns the string values of the named property. The implementation is equivalent to the following code, but may be optimized.
         
         PropertyState property = state.getProperty(name);
         if (property != null && property.getType() == Type.STRINGS) {
             return property.getValue(Type.STRINGS);
         } else {
             return Collections.emptyList();
         }
         
         
        Specified by:
        getStrings in interface NodeState
        Parameters:
        name - property name
        Returns:
        string values of the named property, or an empty collection
      • getName

        @Nullable
        public @Nullable java.lang.String getName​(@NotNull
                                                  @NotNull java.lang.String name)
        Description copied from interface: NodeState
        Returns the name value of the named property. The implementation is equivalent to the following code, but may be optimized.
         
         PropertyState property = state.getProperty(name);
         if (property != null && property.getType() == Type.NAME) {
             return property.getValue(Type.NAME);
         } else {
             return null;
         }
         
         
        Specified by:
        getName in interface NodeState
        Parameters:
        name - property name
        Returns:
        name value of the named property, or null
      • getNames

        @NotNull
        public @NotNull java.lang.Iterable<java.lang.String> getNames​(@NotNull
                                                                      @NotNull java.lang.String name)
        Description copied from interface: NodeState
        Returns the name values of the named property. The implementation is equivalent to the following code, but may be optimized.
         
         PropertyState property = state.getProperty(name);
         if (property != null && property.getType() == Type.NAMES) {
             return property.getValue(Type.NAMES);
         } else {
             return Collections.emptyList();
         }
         
         
        Specified by:
        getNames in interface NodeState
        Parameters:
        name - property name
        Returns:
        name values of the named property, or an empty collection
      • getProperty

        public PropertyState getProperty​(@NotNull
                                         @NotNull java.lang.String name)
        Description copied from interface: NodeState
        Returns the named property, or null if no such property exists.
        Specified by:
        getProperty in interface NodeState
        Parameters:
        name - name of the property to return
        Returns:
        named property, or null if not found
      • getPropertyCount

        public long getPropertyCount()
        Description copied from interface: NodeState
        Returns the number of properties of this node.
        Specified by:
        getPropertyCount in interface NodeState
        Returns:
        number of properties
      • getChildNodeCount

        public long getChildNodeCount​(long max)
        Description copied from interface: NodeState
        Returns the number of iterable child nodes of this node.

        If an implementation knows the exact value, it returns it (even if the value is higher than max). If the implementation does not know the exact value, and the child node count is higher than max, it may return Long.MAX_VALUE. The cost of the operation is at most O(max).

        Specified by:
        getChildNodeCount in interface NodeState
        Parameters:
        max - the maximum number of entries to traverse
        Returns:
        number of iterable child nodes
      • getChildNodeNames

        public java.lang.Iterable<java.lang.String> getChildNodeNames()
        Description copied from interface: NodeState
        Returns the names of all iterable child nodes.
        Specified by:
        getChildNodeNames in interface NodeState
        Returns:
        child node names in some stable order
      • compareAgainstBaseState

        public boolean compareAgainstBaseState​(NodeState base,
                                               NodeStateDiff diff)
        Generic default comparison algorithm that simply walks through the property and child node lists of the given base state and compares the entries one by one with corresponding ones (if any) in this state.
        Specified by:
        compareAgainstBaseState in interface NodeState
        Parameters:
        base - base state
        diff - handler of node state differences
        Returns:
        true if the full diff was performed, or false if it was aborted as requested by the handler (see the NodeStateDiff contract for more details)
      • toString

        public java.lang.String toString()
        Returns a string representation of this node state.
        Overrides:
        toString in class java.lang.Object
        Returns:
        string representation
      • equals

        public boolean equals​(java.lang.Object that)
        Checks whether the given object is equal to this one. Two node states are considered equal if all their properties and child nodes match, regardless of ordering. Subclasses may override this method with a more efficient equality check if one is available.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        that - target of the comparison
        Returns:
        true if the objects are equal, false otherwise
      • hashCode

        public int hashCode()
        Returns a hash code that's compatible with how the equals(Object) method is implemented. The current implementation simply returns zero for everything since NodeState instances are not intended for use as hash keys.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        hash code