Package org.xwiki.annotation.reference
Class IndexedObjectReference
- java.lang.Object
-
- org.xwiki.model.reference.EntityReference
-
- org.xwiki.model.reference.ObjectReference
-
- org.xwiki.annotation.reference.IndexedObjectReference
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<EntityReference>
public class IndexedObjectReference extends ObjectReference
Object reference implementation for object names generated inclassName[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
getClassName()
and object index by callinggetObjectNumber()
. - className
- interpreted as the first object of class className. refers the object returned by XWikiDocument.getObject(String
className). In this case,
getObjectNumber()
will returnnull
andclassName
is obtained by callinggetClassName()
.
- Since:
- 2.3M1
- Version:
- $Id: 97aa558603c7018027279507cfa825b2728b1d52 $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
className
The class name of this object, as set by the caller.protected Integer
objectNumber
The number of this object, as set by the caller.-
Fields inherited from class org.xwiki.model.reference.EntityReference
TOSTRING_SERIALIZER
-
-
Constructor Summary
Constructors Constructor Description IndexedObjectReference(String className, Integer objectNumber, EntityReference parent)
Builds an indexed object reference for the object of classclassName
with indexobjectNumber
in the document referenced byparent
.IndexedObjectReference(EntityReference reference)
Constructor which would raise exceptions if the source entity reference does not have the appropriate type or parent, etc.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getClassName()
Integer
getObjectNumber()
protected void
setName(String name)
-
Methods inherited from class org.xwiki.model.reference.ObjectReference
getDocumentReference, replaceParent, replaceParent, setParent, setType
-
Methods inherited from class org.xwiki.model.reference.EntityReference
appendParent, compareTo, equals, equals, equals, equalsNonRecursive, extractFirstReference, extractReference, getName, getParameter, getParameters, getParent, getReversedReferenceChain, getRoot, getType, hashCode, hasParent, removeParent, setParameter, setParameters, size, toString
-
-
-
-
Constructor Detail
-
IndexedObjectReference
public IndexedObjectReference(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
-
IndexedObjectReference
public IndexedObjectReference(String className, Integer objectNumber, EntityReference parent)
Builds an indexed object reference for the object of classclassName
with indexobjectNumber
in the document referenced byparent
.- Parameters:
className
- the name of the class of the objectobjectNumber
- the number of the object in the document, ornull
if the default object should be referencedparent
- reference to the parent document where the object is
-
-
Method Detail
-
getClassName
public String getClassName()
- Returns:
- the name of the class of this object, as it was set by caller. I.e. no resolving is done from the value set in the name of the 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 classEntityReference
- See Also:
EntityReference.setName(java.lang.String)
-
-