org.apache.jackrabbit.name
Class QName

java.lang.Object
  extended byorg.apache.jackrabbit.name.QName
All Implemented Interfaces:
Cloneable, Comparable, Serializable

public final class QName
extends Object
implements Cloneable, Comparable, Serializable

Qualified name. A qualified name is a combination of a namespace URI and a local part. Instances of this class are used to internally represent the names of JCR content items and other objects within a content repository.

A qualified name is immutable once created, although the prefixed JCR name representation of the qualified name can change depending on the namespace mappings in effect.

This class also contains a number of common namespace and qualified name constants for the namespaces and names specified by the JCR specification.

String representations

The prefixed JCR name format of a qualified name is specified by section 4.6 of the the JCR 1.0 specification (JSR 170) as follows:

 name                ::= simplename | prefixedname
 simplename          ::= onecharsimplename |
                         twocharsimplename |
                         threeormorecharname
 prefixedname        ::= prefix ':' localname
 localname           ::= onecharlocalname |
                         twocharlocalname |
                         threeormorecharname
 onecharsimplename   ::= (* Any Unicode character except:
                            '.', '/', ':', '[', ']', '*',
                            ''', '"', '|' or any whitespace
                            character *)
 twocharsimplename   ::= '.' onecharsimplename |
                         onecharsimplename '.' |
                         onecharsimplename onecharsimplename
 onecharlocalname    ::= nonspace
 twocharlocalname    ::= nonspace nonspace
 threeormorecharname ::= nonspace string nonspace
 prefix              ::= (* Any valid XML Name *)
 string              ::= char | string char
 char                ::= nonspace | ' '
 nonspace            ::= (* Any Unicode character except:
                            '/', ':', '[', ']', '*',
                            ''', '"', '|' or any whitespace
                            character *)
 

In addition to the prefixed JCR name format, a qualified name can also be represented using the format "{namespaceURI}localPart".

See Also:
Serialized Form

Field Summary
static QName[] EMPTY_ARRAY
           
static QName JCR_AUTOCREATED
          jcr:autoCreated
static QName JCR_BASEVERSION
          jcr:baseVersion
static QName JCR_CHILDNODEDEFINITION
          jcr:childNodeDefinition
static QName JCR_CHILDVERSIONHISTORY
          jcr:childVersionHistory
static QName JCR_CONTENT
          jcr:content
static QName JCR_CREATED
          jcr:created
static QName JCR_DATA
          jcr:data
static QName JCR_DEFAULTPRIMARYTYPE
          jcr:defaultPrimaryType
static QName JCR_DEFAULTVALUES
          jcr:defaultValues
static QName JCR_ENCODING
          jcr:encoding
static QName JCR_FROZENMIXINTYPES
          jcr:frozenMixinTypes
static QName JCR_FROZENNODE
          jcr:frozenNode
static QName JCR_FROZENPRIMARYTYPE
          jcr:frozenPrimaryType
static QName JCR_FROZENUUID
          jcr:frozenUuid
static QName JCR_HASORDERABLECHILDNODES
          jcr:hasOrderableChildNodes
static QName JCR_ISCHECKEDOUT
          jcr:isCheckedOut
static QName JCR_ISMIXIN
          jcr:isMixin
static QName JCR_LANGUAGE
          jcr:language
static QName JCR_LASTMODIFIED
          jcr:lastModified
static QName JCR_LOCKISDEEP
          jcr:lockIsDeep
static QName JCR_LOCKOWNER
          jcr:lockOwner
static QName JCR_MANDATORY
          jcr:mandatory
static QName JCR_MERGEFAILED
          jcr:mergeFailed
static QName JCR_MIMETYPE
          jcr:mimeType
static QName JCR_MIXINTYPES
          jcr:mixinTypes
static QName JCR_MULTIPLE
          jcr:multiple
static QName JCR_NAME
          jcr:name
static QName JCR_NODETYPENAME
          jcr:nodeTypeName
static QName JCR_NODETYPES
          jcr:nodeTypes
static QName JCR_ONPARENTVERSION
          jcr:onParentVersion
static QName JCR_PATH
          jcr:path
static QName JCR_PREDECESSORS
          jcr:predecessors
static QName JCR_PRIMARYITEMNAME
          jcr:primaryItemName
static QName JCR_PRIMARYTYPE
          jcr:primaryType
static QName JCR_PROPERTYDEFINITION
          jcr:propertyDefinition
static QName JCR_PROTECTED
          jcr:protected
