Class PathBuilder
java.lang.Object
org.apache.jackrabbit.spi.commons.name.PathBuilder
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
ConstructorDescriptionCreates a new PathBuilder to create a Path using thedefault PathFactory
.PathBuilder
(Path parent) Creates a new PathBuilder and initialized it with elements of the given path.PathBuilder
(Path.Element[] elements) Creates a new PathBuilder and initialized it with the given path elements.PathBuilder
(PathFactory factory) Creates a new PathBuilder. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAll
(Path.Element[] elements) Adds the given elementsvoid
Inserts the element at the beginning of the path to be built.void
Inserts the element at the beginning of the path to be built.void
addFirst
(Path.Element elem) Inserts the element at the beginning of the path to be built.void
Inserts the element at the end of the path to be built.void
Inserts the element at the end of the path to be built.void
addLast
(Path.Element elem) Inserts the element at the end of the path to be built.void
addRoot()
Adds thePathFactory.getRootElement()
.getPath()
Assembles the built path and returns a newPath
.
-
Constructor Details
-
PathBuilder
public PathBuilder()Creates a new PathBuilder to create a Path using thedefault PathFactory
. SeePathBuilder(PathFactory)
for a constructor explicitly specifying the factory to use. -
PathBuilder
Creates a new PathBuilder.- Parameters:
factory
- The PathFactory used to create the elements and the final path.
-
PathBuilder
Creates a new PathBuilder and initialized it with the given path elements.- Parameters:
elements
-
-
PathBuilder
Creates a new PathBuilder and initialized it with elements of the given path.- Parameters:
parent
-
-
-
Method Details
-
addRoot
public void addRoot()Adds thePathFactory.getRootElement()
. -
addAll
Adds the given elements- Parameters:
elements
-
-
addFirst
Inserts the element at the beginning of the path to be built.- Parameters:
elem
-
-
addFirst
Inserts the element at the beginning of the path to be built.- Parameters:
name
-
-
addFirst
Inserts the element at the beginning of the path to be built.- Parameters:
name
-index
-
-
addLast
Inserts the element at the end of the path to be built.- Parameters:
elem
-
-
addLast
Inserts the element at the end of the path to be built.- Parameters:
name
-
-
addLast
Inserts the element at the end of the path to be built.- Parameters:
name
-index
-
-
getPath
Assembles the built path and returns a newPath
.- Returns:
- a new
Path
- Throws:
MalformedPathException
- if the internal path element queue is empty.
-