org.opends.server.admin
Class ManagedObjectPath<C extends ConfigurationClient,S extends Configuration>

java.lang.Object
  extended by org.opends.server.admin.ManagedObjectPath<C,S>
Type Parameters:
C - The type of client managed object configuration that this path references.
S - The type of server managed object configuration that this path references.

public final class ManagedObjectPath<C extends ConfigurationClient,S extends Configuration>
extends java.lang.Object

A path which can be used to determine the location of a managed object instance.

A path is made up of zero or more elements each of which represents a managed object. Managed objects are arranged hierarchically with the root configuration being the top-most managed object. Elements are ordered such that the root configuration managed object is the first element and subsequent elements representing managed objects further down the hierarchy.

A path can be encoded into a string representation using the toString() and toString(StringBuilder) methods. Conversely, this string representation can be parsed using the valueOf(String) method.

The string representation of a managed object path is similar in principle to a UNIX file-system path and is defined as follows:

The following path string representation identifies a connection handler instance (note that the type is not specified indicating that the path identifies a connection handler called my handler which can be any type of connection handler):
  /relation=connection-handler+name=my handler
 
If the identified connection handler must be an LDAP connection handler then the above path should include the type:
  /relation=connection-handler+type=ldap-connection-handler+name=my handler
 
The final example identifies the global configuration:
  /relation=global-configuration
 


Method Summary
<CC extends C,SS extends S>
ManagedObjectPath<CC,SS>
asSubType(AbstractManagedObjectDefinition<CC,SS> nd)
          Creates a new managed object path which has the same structure as this path except that the final path element is associated with the specified managed object definition.
<M extends ConfigurationClient,N extends Configuration>
ManagedObjectPath<M,N>
child(InstantiableRelationDefinition<? super M,? super N> r, AbstractManagedObjectDefinition<M,N> d, java.lang.String name)
          Creates a new child managed object path beneath the provided parent path having the specified managed object definition.
<M extends ConfigurationClient,N extends Configuration>
ManagedObjectPath<M,N>
child(InstantiableRelationDefinition<M,N> r, java.lang.String name)
          Creates a new child managed object path beneath the provided parent path using the relation's child managed object definition.
<M extends ConfigurationClient,N extends Configuration>
ManagedObjectPath<M,N>
child(OptionalRelationDefinition<? super M,? super N> r, AbstractManagedObjectDefinition<M,N> d)
          Creates a new child managed object path beneath the provided parent path having the specified managed object definition.
<M extends ConfigurationClient,N extends Configuration>
ManagedObjectPath<M,N>
child(OptionalRelationDefinition<M,N> r)
          Creates a new child managed object path beneath the provided parent path using the relation's child managed object definition.
<M extends ConfigurationClient,N extends Configuration>
ManagedObjectPath<M,N>
child(SingletonRelationDefinition<? super M,? super N> r, AbstractManagedObjectDefinition<M,N> d)
          Creates a new child managed object path beneath the provided parent path having the specified managed object definition.
<M extends ConfigurationClient,N extends Configuration>
ManagedObjectPath<M,N>
child(SingletonRelationDefinition<M,N> r)
          Creates a new child managed object path beneath the provided parent path using the relation's child managed object definition.
static ManagedObjectPath<RootCfgClient,RootCfg> emptyPath()
          Creates a new managed object path representing the configuration root.
 boolean equals(java.lang.Object obj)
          
 AbstractManagedObjectDefinition<C,S> getManagedObjectDefinition()
          Get the definition of the managed object referred to by this path.
 java.lang.String getName()
          Get the name of the managed object referred to by this path if applicable.
 RelationDefinition<? super C,? super S> getRelationDefinition()
          Get the relation definition of the managed object referred to by this path.
 int hashCode()
          
 boolean isEmpty()
          Determine whether or not this path contains any path elements.
 boolean matches(ManagedObjectPath<?,?> other)
          Determines whether this managed object path references the same location as the provided managed object path.
 ManagedObjectPath<?,?> parent()
          Creates a new parent managed object path representing the immediate parent of this path.
 ManagedObjectPath<?,?> parent(int offset)
          Creates a new parent managed object path the specified number of path elements above this path.
 ManagedObjectPath<C,S> rename(java.lang.String newName)
          Creates a new managed object path which has the same structure as this path except that the final path element is renamed.
 void serialize(ManagedObjectPathSerializer serializer)
          Serialize this managed object path using the provided serialization strategy.
 int size()
          Get the number of path elements in this managed object path.
 DN toDN()
          Creates a DN representation of this managed object path.
 java.lang.String toString()
          
 void toString(java.lang.StringBuilder builder)
          Appends a string representation of this managed object path to the provided string builder.