static QName JCR_REQUIREDPRIMARYTYPES
          jcr:requiredPrimaryTypes
static QName JCR_REQUIREDTYPE
          jcr:requiredType
static QName JCR_ROOT
          jcr:root (dummy name for root node used in XML serialization)
static QName JCR_ROOTVERSION
          jcr:rootVersion
static QName JCR_SAMENAMESIBLINGS
          jcr:sameNameSiblings
static QName JCR_SCORE
          jcr:score
static QName JCR_STATEMENT
          jcr:statement
static QName JCR_SUCCESSORS
          jcr:successors
static QName JCR_SUPERTYPES
          jcr:supertypes
static QName JCR_SYSTEM
          jcr:system
static QName JCR_UUID
          jcr:uuid
static QName JCR_VALUECONSTRAINTS
          jcr:valueConstraints
static QName JCR_VERSIONABLEUUID
          jcr:versionableUuid
static QName JCR_VERSIONHISTORY
          jcr:versionHistory
static QName JCR_VERSIONLABELS
          jcr:versionLabels
static QName JCR_VERSIONSTORAGE
          jcr:versionStorage
static QName JCR_XMLCHARACTERS
          jcr:xmlcharacters
static QName JCR_XMLTEXT
          jcr:xmltext
static QName MIX_LOCKABLE
          mix:referenceable
static QName MIX_REFERENCEABLE
          mix:referenceable
static QName MIX_VERSIONABLE
          mix:versionable
static String NS_DEFAULT_URI
           
static String NS_EMPTY_PREFIX
           
static String NS_JCR_PREFIX
           
static String NS_JCR_URI
           
static String NS_MIX_PREFIX
           
static String NS_MIX_URI
           
static String NS_NT_PREFIX
           
static String NS_NT_URI
           
static String NS_REP_PREFIX
           
static String NS_REP_URI
           
static String NS_SV_PREFIX
           
static String NS_SV_URI
           
static String NS_XML_PREFIX
           
static String NS_XML_URI
           
static String NS_XMLNS_PREFIX
           
static String NS_XMLNS_URI
           
static QName NT_BASE
          nt:base
static QName NT_CHILDNODEDEFINITION
          nt:childNodeDefinition
static QName NT_FILE
          nt:file
static QName NT_FOLDER
          nt:folder
static QName NT_FROZENNODE
          nt:frozenNode
static QName NT_HIERARCHYNODE
          nt:hierarchyNode
static QName NT_NODETYPE
          nt:nodeType
static QName NT_PROPERTYDEFINITION
          nt:propertyDefinition
static QName NT_QUERY
          nt:query
static QName NT_RESOURCE
          nt:resource
static QName NT_UNSTRUCTURED
          nt:unstructured
static QName NT_VERSION
          nt:version
static QName NT_VERSIONEDCHILD
          nt:versionedChild
static QName NT_VERSIONHISTORY
          nt:versionHistory
static QName NT_VERSIONLABELS
          nt:versionLabels
static QName REP_NODETYPES
          rep:versionStorage
static QName REP_ROOT
          rep:root
static QName REP_SYSTEM
          rep:system
static QName REP_VERSIONSTORAGE
          rep:versionStorage
 
Constructor Summary
QName(String namespaceURI, String localName)
          Creates a new qualified name with the given namespace URI and local part.
 
Method Summary
static void checkFormat(String jcrName)
          Checks if jcrName is a valid JCR-style name.
 Object clone()
          Creates a clone of this qualified name.
 int compareTo(Object o)
          Compares two qualified names.
 boolean equals(Object obj)
          Compares two qualified names for equality.
static QName fromJCRName(String rawName, NamespaceResolver resolver)
          Parses the given prefixed JCR name into a qualified name using the given namespace resolver.
 String getLocalName()
          Returns the local part of the qualified name.
 String getNamespaceURI()
          Returns the namespace URI of the qualified name.
 int hashCode()
          Returns the hash code of this qualified name.
static String[] parse(String jcrName)
          Parses the jcrName and returns an array of two strings: the first array element contains the prefix (or empty string), the second the local name.
 String toJCRName(NamespaceResolver resolver)
          Returns the qualified name in the prefixed JCR name format.
 void toJCRName(NamespaceResolver resolver, StringBuffer buf)
          Appends the qualified name in the prefixed JCR name format to the given string buffer.
 String toString()
          Returns the string representation of this QName in the following format:

{namespaceURI}localName

static QName valueOf(String s)
          Returns a QName holding the value of the specified string.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NS_EMPTY_PREFIX

