Class 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: 602c2c31f547268ee4946cc688efe210547e64bc $
    See Also:
    Serialized Form
    • 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
      • BaseObjectReference

        public BaseObjectReference​(EntityReference 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
      • BaseObjectReference

        public BaseObjectReference​(EntityReference reference,
                                   EntityReference parent)
        Clone an BaseObjectReference, but use the specified parent for its new parent.
        Parameters:
        reference - the reference to clone
        parent - 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.