static ManagedObjectPath<?,?> valueOf(java.lang.String s)
          Returns a managed object path holding the value of the specified string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

emptyPath

public static ManagedObjectPath<RootCfgClient,RootCfg> emptyPath()
Creates a new managed object path representing the configuration root.

Returns:
Returns a new managed object path representing the configuration root.

valueOf

public static ManagedObjectPath<?,?> valueOf(java.lang.String s)
                                      throws java.lang.IllegalArgumentException
Returns a managed object path holding the value of the specified string.

Parameters:
s - The string to be parsed.
Returns:
Returns a managed object path holding the value of the specified string.
Throws:
java.lang.IllegalArgumentException - If the string could not be parsed.

asSubType

public <CC extends C,SS extends S> ManagedObjectPath<CC,SS> asSubType(AbstractManagedObjectDefinition<CC,SS> nd)
Creates a new managed object path which has the same structure as this path except that the final path element is associated with the specified managed object definition.

Type Parameters:
CC - The type of client managed object configuration that this path will reference.
SS - The type of server managed object configuration that this path will reference.
Parameters:
nd - The new managed object definition.
Returns:
Returns a new managed object path which has the same structure as this path except that the final path element is associated with the specified managed object definition.

child

public <M extends ConfigurationClient,N extends Configuration> ManagedObjectPath<M,N> child(InstantiableRelationDefinition<? super M,? super N> r,
                                                                                            AbstractManagedObjectDefinition<M,N> d,
                                                                                            java.lang.String name)
                                                                               throws java.lang.IllegalArgumentException
Creates a new child managed object path beneath the provided parent path having the specified managed object definition.

Type Parameters:
M - The type of client managed object configuration that the child path references.
N - The type of server managed object configuration that the child path references.
Parameters:
r - The instantiable relation referencing the child.
d - The managed object definition associated with the child (must be a sub-type of the relation).
name - The relative name of the child managed object.
Returns:
Returns a new child managed object path beneath the provided parent path.
Throws:
java.lang.IllegalArgumentException - If the provided name is empty or blank.

child

public <M extends ConfigurationClient,N extends Configuration> ManagedObjectPath<M,N> child(InstantiableRelationDefinition<M,N> r,
                                                                                            java.lang.String name)
                                                                               throws java.lang.IllegalArgumentException
Creates a new child managed object path beneath the provided parent path using the relation's child managed object definition.

Type Parameters:
M - The type of client managed object configuration that the child path references.
N - The type of server managed object configuration that the child path references.
Parameters:
r - The instantiable relation referencing the child.
name - The relative name of the child managed object.
Returns:
Returns a new child managed object path beneath the provided parent path.
Throws:
java.lang.IllegalArgumentException - If the provided name is empty or blank.

child

public <M extends ConfigurationClient,N extends Configuration> ManagedObjectPath<M,N> child(OptionalRelationDefinition<? super M,? super N> r,
                                                                                            AbstractManagedObjectDefinition<M,N> d)
Creates a new child managed object path beneath the provided parent path having the specified managed object definition.

Type Parameters:
M - The type of client managed object configuration that the child path references.
N - The type of server managed object configuration that the child path references.
Parameters:
r - The optional relation referencing the child.
d - The managed object definition associated with the child (must be a sub-type of the relation).
Returns:
Returns a new child managed object path beneath the provided parent path.

child

public <M extends ConfigurationClient,N extends Configuration> ManagedObjectPath<M,N> child(OptionalRelationDefinition<M,N> r)
Creates a new child managed object path beneath the provided parent path using the relation's child managed object definition.

Type Parameters:
M - The type of client managed object configuration that the child path references.
N - The type of server managed object configuration that the child path references.
Parameters:
r - The optional relation referencing the child.
Returns:
Returns a new child managed object path beneath the provided parent path.

child

public <M extends ConfigurationClient,N extends Configuration> ManagedObjectPath<M,N> child(SingletonRelationDefinition<? super M,? super N> r,
                                                                                            AbstractManagedObjectDefinition<M,N> d)