public static final String NS_EMPTY_PREFIX
See Also:
Constant Field Values

NS_DEFAULT_URI

public static final String NS_DEFAULT_URI
See Also:
Constant Field Values

NS_REP_PREFIX

public static final String NS_REP_PREFIX
See Also:
Constant Field Values

NS_REP_URI

public static final String NS_REP_URI
See Also:
Constant Field Values

NS_JCR_PREFIX

public static final String NS_JCR_PREFIX
See Also:
Constant Field Values

NS_JCR_URI

public static final String NS_JCR_URI
See Also:
Constant Field Values

NS_NT_PREFIX

public static final String NS_NT_PREFIX
See Also:
Constant Field Values

NS_NT_URI

public static final String NS_NT_URI
See Also:
Constant Field Values

NS_MIX_PREFIX

public static final String NS_MIX_PREFIX
See Also:
Constant Field Values

NS_MIX_URI

public static final String NS_MIX_URI
See Also:
Constant Field Values

NS_SV_PREFIX

public static final String NS_SV_PREFIX
See Also:
Constant Field Values

NS_SV_URI

public static final String NS_SV_URI
See Also:
Constant Field Values

NS_XML_PREFIX

public static final String NS_XML_PREFIX
See Also:
Constant Field Values

NS_XML_URI

public static final String NS_XML_URI
See Also:
Constant Field Values

NS_XMLNS_PREFIX

public static final String NS_XMLNS_PREFIX
See Also:
Constant Field Values

NS_XMLNS_URI

public static final String NS_XMLNS_URI
See Also:
Constant Field Values

JCR_SYSTEM

public static final QName JCR_SYSTEM
jcr:system


JCR_NODETYPES

public static final QName JCR_NODETYPES
jcr:nodeTypes


JCR_UUID

public static final QName JCR_UUID
jcr:uuid


JCR_PRIMARYTYPE

public static final QName JCR_PRIMARYTYPE
jcr:primaryType


JCR_MIXINTYPES

public static final QName JCR_MIXINTYPES
jcr:mixinTypes


JCR_CREATED

public static final QName JCR_CREATED
jcr:created


JCR_LASTMODIFIED

public static final QName JCR_LASTMODIFIED
jcr:lastModified


JCR_ENCODING

public static final QName JCR_ENCODING
jcr:encoding


JCR_MIMETYPE

public static final QName JCR_MIMETYPE
jcr:mimeType


JCR_DATA

public static final QName JCR_DATA
jcr:data


JCR_CONTENT

public static final QName JCR_CONTENT
jcr:content


JCR_ROOT

public static final QName JCR_ROOT
jcr:root (dummy name for root node used in XML serialization)


JCR_XMLTEXT

public static final QName JCR_XMLTEXT
jcr:xmltext


JCR_XMLCHARACTERS

public static final QName JCR_XMLCHARACTERS
jcr:xmlcharacters


JCR_SCORE

public static final QName JCR_SCORE
jcr:score


JCR_PATH

public static final QName JCR_PATH
jcr:path


JCR_STATEMENT

public static final QName JCR_STATEMENT
jcr:statement


JCR_LANGUAGE

public static final QName JCR_LANGUAGE
jcr:language


JCR_LOCKOWNER

public static final QName JCR_LOCKOWNER
jcr:lockOwner


JCR_LOCKISDEEP

public static final QName JCR_LOCKISDEEP
jcr:lockIsDeep


JCR_VERSIONSTORAGE

public static final QName JCR_VERSIONSTORAGE
jcr:versionStorage


JCR_MERGEFAILED

public static final QName JCR_MERGEFAILED
jcr:mergeFailed


JCR_FROZENNODE

public static final QName JCR_FROZENNODE
jcr:frozenNode


JCR_FROZENUUID

public static final QName JCR_FROZENUUID
jcr:frozenUuid


JCR_FROZENPRIMARYTYPE

public static final QName JCR_FROZENPRIMARYTYPE
jcr:frozenPrimaryType


JCR_FROZENMIXINTYPES

public static final QName JCR_FROZENMIXINTYPES
jcr:frozenMixinTypes


JCR_PREDECESSORS

public static final QName JCR_PREDECESSORS
jcr:predecessors


JCR_VERSIONLABELS

public static final QName JCR_VERSIONLABELS
jcr:versionLabels


JCR_SUCCESSORS

public static final QName JCR_SUCCESSORS
jcr:successors


JCR_ISCHECKEDOUT

public static final QName JCR_ISCHECKEDOUT
jcr:isCheckedOut


