org.jboss.dna.jcr
Class NodeDefinitionId

java.lang.Object
  extended by org.jboss.dna.jcr.NodeDefinitionId
All Implemented Interfaces:
Serializable

@Immutable
public final class NodeDefinitionId
extends Object
implements Serializable

An immutable identifier for a node definition. Although instances can be serialized, the node definitions are often stored within the graph as string values on a property. These string values can later be parsed to reconstruct the identifier. Note that this string representation does not use namespace prefixes, so they are long-lasting and durable.

What distinguishes one property definition from another is not well documented in the JSR-170 specification. The closest this version of the spec gets is Section 6.7.15, but that merely says that more than one property definition can have the same name. The proposed draft of the JSR-283 specification does clarify this more: Section 4.7.15 says :

"Similarly, a node type may have two or more child node definitions with identical name attributes as long as they are distinguishable by the required primary types attribute (the value returned by NodeDefinition.getRequiredPrimaryTypes)."

This class is Serializable and designed to be used as a key in a HashMap.

See Also:
Serialized Form

Field Summary
static String ANY_NAME
          The string-form of the name that can be used to represent a residual property definition.
 
Constructor Summary
NodeDefinitionId(Name nodeTypeName, Name childDefinitionName, Name[] requiredPrimaryTypes)
          Create an identifier for a node definition.
 
Method Summary
 boolean allowsAnyChildName()
          Determine whether this node definition defines any named child.
 boolean equals(Object obj)
          
static NodeDefinitionId fromString(String definition, NameFactory factory)
          Parse the supplied string for of an identifer, and return the object form for that identifier.
 Name getChildDefinitionName()
          Get the name of the child definition.
 Name getNodeTypeName()
          Get the name of the node type on which the child node definition is defined.
 Name[] getRequiredPrimaryTypes()
           
 String getString()
          Get the string form of this identifier.
 int hashCode()
          
 String toString()
          
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ANY_NAME

public static final String ANY_NAME
The string-form of the name that can be used to represent a residual property definition.

See Also:
Constant Field Values
Constructor Detail

NodeDefinitionId

public NodeDefinitionId(Name nodeTypeName,
                        Name childDefinitionName,
                        Name[] requiredPrimaryTypes)
Create an identifier for a node definition.

Parameters:
nodeTypeName - the name of the node type on which this child node definition is defined; may not be null
childDefinitionName - the name of the child node definition, which may be a residual child definition; may not be null
requiredPrimaryTypes - the names of the required primary types for the child node definition
Method Detail

getNodeTypeName

public Name getNodeTypeName()
Get the name of the node type on which the child node definition is defined.

Returns:
the node type's name; never null

getChildDefinitionName

public Name getChildDefinitionName()
Get the name of the child definition.

Returns:
the child definition's name; never null

getRequiredPrimaryTypes

public Name[] getRequiredPrimaryTypes()
Returns:
requiredPrimaryTypes

allowsAnyChildName

public boolean allowsAnyChildName()
Determine whether this node definition defines any named child.

Returns:
true if this node definition allows children with any name, or false if this definition requires a particular child name

getString

public String getString()
Get the string form of this identifier. This form can be persisted, since it does not rely upon namespace prefixes.

Returns:
the string form

fromString

public static NodeDefinitionId fromString(String definition,
                                          NameFactory factory)
Parse the supplied string for of an identifer, and return the object form for that identifier.

Parameters:
definition - the string form of the identifier; may not be null
factory - the factory that should be used to create Name objects; may not be null
Returns:
the object form of the identifier; never null
Throws:
ValueFormatException - if the definition is not the valid format

hashCode

public int hashCode()

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

equals

public boolean equals(Object obj)

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

toString

public String toString()

Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2008-2009 JBoss, a division of Red Hat. All Rights Reserved.