Class XMPPath

  • All Implemented Interfaces:
    java.lang.Iterable<XMPPathSegment>, java.util.Collection<XMPPathSegment>, java.util.List<XMPPathSegment>

    public class XMPPath
    extends java.lang.Object
    implements java.util.List<XMPPathSegment>
    XMPPath is a Class that provides an easy iterative description of a specific path into the XMP tree. Each XMPPathSegment represents one segment of the path into the XMP tree.
    • Constructor Detail

      • XMPPath

        public XMPPath()
        Creates an empty XMPPath object
    • Method Detail

      • parse

        public static XMPPath parse​(java.lang.String path,
                                    java.util.Map<java.lang.String,​java.lang.String> prefixContract)
                             throws XMPPathParserException
        Creates an XMPPath object by parsing an XMP path String and creates one path segment for each detected segment in the path.
        Parameters:
        path - Path string to parse
        prefixContract - A Map that contains the mapping between Namespaces and their prefixes. This must be provided to interpret the path correctly. The key must be the prefix and the value the namespace!
        Throws:
        XMPPathParserException - If the path has an invalid format or a prefix is found that is not defined in the prefixContract
      • serialize

        public java.lang.String serialize()
        Serializes the XMPPath object to a String representation. This will produce a long form of the path using the full namespace strings.
        Returns:
        String representation of the XMPPath
      • serialize

        public java.lang.String serialize​(java.util.Map<java.lang.String,​java.lang.String> prefixContract)
        Serializes the XMPPath object to a String representation. This produces a short form of the path using the prefixes provided by the contract.
        Parameters:
        prefixContract - A Map that contains the mapping between Namespaces and their prefixes. The key must be the prefix and the value the namespace!
        Returns:
        String representation of the XMPPath
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<XMPPathSegment>
        Specified by:
        size in interface java.util.List<XMPPathSegment>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<XMPPathSegment>
        Specified by:
        isEmpty in interface java.util.List<XMPPathSegment>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<XMPPathSegment>
        Specified by:
        contains in interface java.util.List<XMPPathSegment>
      • iterator

        public java.util.Iterator<XMPPathSegment> iterator()
        Specified by:
        iterator in interface java.util.Collection<XMPPathSegment>
        Specified by:
        iterator in interface java.lang.Iterable<XMPPathSegment>
        Specified by:
        iterator in interface java.util.List<XMPPathSegment>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<XMPPathSegment>
        Specified by:
        toArray in interface java.util.List<XMPPathSegment>
      • toArray

        public <T> T[] toArray​(T[] a)
        Specified by:
        toArray in interface java.util.Collection<XMPPathSegment>
        Specified by:
        toArray in interface java.util.List<XMPPathSegment>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<XMPPathSegment>
        Specified by:
        remove in interface java.util.List<XMPPathSegment>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<XMPPathSegment>
        Specified by:
        containsAll in interface java.util.List<XMPPathSegment>
      • addAll

        public boolean addAll​(java.util.Collection<? extends XMPPathSegment> c)
        Specified by:
        addAll in interface java.util.Collection<XMPPathSegment>
        Specified by:
        addAll in interface java.util.List<XMPPathSegment>
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends XMPPathSegment> c)
        Specified by:
        addAll in interface java.util.List<XMPPathSegment>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<XMPPathSegment>
        Specified by:
        removeAll in interface java.util.List<XMPPathSegment>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<XMPPathSegment>
        Specified by:
        retainAll in interface java.util.List<XMPPathSegment>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<XMPPathSegment>
        Specified by:
        clear in interface java.util.List<XMPPathSegment>
      • indexOf

        public int indexOf​(java.lang.Object o)
        Specified by:
        indexOf in interface java.util.List<XMPPathSegment>
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object o)
        Specified by:
        lastIndexOf in interface java.util.List<XMPPathSegment>
      • listIterator

        public java.util.ListIterator<XMPPathSegment> listIterator()
        Specified by:
        listIterator in interface java.util.List<XMPPathSegment>
      • listIterator

        public java.util.ListIterator<XMPPathSegment> listIterator​(int index)
        Specified by:
        listIterator in interface java.util.List<XMPPathSegment>
      • subList

        public java.util.List<XMPPathSegment> subList​(int fromIndex,
                                                      int toIndex)
        Specified by:
        subList in interface java.util.List<XMPPathSegment>
      • compare

        public XMPPath.Compare compare​(XMPPath path)
        Compares the provided path with this path.
        Parameters:
        path - the path to compare with
        Returns:
        The paths are equal if both have the same size and each segment is EQUAL. If the provided path is a subpath of this path, ANCESTOR is returned. If the provided path is an ancestor of this path, DESCENDANT is returned. In all other cases the paths are DIFFERENT.
        Throws:
        java.lang.IllegalArgumentException - If path is null
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<XMPPathSegment>
        Specified by:
        hashCode in interface java.util.List<XMPPathSegment>
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface java.util.Collection<XMPPathSegment>
        Specified by:
        equals in interface java.util.List<XMPPathSegment>
        Overrides:
        equals in class java.lang.Object