Package com.xpn.xwiki.objects
Class BaseObjectReference
- java.lang.Object
-
- org.xwiki.model.reference.EntityReference
-
- org.xwiki.model.reference.ObjectReference
-
- com.xpn.xwiki.objects.BaseObjectReference
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<EntityReference>
public class BaseObjectReference 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
getXClassReference()
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 callinggetXClassReference()
.
- Version:
- $Id: 602c2c31f547268ee4946cc688efe210547e64bc $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description 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
Constructors Constructor Description BaseObjectReference(DocumentReference classReference, Integer objectNumber, DocumentReference parent)
Builds an indexed object reference for the object of classclassName
with indexobjectNumber
in the document referenced byparent
.BaseObjectReference(EntityReference reference)
Constructor which would raise exceptions if the source entity reference does not have the appropriate type or parent, etc.BaseObjectReference(EntityReference classReference, Integer objectNumber, DocumentReference parent)
Builds an indexed object reference for the object of classclassName
with indexobjectNumber
in the document referenced byparent
.BaseObjectReference(EntityReference reference, EntityReference parent)
Clone an BaseObjectReference, but use the specified parent for its new parent.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RegexEntityReference
any(String classReference)
static RegexEntityReference
any(String classReference, EntityReference parent)
static List<com.xpn.xwiki.internal.event.XObjectEvent>
anyEvents(String classReference)
Integer
getObjectNumber()
DocumentReference
getXClassReference()
BaseObjectReference
replaceParent(EntityReference newParent)
-
Methods inherited from class org.xwiki.model.reference.ObjectReference
getDocumentReference, 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, setName, setParameter, setParameters, size, toString
-
-
-
-
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 classclassName
with indexobjectNumber
in the document referenced byparent
.- Parameters:
classReference
- 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
-
BaseObjectReference
public BaseObjectReference(EntityReference classReference, Integer objectNumber, DocumentReference parent)
Builds an indexed object reference for the object of classclassName
with indexobjectNumber
in the document referenced byparent
.- Parameters:
classReference
- 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
-
BaseObjectReference
public BaseObjectReference(EntityReference reference, EntityReference parent)
Clone an BaseObjectReference, but use the specified parent for its new parent.- Parameters:
reference
- the reference to cloneparent
- the new parent to use- Since:
- 10.8RC1
-
-
Method Detail
-
any
public static RegexEntityReference any(String classReference)
- Parameters:
classReference
- the local reference of the class (e.g. "XWiki.XWikiPreferences")- Returns:
- a reference used to match on object reference with the passed xclass
- Since:
- 9.4RC1
-
any
public static RegexEntityReference any(String classReference, EntityReference parent)
- Parameters:
classReference
- the local reference of the class (e.g. "XWiki.XWikiPreferences")parent
- the parent of the object reference- Returns:
- a reference used to match on object reference with the passed xclass
- Since:
- 9.4RC1
-
anyEvents
public static List<com.xpn.xwiki.internal.event.XObjectEvent> anyEvents(String classReference)
- Parameters:
classReference
- the local reference of the class (e.g. "XWiki.XWikiPreferences")- Returns:
- all
XObjectEvent
to listen to be notified or any modification on a xobject - Since:
- 11.8RC1
-
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.
-
replaceParent
public BaseObjectReference replaceParent(EntityReference newParent)
- Overrides:
replaceParent
in classObjectReference
-
-