Class PathBuilder


  • public final class PathBuilder
    extends Object
    Helper class used to build a path from pre-parsed path elements.

    Note that this class does neither validate the format of the path elements nor does it validate the format of the entire path. This class should therefore only be used in situations, where the elements and the resulting path are known to be valid. The regular way of creating a Path object is by calling any of the PathFactory.create()methods.

    • Constructor Summary

      Constructors 
      Constructor Description
      PathBuilder()
      Creates a new PathBuilder to create a Path using the default PathFactory.
      PathBuilder​(org.apache.jackrabbit.spi.Path parent)
      Creates a new PathBuilder and initialized it with elements of the given path.
      PathBuilder​(org.apache.jackrabbit.spi.Path.Element[] elements)
      Creates a new PathBuilder and initialized it with the given path elements.
      PathBuilder​(org.apache.jackrabbit.spi.PathFactory factory)
      Creates a new PathBuilder.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addAll​(org.apache.jackrabbit.spi.Path.Element[] elements)
      Adds the given elements
      void addFirst​(org.apache.jackrabbit.spi.Name name)
      Inserts the element at the beginning of the path to be built.
      void addFirst​(org.apache.jackrabbit.spi.Name name, int index)
      Inserts the element at the beginning of the path to be built.
      void addFirst​(org.apache.jackrabbit.spi.Path.Element elem)
      Inserts the element at the beginning of the path to be built.
      void addLast​(org.apache.jackrabbit.spi.Name name)
      Inserts the element at the end of the path to be built.
      void addLast​(org.apache.jackrabbit.spi.Name name, int index)
      Inserts the element at the end of the path to be built.
      void addLast​(org.apache.jackrabbit.spi.Path.Element elem)
      Inserts the element at the end of the path to be built.
      void addRoot()
      Adds the PathFactory.getRootElement().
      org.apache.jackrabbit.spi.Path getPath()
      Assembles the built path and returns a new Path.
    • Constructor Detail

      • PathBuilder

        public PathBuilder​(org.apache.jackrabbit.spi.PathFactory factory)
        Creates a new PathBuilder.
        Parameters:
        factory - The PathFactory used to create the elements and the final path.
      • PathBuilder

        public PathBuilder​(org.apache.jackrabbit.spi.Path.Element[] elements)
        Creates a new PathBuilder and initialized it with the given path elements.
        Parameters:
        elements -
      • PathBuilder

        public PathBuilder​(org.apache.jackrabbit.spi.Path parent)
        Creates a new PathBuilder and initialized it with elements of the given path.
        Parameters:
        parent -
    • Method Detail

      • addRoot

        public void addRoot()
        Adds the PathFactory.getRootElement().
      • addAll

        public void addAll​(org.apache.jackrabbit.spi.Path.Element[] elements)
        Adds the given elements
        Parameters:
        elements -
      • addFirst

        public void addFirst​(org.apache.jackrabbit.spi.Path.Element elem)
        Inserts the element at the beginning of the path to be built.
        Parameters:
        elem -
      • addFirst

        public void addFirst​(org.apache.jackrabbit.spi.Name name)
        Inserts the element at the beginning of the path to be built.
        Parameters:
        name -
      • addFirst

        public void addFirst​(org.apache.jackrabbit.spi.Name name,
                             int index)
        Inserts the element at the beginning of the path to be built.
        Parameters:
        name -
        index -
      • addLast

        public void addLast​(org.apache.jackrabbit.spi.Path.Element elem)
        Inserts the element at the end of the path to be built.
        Parameters:
        elem -
      • addLast

        public void addLast​(org.apache.jackrabbit.spi.Name name)
        Inserts the element at the end of the path to be built.
        Parameters:
        name -
      • addLast

        public void addLast​(org.apache.jackrabbit.spi.Name name,
                            int index)
        Inserts the element at the end of the path to be built.
        Parameters:
        name -
        index -
      • getPath

        public org.apache.jackrabbit.spi.Path getPath()
                                               throws MalformedPathException
        Assembles the built path and returns a new Path.
        Returns:
        a new Path
        Throws:
        MalformedPathException - if the internal path element queue is empty.