JCR_VERSIONHISTORY

public static final QName JCR_VERSIONHISTORY
jcr:versionHistory


JCR_BASEVERSION

public static final QName JCR_BASEVERSION
jcr:baseVersion


JCR_CHILDVERSIONHISTORY

public static final QName JCR_CHILDVERSIONHISTORY
jcr:childVersionHistory


JCR_ROOTVERSION

public static final QName JCR_ROOTVERSION
jcr:rootVersion


JCR_VERSIONABLEUUID

public static final QName JCR_VERSIONABLEUUID
jcr:versionableUuid


JCR_NODETYPENAME

public static final QName JCR_NODETYPENAME
jcr:nodeTypeName


JCR_HASORDERABLECHILDNODES

public static final QName JCR_HASORDERABLECHILDNODES
jcr:hasOrderableChildNodes


JCR_ISMIXIN

public static final QName JCR_ISMIXIN
jcr:isMixin


JCR_SUPERTYPES

public static final QName JCR_SUPERTYPES
jcr:supertypes


JCR_PROPERTYDEFINITION

public static final QName JCR_PROPERTYDEFINITION
jcr:propertyDefinition


JCR_NAME

public static final QName JCR_NAME
jcr:name


JCR_MANDATORY

public static final QName JCR_MANDATORY
jcr:mandatory


JCR_PROTECTED

public static final QName JCR_PROTECTED
jcr:protected


JCR_REQUIREDTYPE

public static final QName JCR_REQUIREDTYPE
jcr:requiredType


JCR_ONPARENTVERSION

public static final QName JCR_ONPARENTVERSION
jcr:onParentVersion


JCR_PRIMARYITEMNAME

public static final QName JCR_PRIMARYITEMNAME
jcr:primaryItemName


JCR_MULTIPLE

public static final QName JCR_MULTIPLE
jcr:multiple


JCR_VALUECONSTRAINTS

public static final QName JCR_VALUECONSTRAINTS
jcr:valueConstraints


JCR_DEFAULTVALUES

public static final QName JCR_DEFAULTVALUES
jcr:defaultValues


JCR_AUTOCREATED

public static final QName JCR_AUTOCREATED
jcr:autoCreated


JCR_CHILDNODEDEFINITION

public static final QName JCR_CHILDNODEDEFINITION
jcr:childNodeDefinition


JCR_SAMENAMESIBLINGS

public static final QName JCR_SAMENAMESIBLINGS
jcr:sameNameSiblings


JCR_DEFAULTPRIMARYTYPE

public static final QName JCR_DEFAULTPRIMARYTYPE
jcr:defaultPrimaryType


JCR_REQUIREDPRIMARYTYPES

public static final QName JCR_REQUIREDPRIMARYTYPES
jcr:requiredPrimaryTypes


REP_ROOT

public static final QName REP_ROOT
rep:root


REP_SYSTEM

public static final QName REP_SYSTEM
rep:system


REP_VERSIONSTORAGE

public static final QName REP_VERSIONSTORAGE
rep:versionStorage


REP_NODETYPES

public static final QName REP_NODETYPES
rep:versionStorage


NT_UNSTRUCTURED

public static final QName NT_UNSTRUCTURED
nt:unstructured


NT_BASE

public static final QName NT_BASE
nt:base


NT_HIERARCHYNODE

public static final QName NT_HIERARCHYNODE
nt:hierarchyNode


NT_RESOURCE

public static final QName NT_RESOURCE
nt:resource


NT_FILE

public static final QName NT_FILE
nt:file


NT_FOLDER

public static final QName NT_FOLDER
nt:folder


NT_QUERY

public static final QName NT_QUERY
nt:query


MIX_REFERENCEABLE

public static final QName MIX_REFERENCEABLE
mix:referenceable


MIX_LOCKABLE

public static final QName MIX_LOCKABLE
mix:referenceable


MIX_VERSIONABLE

public static final QName MIX_VERSIONABLE
mix:versionable


NT_VERSIONHISTORY

public static final QName NT_VERSIONHISTORY
nt:versionHistory


NT_VERSION

public static final QName NT_VERSION
nt:version


NT_VERSIONLABELS

public static final QName NT_VERSIONLABELS
nt:versionLabels


NT_VERSIONEDCHILD

public static final QName NT_VERSIONEDCHILD
nt:versionedChild


NT_FROZENNODE

public static final QName NT_FROZENNODE
nt:frozenNode


NT_NODETYPE

public static final QName NT_NODETYPE
nt:nodeType