Creates a new child managed object path beneath the provided parent path having the specified managed object definition.

Type Parameters:
M - The type of client managed object configuration that the child path references.
N - The type of server managed object configuration that the child path references.
Parameters:
r - The singleton relation referencing the child.
d - The managed object definition associated with the child (must be a sub-type of the relation).
Returns:
Returns a new child managed object path beneath the provided parent path.

child

public <M extends ConfigurationClient,N extends Configuration> ManagedObjectPath<M,N> child(SingletonRelationDefinition<M,N> r)
Creates a new child managed object path beneath the provided parent path using the relation's child managed object definition.

Type Parameters:
M - The type of client managed object configuration that the child path references.
N - The type of server managed object configuration that the child path references.
Parameters:
r - The singleton relation referencing the child.
Returns:
Returns a new child managed object path beneath the provided parent path.

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

getManagedObjectDefinition

public AbstractManagedObjectDefinition<C,S> getManagedObjectDefinition()
Get the definition of the managed object referred to by this path.

When the path is empty, the RootCfgDefn is returned.

Returns:
Returns the definition of the managed object referred to by this path, or the RootCfgDefn if the path is empty.

getName

public java.lang.String getName()
Get the name of the managed object referred to by this path if applicable.

If there path does not refer to an instantiable managed object null is returned.

Returns:
Returns the name of the managed object referred to by this path, or null if the managed object does not have a name.

getRelationDefinition

public RelationDefinition<? super C,? super S> getRelationDefinition()
Get the relation definition of the managed object referred to by this path.

When the path is empty, the null is returned.

Returns:
Returns the relation definition of the managed object referred to by this path, or the null if the path is empty.

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

isEmpty

public boolean isEmpty()
Determine whether or not this path contains any path elements.

Returns:
Returns true if this path does not contain any path elements.

matches

public boolean matches(ManagedObjectPath<?,?> other)
Determines whether this managed object path references the same location as the provided managed object path.

This method differs from equals in that it ignores sub-type definitions.

Parameters:
other - The managed object path to be compared.
Returns:
Returns true if this managed object path references the same location as the provided managed object path.

parent

public ManagedObjectPath<?,?> parent()
                              throws java.lang.IllegalArgumentException
Creates a new parent managed object path representing the immediate parent of this path. This method is a short-hand for parent(1).

Returns:
Returns a new parent managed object path representing the immediate parent of this path.
Throws:
java.lang.IllegalArgumentException - If this path does not have a parent (i.e. it is the empty path).

parent

public ManagedObjectPath<?,?> parent(int offset)
                              throws java.lang.IllegalArgumentException
Creates a new parent managed object path the specified number of path elements above this path.

Parameters:
offset - The number of path elements (0 - means no offset, 1 means the parent, and 2 means the grand-parent).
Returns:
Returns a new parent managed object path the specified number of path elements above this path.
Throws:
java.lang.IllegalArgumentException - If the offset is less than 0, or greater than the number of path elements in this path.

rename

public ManagedObjectPath<C,S> rename(java.lang.String newName)
                                                                                throws java.lang.IllegalStateException
Creates a new managed object path which has the same structure as this path except that the final path element is renamed. The final path element must comprise of an instantiable relation.

Parameters:
newName - The new name of the final path element.
Returns:
Returns a new managed object path which has the same structure as this path except that the final path element is renamed.
Throws:
java.lang.IllegalStateException - If this managed object path is empty or if its final path element does not comprise of an instantiable relation.

serialize

public void serialize(ManagedObjectPathSerializer serializer)
Serialize this managed object path using the provided serialization strategy.

The path elements will be passed to the serializer in big-endian order: starting from the root element and proceeding down to the leaf.

Parameters:
serializer - The managed object path serialization strategy.

size

public int size()
Get the number of path elements in this managed object path.

Returns:
Returns the number of path elements (0 - means no offset, 1 means the parent, and 2 means the grand-parent).

toDN

public DN toDN()
Creates a DN representation of this managed object path.

Returns:
Returns a DN representation of this managed object path.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

toString

public void toString(java.lang.StringBuilder builder)
Appends a string representation of this managed object path to the provided string builder.

Parameters:
builder - Append the string representation to this builder.
See Also:
toString()