org.jboss.dna.jcr
Class PropertyDefinitionId

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

@Immutable
public final class PropertyDefinitionId
extends Object
implements Serializable

An immutable identifier for a property definition. Although instances can be serialized, the property 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 :

"A node type may have two or more property definitions with identical name attributes (the value returned by ItemDefinition.getName) as long as the definitions are otherwise distinguishable by either the required type attribute (the value returned by PropertyDefinition.getRequiredType) or the multiple attribute (the value returned by PropertyDefinition.isMultiple)."

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
PropertyDefinitionId(Name nodeTypeName, Name propertyDefinitionName, int propertyType, boolean allowsMultiple)
          Create a new identifier for a property definition.
 
Method Summary
 boolean allowsAnyChildName()
          Determine whether this property definition allows properties with any name.
 boolean allowsMultiple()
          Return whether the property definition allows multiple values.
 PropertyDefinitionId asMultiValued()
           
 PropertyDefinitionId asSingleValued()
           
 boolean equals(Object obj)
          
static PropertyDefinitionId fromString(String definition, NameFactory factory)
          Parse the supplied string for of an identifer, and return the object form for that identifier.
 Name getNodeTypeName()
          Get the name of the node type on which the property definition is defined
 Name getPropertyDefinitionName()
          Get the name of the property definition.
 int getPropertyType()
          Get the required property type
 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

PropertyDefinitionId

public PropertyDefinitionId(Name nodeTypeName,
                            Name propertyDefinitionName,
                            int propertyType,
                            boolean allowsMultiple)
Create a new identifier for a property definition.

Parameters:
nodeTypeName - the name of the node type; may not be null
propertyDefinitionName - the name of the property definition, which may be a residual property; may not be null
propertyType - the required property type for the definition; must be a valid PropertyType value
allowsMultiple - true if the property definition should allow multiple values, or false if it is a single-value property definition
Method Detail

getNodeTypeName

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

Returns:
the node type's name; may not be null

getPropertyDefinitionName

public Name getPropertyDefinitionName()
Get the name of the property definition.

Returns:
the property definition's name; never null

getPropertyType

public int getPropertyType()
Get the required property type

Returns:
the property type; always a valid PropertyType value

allowsMultiple

public boolean allowsMultiple()
Return whether the property definition allows multiple values.

Returns:
true if the property definition allows multiple values, or false if it is a single-value property definition

allowsAnyChildName

public boolean allowsAnyChildName()
Determine whether this property definition allows properties with any name.

Returns:
true if this node definition allows properties with any name, or false if this definition requires a particular property 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 PropertyDefinitionId 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

asSingleValued

public PropertyDefinitionId asSingleValued()

asMultiValued

public PropertyDefinitionId asMultiValued()

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.