NT_PROPERTYDEFINITION

public static final QName NT_PROPERTYDEFINITION
nt:propertyDefinition


NT_CHILDNODEDEFINITION

public static final QName NT_CHILDNODEDEFINITION
nt:childNodeDefinition


EMPTY_ARRAY

public static final QName[] EMPTY_ARRAY
Constructor Detail

QName

public QName(String namespaceURI,
             String localName)
Creates a new qualified name with the given namespace URI and local part.

Note that the format of the local part is not validated. The format can be checked by calling checkFormat(String).

Parameters:
namespaceURI - namespace uri
localName - local part
Method Detail

fromJCRName

public static QName fromJCRName(String rawName,
                                NamespaceResolver resolver)
                         throws IllegalNameException,
                                UnknownPrefixException
Parses the given prefixed JCR name into a qualified name using the given namespace resolver.

Parameters:
rawName - prefixed JCR name
resolver - namespace resolver
Returns:
qualified name
Throws:
IllegalNameException - if the given name is not a valid JCR name
UnknownPrefixException - if the JCR name prefix does not resolve

valueOf

public static QName valueOf(String s)
                     throws IllegalArgumentException
Returns a QName holding the value of the specified string. The string must be in the format returned by the QName.toString() method, i.e.

{namespaceURI}localName

Parameters:
s - a String containing the QName representation to be parsed.
Returns:
the QName represented by the argument
Throws:
IllegalArgumentException - if the specified string can not be parsed as a QName.
See Also:
toString()

checkFormat

public static void checkFormat(String jcrName)
                        throws IllegalNameException
Checks if jcrName is a valid JCR-style name.

Parameters:
jcrName - the name to be checked
Throws:
IllegalNameException - If jcrName is not a valid JCR-style name.

parse

public static String[] parse(String jcrName)
                      throws IllegalNameException
Parses the jcrName and returns an array of two strings: the first array element contains the prefix (or empty string), the second the local name.

Parameters:
jcrName - the name to be parsed
Returns:
An array holding two strings: the first array element contains the prefix (or empty string), the second the local name.
Throws:
IllegalNameException - If jcrName is not a valid JCR-style name.

getLocalName

public String getLocalName()
Returns the local part of the qualified name.

Returns:
local name

getNamespaceURI

public String getNamespaceURI()
Returns the namespace URI of the qualified name.

Returns:
namespace URI

toJCRName

public String toJCRName(NamespaceResolver resolver)
                 throws NoPrefixDeclaredException
Returns the qualified name in the prefixed JCR name format. The namespace URI is mapped to a prefix using the given namespace resolver.

Parameters:
resolver - namespace resolver
Returns:
prefixed name
Throws:
NoPrefixDeclaredException - if the namespace can not be resolved

toJCRName

public void toJCRName(NamespaceResolver resolver,
                      StringBuffer buf)
               throws NoPrefixDeclaredException
Appends the qualified name in the prefixed JCR name format to the given string buffer. The namespace URI is mapped to a prefix using the given namespace resolver.

Parameters:
resolver - namespace resolver
buf - string buffer where the prefixed JCR name should be appended to
Throws:
NoPrefixDeclaredException - if the namespace can not be resolved
See Also:
toJCRName(NamespaceResolver)

toString

public String toString()
Returns the string representation of this QName in the following format:

{namespaceURI}localName

Returns:
the string representation of this QName.
See Also:
valueOf(String)

equals

public boolean equals(Object obj)
Compares two qualified names for equality. Returns true if the given object is a qualified name and has the same namespace URI and local part as this qualified name.

Parameters:
obj - the object to compare this qualified name with
Returns:
true if the object is equal to this qualified name, false otherwise
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Returns the hash code of this qualified name. The hash code is computed from the namespace URI and local part of the qualified name and memorized for better performance.

Returns:
hash code
See Also:
Object.hashCode()

clone

public Object clone()
             throws CloneNotSupportedException
Creates a clone of this qualified name. Overriden in order to make clone() public.

Returns:
a clone of this instance
Throws:
CloneNotSupportedException - never thrown
See Also:
Object.clone()

compareTo

public int compareTo(Object o)
              throws ClassCastException
Compares two qualified names.

Specified by:
compareTo in interface Comparable
Parameters:
o - the object to compare this qualified name with
Returns:
comparison result
Throws:
ClassCastException - if the given object is not a qualified name
See Also:
Comparable.compareTo(Object)


Copyright © 2004-2006 The Apache Software Foundation. All Rights Reserved.