Package com.unboundid.scim2.common
Class Path
- java.lang.Object
-
- com.unboundid.scim2.common.Path
-
- All Implemented Interfaces:
Iterable<Path.Element>
public final class Path extends Object implements Iterable<Path.Element>
This class represents a path to one or more JSON values that are the targets of a SCIM PATCH operation. A path may also be used to describe which JSON values to get or set when manipulating SCIM resources using theGenericScimResource
class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Path.Element
This class represents an element of the path.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Path
attribute(Path path)
Create a new path to the sub-attribute path of the attribute referenced by this path.Path
attribute(String attribute)
Create a new path to a sub-attribute of the attribute referenced by this path.Path
attribute(String attribute, Filter valueFilter)
Create a new path to a sub-set of values of a sub-attribute of the attribute referenced by this path.boolean
equals(Object o)
static Path
fromString(String pathString)
Parse a path from its string representation.Path.Element
getElement(int index)
Retrieves the path element at the specified index.String
getSchemaUrn()
Retrieves the schema URN of the attribute referenced by this path.int
hashCode()
boolean
isRoot()
Whether this path targets the root of the JSON object that represents the SCIM resource or an schema extension.Iterator<Path.Element>
iterator()
Path
replace(int index, Filter valueFilter)
Create a new path where the filter at the specified index is replaced with the one provided.Path
replace(int index, String attribute)
Create a new path where the attribute at the specified index is replaced with the one provided.Path
replace(int index, String attribute, Filter valueFilter)
Create a new path where the attribute and filter at the specified index is replaced with those provided.static Path
root()
Creates a path to the root of the JSON object that represents the SCIM resource.static <T> Path
root(Class<T> extensionClass)
Creates a path to the root of the JSON object that contains all the extension attributes of an extension schema defined by the provided class.static Path
root(String schemaUrn)
Creates a path to the root of the JSON object that contains all the attributes of a schema.int
size()
Retrieves the number of elements in this path.Path
subPath(int index)
Creates a new path from beginning portion of this path to the specified index (exclusive).String
toString()
void
toString(StringBuilder builder)
Append the string representation of the attribute path to the provided buffer.Path
withoutFilters()
Create a new path from this path with any value filters removed.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
attribute
public Path attribute(String attribute)
Create a new path to a sub-attribute of the attribute referenced by this path.- Parameters:
attribute
- The name of the sub-attribute.- Returns:
- A new path to a sub-attribute of the attribute referenced by this path.
-
attribute
public Path attribute(String attribute, Filter valueFilter)
Create a new path to a sub-set of values of a sub-attribute of the attribute referenced by this path.- Parameters:
attribute
- The name of the sub-attribute.valueFilter
- The value filter.- Returns:
- A new path to a sub-attribute of the attribute referenced by this path.
-
attribute
public Path attribute(Path path)
Create a new path to the sub-attribute path of the attribute referenced by this path.- Parameters:
path
- The path of the sub-attribute.- Returns:
- A new path to a sub-attribute of the attribute referenced by this path.
-
replace
public Path replace(int index, String attribute, Filter valueFilter)
Create a new path where the attribute and filter at the specified index is replaced with those provided.- Parameters:
index
- The index of the element to replace.attribute
- The replacement attribute.valueFilter
- The replacement value filter.- Returns:
- The new path.
-
replace
public Path replace(int index, String attribute)
Create a new path where the attribute at the specified index is replaced with the one provided.- Parameters:
index
- The index of the element to replace.attribute
- The replacement attribute.- Returns:
- The new path.
-
replace
public Path replace(int index, Filter valueFilter)
Create a new path where the filter at the specified index is replaced with the one provided.- Parameters:
index
- The index of the element to replace.valueFilter
- The replacement value filter.- Returns:
- The new path.
-
subPath
public Path subPath(int index) throws IndexOutOfBoundsException
Creates a new path from beginning portion of this path to the specified index (exclusive). The last element in the newly created path will be the provided index - 1.- Parameters:
index
- The exclusive index of the endpoint path element.- Returns:
- A new path to a beginning portion of this path.
- Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index > size()
)
-
iterator
public Iterator<Path.Element> iterator()
- Specified by:
iterator
in interfaceIterable<Path.Element>
-
getElement
public Path.Element getElement(int index) throws IndexOutOfBoundsException
Retrieves the path element at the specified index.- Parameters:
index
- The index of the path element to retrieve.- Returns:
- The path element at the index.
- Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()
)
-
isRoot
public boolean isRoot()
Whether this path targets the root of the JSON object that represents the SCIM resource or an schema extension.- Returns:
true
if this path targets the root of the JSON object that represents the SCIM resource or an schema extension orfalse
otherwise.
-
size
public int size()
Retrieves the number of elements in this path.- Returns:
- the number of elements in this path.
-
withoutFilters
public Path withoutFilters()
Create a new path from this path with any value filters removed.- Returns:
- A new path from this path with any value filters removed.
-
fromString
public static Path fromString(String pathString) throws BadRequestException
Parse a path from its string representation.- Parameters:
pathString
- The string representation of the path.- Returns:
- The parsed path.
- Throws:
BadRequestException
- if the path string could not be parsed.
-
root
public static Path root()
Creates a path to the root of the JSON object that represents the SCIM resource.- Returns:
- The path to the root of the JSON object that represents the SCIM resource.
-
root
public static Path root(String schemaUrn)
Creates a path to the root of the JSON object that contains all the attributes of a schema.- Parameters:
schemaUrn
- The schema URN ornull
.- Returns:
- The path to the root of the JSON object that contains all the attributes of an extension URN.
-
root
public static <T> Path root(Class<T> extensionClass)
Creates a path to the root of the JSON object that contains all the extension attributes of an extension schema defined by the provided class.- Type Parameters:
T
- The generic type parameter of the Java class used to represent the extension.- Parameters:
extensionClass
- The the extension class that defines the extension schema.- Returns:
- The path to the root of the JSON object that contains all the extension attributes of an extension schema.
-
getSchemaUrn
public String getSchemaUrn()
Retrieves the schema URN of the attribute referenced by this path.- Returns:
- The schema URN of the attribute referenced by this path or
null
if not specified.
-
toString
public void toString(StringBuilder builder)
Append the string representation of the attribute path to the provided buffer.- Parameters:
builder
- The buffer to which the string representation of the attribute path is to be appended.
-
-