com.xpn.xwiki.objects
Class BaseObjectReference

java.lang.Object
  extended by org.xwiki.model.reference.EntityReference
      extended by org.xwiki.model.reference.ObjectReference
          extended by com.xpn.xwiki.objects.BaseObjectReference
All Implemented Interfaces:
Serializable, Cloneable, Comparable<EntityReference>

public class BaseObjectReference
extends ObjectReference

Object reference implementation for object names generated in className[objectNumber] format. It provides helper functions to extract the class name as specified by the caller, and object number.
Accepted formats for the object name are:

className[objectNumber]
interpreted as the object of class className with number objectNumber. refers the object returned by XWikiDocument.getObject(String className, int objectNumber). In this case, className is obtained by calling getXClassReference() and object index by calling getObjectNumber().
className
interpreted as the first object of class className. refers the object returned by XWikiDocument.getObject(String className). In this case, getObjectNumber() will return null and className is obtained by calling getXClassReference().

Version:
$Id: b73a71dce354b4c4484e51ef61bae536d5d97d34 $
See Also:
Serialized Form

Field Summary
protected  Integer objectNumber
          The number of this object.
protected  DocumentReference xclassReference
          The class reference of this object.
 
Fields inherited from class org.xwiki.model.reference.EntityReference
TOSTRING_SERIALIZER
 
Constructor Summary
BaseObjectReference(DocumentReference classReference, Integer objectNumber, DocumentReference parent)
          Builds an indexed object reference for the object of class className with index objectNumber in the document referenced by parent.
BaseObjectReference(EntityReference reference)
          Constructor which would raise exceptions if the source entity reference does not have the appropriate type or parent, etc.
 
Method Summary
 Integer getObjectNumber()
           
 DocumentReference getXClassReference()
           
protected  void setName(String name)
          
Overridden to always compute the class name and the object number.
 
Methods inherited from class org.xwiki.model.reference.ObjectReference
replaceParent, setParent, setType
 
Methods inherited from class org.xwiki.model.reference.EntityReference
appendParent, compareTo, equals, extractReference, getName, getParameter, getParent, getReversedReferenceChain, getRoot, getType, hashCode, removeParent, setParameter, setParameters, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

xclassReference

protected DocumentReference xclassReference
The class reference of this object.


objectNumber

protected Integer objectNumber
The number of this object.

Constructor Detail

BaseObjectReference

public BaseObjectReference(EntityReference reference)
Constructor which would raise exceptions if the source entity reference does not have the appropriate type or parent, etc.

Parameters:
reference - the raw reference to build this object reference from

BaseObjectReference

public BaseObjectReference(DocumentReference classReference,
                           Integer objectNumber,
                           DocumentReference parent)
Builds an indexed object reference for the object of class className with index objectNumber in the document referenced by parent.

Parameters:
classReference - the name of the class of the object
objectNumber - the number of the object in the document, or null if the default object should be referenced
parent - reference to the parent document where the object is
Method Detail

getXClassReference

public DocumentReference getXClassReference()
Returns:
the reference of the class of this object.

getObjectNumber

public Integer getObjectNumber()
Returns:
the number of this object among the objects of the same class in the document, as set by the caller in [objectNumber] format after the class name (i.e. no resolving is done, existence of this object is not guaranteed). If no number can be parsed (i.e. [number] cannot be parsed) this function returns null and object should be interpreted as the first object of this class in the document.

setName

protected void setName(String name)

Overridden to always compute the class name and the object number.

Overrides:
setName in class EntityReference
See Also:
EntityReference.setName(java.lang.String)


Copyright © 2004-2013 XWiki. All Rights Reserved.