|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.graph.Location
@Immutable public abstract class Location
The location of a node, as specified by either its path, UUID, and/or identification properties. Hash codes are not implemented in this base class to allow immutable subclasses to calculate and cache the hash code during object construction.
Field Summary | |
---|---|
protected static Iterator<Property> |
NO_ID_PROPERTIES_ITERATOR
Simple shared iterator instance that is used when there are no properties. |
Constructor Summary | |
---|---|
Location()
|
Method Summary | |
---|---|
static Comparator<Location> |
comparator()
Get a Comparator that can be used to compare two Location objects. |
int |
compareTo(Location that)
|
static Location |
create(Iterable<Property> idProperties)
Create a location defined by a path and an iterator over identification properties. |
static Location |
create(List<Property> idProperties)
Create a location defined by multiple identification properties. |
static Location |
create(Path path)
Create a location defined by a path. |
static Location |
create(Path path,
Iterable<Property> idProperties)
Create a location defined by a path and an iterator over identification properties. |
static Location |
create(Path path,
Property idProperty)
Create a location defined by a path and a single identification property. |
static Location |
create(Path path,
Property firstIdProperty,
Property... remainingIdProperties)
Create a location defined by a path and multiple identification properties. |
static Location |
create(Path path,
UUID uuid)
Create a location defined by a path and an UUID. |
static Location |
create(Property idProperty)
Create a location defined by a single identification property. |
static Location |
create(Property firstIdProperty,
Property... remainingIdProperties)
Create a location defined by multiple identification properties. |
static Location |
create(UUID uuid)
Create a location defined by a UUID. |
boolean |
equals(Object obj)
Two location objects are equal (or equivalent) if they share the same path and/or ID properties: if both locations have a path, they must have the same path; if both locations have ID properties, these properties must match. |
boolean |
equals(Object obj,
boolean requireSameNameSiblingIndexes)
Compare this location to the supplied location, and determine whether the two locations represent the same logical location. |
abstract List<Property> |
getIdProperties()
Get the identification properties that (at least in part) define this location. |
Property |
getIdProperty(Name name)
Get the identification property with the supplied name, if there is such a property. |
abstract Path |
getPath()
Get the path that (at least in part) defines this location. |
String |
getString()
Get the string form of the location. |
String |
getString(NamespaceRegistry namespaceRegistry)
Get the encoded string form of the location, using the supplied encoder to encode characters in each of the location's path and properties. |
String |
getString(NamespaceRegistry namespaceRegistry,
TextEncoder encoder)
Get the encoded string form of the location, using the supplied encoder to encode characters in each of the location's path and properties. |
String |
getString(NamespaceRegistry namespaceRegistry,
TextEncoder encoder,
TextEncoder delimiterEncoder)
Get the encoded string form of the location, using the supplied encoder to encode characters in each of the location's path and properties. |
String |
getString(TextEncoder encoder)
Get the encoded string form of the location, using the supplied encoder to encode characters in each of the location's path and properties. |
UUID |
getUuid()
Get the first UUID that is in one of the identification properties . |
int |
hashCode()
|
boolean |
hasIdProperties()
Return whether this location is defined (at least in part) with identification properties. |
boolean |
hasPath()
Return whether this location is defined (at least in part) by a path. |
protected static UUID |
identifierFor(Path identifierPath)
|
boolean |
isSame(Location that)
Determine whether this location has the same path and identification
properties : if one location has a path, then both must have the same path; likewise, if one location has ID properties,
then both must have the same ID properties. |
Iterator<Property> |
iterator()
|
String |
toString()
|
abstract Location |
with(Path newPath)
Create a copy of this location that uses the supplied path. |
abstract Location |
with(Property newIdProperty)
Create a copy of this location that adds the supplied identification property. |
abstract Location |
with(UUID uuid)
Create a copy of this location that adds the supplied UUID as an identification property. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final Iterator<Property> NO_ID_PROPERTIES_ITERATOR
Constructor Detail |
---|
public Location()
Method Detail |
---|
public static final Comparator<Location> comparator()
Comparator
that can be used to compare two Location objects. Note that Location implements Comparable
.
public static Location create(Path path)
path
- the path
Location
with the given path and no identification properties
IllegalArgumentException
- if path
is nullprotected static UUID identifierFor(Path identifierPath)
public static Location create(UUID uuid)
uuid
- the UUID
Location
with no path and a single identification property with the name
ModeShapeLexicon.UUID
and the given uuid
for a value.
IllegalArgumentException
- if uuid
is nullpublic static Location create(Path path, UUID uuid)
path
- the pathuuid
- the UUID, or null if there is no UUID
Location
with the given path (if any) and a single identification property with the name
ModeShapeLexicon.UUID
and the given uuid
(if it is present) for a value.
IllegalArgumentException
- if path
is nullpublic static Location create(Path path, Property idProperty)
path
- the pathidProperty
- the identification property
Location
with the given path and identification property (if it is present).
IllegalArgumentException
- if path
or idProperty
is nullpublic static Location create(Path path, Property firstIdProperty, Property... remainingIdProperties)
path
- the pathfirstIdProperty
- the first identification propertyremainingIdProperties
- the remaining identification property
Location
with the given path and identification properties.
IllegalArgumentException
- if any of the arguments are nullpublic static Location create(Path path, Iterable<Property> idProperties)
path
- the pathidProperties
- the iterator over the identification properties
Location
with the given path and identification properties
IllegalArgumentException
- if any of the arguments are nullpublic static Location create(Property idProperty)
idProperty
- the identification property
Location
with no path and the given identification property.
IllegalArgumentException
- if idProperty
is nullpublic static Location create(Property firstIdProperty, Property... remainingIdProperties)
firstIdProperty
- the first identification propertyremainingIdProperties
- the remaining identification property
Location
with no path and the given and identification properties.
IllegalArgumentException
- if any of the arguments are nullpublic static Location create(Iterable<Property> idProperties)
idProperties
- the iterator over the identification properties
Location
with no path and the given identification properties.
IllegalArgumentException
- if any of the arguments are nullpublic static Location create(List<Property> idProperties)
idProperties
- the identification properties
Location
with no path and the given identification properties.
IllegalArgumentException
- if idProperties
is null or emptypublic abstract Path getPath()
public boolean hasPath()
path
helps define this locationpublic abstract List<Property> getIdProperties()
public boolean hasIdProperties()
identification properties
help define this locationpublic Property getIdProperty(Name name)
name
- the name of the identification property
are no identification properties
public UUID getUuid()
identification properties
.
public boolean isSame(Location that)
path
and identification
properties
: if one location has a path, then both must have the same path; likewise, if one location has ID properties,
then both must have the same ID properties.
This is different than the behavior of equals(Object)
, which attempts to determine whether two locations are
equivalent. Two location objects are equivalent if they share the same path and/or ID properties: if both locations
have a path, they must have the same path; if both locations have ID properties, these properties must match.
that
- the other location to be compared
equals(Object)
public Iterator<Property> iterator()
iterator
in interface Iterable<Property>
Iterable.iterator()
public int hashCode()
hashCode
in class Object
Object.hashCode()
public boolean equals(Object obj)
Two location objects are equal (or equivalent) if they share the same path and/or ID properties: if both locations have a path, they must have the same path; if both locations have ID properties, these properties must match.
To determine whether two location objects represent the same location, use isSame(Location)
: if one location has a
path, then both must have the same path; likewise, if one location has ID properties, then both must have the same ID
properties.
equals
in class Object
Object.equals(java.lang.Object)
,
isSame(Location)
public boolean equals(Object obj, boolean requireSameNameSiblingIndexes)
/x/y
" path/x/y/z
"/x/y/z
" path and an identification property {id=3}Note that passing a null location as a parameter will always return false.
obj
- the other location to comparerequireSameNameSiblingIndexes
- true if the paths must have equivalent same-name-sibling indexes
, or false if the same-name-siblings may be different
public int compareTo(Location that)
compareTo
in interface Comparable<Location>
Comparable.compareTo(java.lang.Object)
public String getString()
getString(TextEncoder)
,
getString(NamespaceRegistry)
,
getString(NamespaceRegistry, TextEncoder)
,
getString(NamespaceRegistry, TextEncoder, TextEncoder)
public String getString(TextEncoder encoder)
encoder
- the encoder to use, or null if the default encoder should be used
getString()
,
getString(NamespaceRegistry)
,
getString(NamespaceRegistry, TextEncoder)
,
getString(NamespaceRegistry, TextEncoder, TextEncoder)
public String getString(NamespaceRegistry namespaceRegistry)
namespaceRegistry
- the namespace registry to use for getting the string form of the path and properties, or null if
no namespace registry should be used
getString()
,
getString(TextEncoder)
,
getString(NamespaceRegistry, TextEncoder)
,
getString(NamespaceRegistry, TextEncoder, TextEncoder)
public String getString(NamespaceRegistry namespaceRegistry, TextEncoder encoder)
namespaceRegistry
- the namespace registry to use for getting the string form of the path and properties, or null if
no namespace registry should be usedencoder
- the encoder to use, or null if the default encoder should be used
getString()
,
getString(TextEncoder)
,
getString(NamespaceRegistry)
,
getString(NamespaceRegistry, TextEncoder, TextEncoder)
public String getString(NamespaceRegistry namespaceRegistry, TextEncoder encoder, TextEncoder delimiterEncoder)
namespaceRegistry
- the namespace registry to use for getting the string form of the path and properties, or null if
no namespace registry should be usedencoder
- the encoder to use, or null if the default encoder should be useddelimiterEncoder
- the encoder to use for encoding the delimiters in paths, names, and properties, or null if the
standard delimiters should be used
getString()
,
getString(TextEncoder)
,
getString(NamespaceRegistry)
,
getString(NamespaceRegistry, TextEncoder)
public String toString()
toString
in class Object
Object.toString()
public abstract Location with(Property newIdProperty)
newIdProperty
- the new identification property, which may be null
public abstract Location with(Path newPath)
newPath
- the new path for the location
public abstract Location with(UUID uuid)
uuid
- the new UUID, which may be null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |