Package org.xwiki.model.reference
Class DocumentReference
- java.lang.Object
-
- org.xwiki.model.reference.EntityReference
-
- org.xwiki.model.reference.AbstractLocalizedEntityReference
-
- org.xwiki.model.reference.DocumentReference
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<EntityReference>
- Direct Known Subclasses:
DocumentVersionReference
public class DocumentReference extends AbstractLocalizedEntityReference
Represents a reference to a document (wiki, space and document names).- Since:
- 2.2M1
- Version:
- $Id: 4b88e82528642a24ca06de1fa6e1c9aef0ebe6a7 $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Type
TYPE_PROVIDER
TheType
for aProvider<DocumentReference>
.-
Fields inherited from class org.xwiki.model.reference.EntityReference
TOSTRING_SERIALIZER
-
-
Constructor Summary
Constructors Modifier Constructor Description DocumentReference(String wikiName, String spaceName, String pageName)
Create a new Document reference from wiki, space and page name.DocumentReference(String wikiName, String spaceName, String pageName, String language)
Create a new Document reference from wiki name, space name, page name and language.DocumentReference(String wikiName, String spaceName, String pageName, Locale locale)
Create a new Document reference from wiki name, space name, page name and locale.DocumentReference(String wikiName, List<String> spaceNames, String pageName)
Create a new Document reference from wiki name, spaces names and page name.DocumentReference(String wikiName, List<String> spaceNames, String pageName, Locale locale)
Create a new Document reference from wiki name, spaces names, page name and locale.DocumentReference(String pageName, EntityReference parent, Map<String,Serializable> parameters)
DocumentReference(String pageName, SpaceReference parent)
Create a new Document reference from document name and parent space.DocumentReference(String pageName, SpaceReference parent, Locale locale)
Create a new Document reference from document name, parent space and locale.DocumentReference(EntityReference reference)
Special constructor that transforms a generic entity reference into aDocumentReference
.DocumentReference(EntityReference reference, Locale locale)
Clone the provided reference and change the Locale.DocumentReference(EntityReference reference, EntityReference parent)
Clone an DocumentReference, but use the specified parent for its new parent.protected
DocumentReference(EntityReference reference, EntityReference oldReference, EntityReference newReference)
Clone an DocumentReference, but replace one of the parent in the chain by a new one.DocumentReference(LocalDocumentReference localDocumentReference, WikiReference wikiReference)
Create a new Document reference from local document reference and wiki reference.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SpaceReference
getLastSpaceReference()
LocalDocumentReference
getLocalDocumentReference()
LocalDocumentReference
getLocaleDocumentReference()
Deprecated.since 9.3RC1/8.4.5, usegetLocalDocumentReference()
insteadList<SpaceReference>
getSpaceReferences()
WikiReference
getWikiReference()
DocumentReference
replaceParent(EntityReference newParent)
Return a clone of this reference, but with its parent replaced by the passed one.DocumentReference
replaceParent(EntityReference oldParent, EntityReference newParent)
Return a clone of this reference, but with one of its parent replaced by another one.protected void
setParent(EntityReference parent)
Entity reference are immutable since 3.3M2, so this method is now protected.protected void
setType(EntityType type)
Entity reference are immutable since 3.3M2, so this method is now protected.DocumentReference
setWikiReference(WikiReference wikiReference)
Create a new DocumentReference with passed wiki reference.String
toString()
DocumentReference
withoutLocale()
-
Methods inherited from class org.xwiki.model.reference.AbstractLocalizedEntityReference
getLocale, setLocale, setParameter
-
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, setParameters, size
-
-
-
-
Constructor Detail
-
DocumentReference
public DocumentReference(EntityReference reference)
Special constructor that transforms a generic entity reference into aDocumentReference
. It checks the validity of the passed reference (ie correct type and correct parent).- Parameters:
reference
- the reference to convert- Throws:
IllegalArgumentException
- if the passed reference is not a valid document reference
-
DocumentReference
protected DocumentReference(EntityReference reference, EntityReference oldReference, EntityReference newReference)
Clone an DocumentReference, but replace one of the parent in the chain by a new one.- Parameters:
reference
- the reference that is clonedoldReference
- the old parent that will be replacednewReference
- the new parent that will replace oldReference in the chain- Since:
- 3.3M2
-
DocumentReference
public DocumentReference(EntityReference reference, Locale locale)
Clone the provided reference and change the Locale.- Parameters:
reference
- the reference to clonelocale
- the new locale for this reference, if null, locale is removed- Throws:
IllegalArgumentException
- if the passed reference is not a valid document reference
-
DocumentReference
public DocumentReference(String wikiName, String spaceName, String pageName)
Create a new Document reference from wiki, space and page name.- Parameters:
wikiName
- the name of the wiki containing the document, must not be nullspaceName
- the name of the space containing the document, must not be nullpageName
- the name of the document
-
DocumentReference
public DocumentReference(String wikiName, String spaceName, String pageName, Locale locale)
Create a new Document reference from wiki name, space name, page name and locale.- Parameters:
wikiName
- the name of the wiki containing the document, must not be nullspaceName
- the name of the space containing the document, must not be nullpageName
- the name of the documentlocale
- the locale of the document reference, may be null
-
DocumentReference
public DocumentReference(String wikiName, String spaceName, String pageName, String language)
Create a new Document reference from wiki name, space name, page name and language. This is an helper function during transition from language to locale, it will be deprecated ASAP.- Parameters:
wikiName
- the name of the wiki containing the document, must not be nullspaceName
- the name of the space containing the document, must not be nullpageName
- the name of the documentlanguage
- the language of the document reference, may be null
-
DocumentReference
public DocumentReference(String wikiName, List<String> spaceNames, String pageName)
Create a new Document reference from wiki name, spaces names and page name.- Parameters:
wikiName
- the name of the wiki containing the document, must not be nullspaceNames
- an ordered list of the names of the spaces containing the document from root space to last one, must not be nullpageName
- the name of the document
-
DocumentReference
public DocumentReference(String wikiName, List<String> spaceNames, String pageName, Locale locale)
Create a new Document reference from wiki name, spaces names, page name and locale.- Parameters:
wikiName
- the name of the wiki containing the document, must not be nullspaceNames
- an ordered list of the names of the spaces containing the document from root space to last one, must not be nullpageName
- the name of the document referencelocale
- the locale of the document reference, may be null
-
DocumentReference
public DocumentReference(String pageName, SpaceReference parent)
Create a new Document reference from document name and parent space.- Parameters:
pageName
- the name of the documentparent
- the parent space for the document
-
DocumentReference
public DocumentReference(LocalDocumentReference localDocumentReference, WikiReference wikiReference)
Create a new Document reference from local document reference and wiki reference.- Parameters:
localDocumentReference
- the document reference without the wiki referencewikiReference
- the wiki reference- Since:
- 5.1M1
-
DocumentReference
public DocumentReference(String pageName, SpaceReference parent, Locale locale)
Create a new Document reference from document name, parent space and locale.- Parameters:
pageName
- the name of the documentparent
- the parent space for the documentlocale
- the locale of the document reference, may be null
-
DocumentReference
public DocumentReference(String pageName, EntityReference parent, Map<String,Serializable> parameters)
- Parameters:
pageName
- the name of the documentparent
- the parent space for the documentparameters
- parameters for this reference, may be null- Since:
- 10.6RC1
-
DocumentReference
public DocumentReference(EntityReference reference, EntityReference parent)
Clone an DocumentReference, 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
-
setParent
protected void setParent(EntityReference parent)
Entity reference are immutable since 3.3M2, so this method is now protected.Overridden in order to verify the validity of the passed parent.
- Overrides:
setParent
in classEntityReference
- Parameters:
parent
- the parent for this entity, may be null for a root entity.- Throws:
IllegalArgumentException
- if the passed parent is not a valid document reference parent (ie a space reference)- See Also:
EntityReference.setParent(EntityReference)
-
setType
protected void setType(EntityType type)
Entity reference are immutable since 3.3M2, so this method is now protected.Overridden in order to verify the validity of the passed type.
- Overrides:
setType
in classEntityReference
- Parameters:
type
- the type for this entity- Throws:
IllegalArgumentException
- if the passed type is not a document type- See Also:
EntityReference.setType(org.xwiki.model.EntityType)
-
getWikiReference
public WikiReference getWikiReference()
- Returns:
- the wiki reference of this document reference
-
setWikiReference
public DocumentReference setWikiReference(WikiReference wikiReference)
Create a new DocumentReference with passed wiki reference.- Parameters:
wikiReference
- the wiki reference to use- Returns:
- a new document reference or the same if the passed wiki is already the current wiki
- Since:
- 7.2M1
-
getLastSpaceReference
public SpaceReference getLastSpaceReference()
- Returns:
- the space reference of the last space containing this document
-
getSpaceReferences
public List<SpaceReference> getSpaceReferences()
- Returns:
- space references of this document in an ordered list
-
replaceParent
public DocumentReference replaceParent(EntityReference oldParent, EntityReference newParent)
Description copied from class:EntityReference
Return a clone of this reference, but with one of its parent replaced by another one.- Overrides:
replaceParent
in classEntityReference
- Parameters:
oldParent
- the old parent that will be replacednewParent
- the new parent that will replace oldParent in the chain. If the same as oldParent, this is returned.- Returns:
- a new reference with a amended parent chain
-
replaceParent
public DocumentReference replaceParent(EntityReference newParent)
Description copied from class:EntityReference
Return a clone of this reference, but with its parent replaced by the passed one.- Overrides:
replaceParent
in classEntityReference
- Parameters:
newParent
- the new parent that will replace the parent- Returns:
- a new reference with a amended parent chain
-
getLocaleDocumentReference
@Deprecated public LocalDocumentReference getLocaleDocumentReference()
Deprecated.since 9.3RC1/8.4.5, usegetLocalDocumentReference()
instead- Returns:
- the
LocalDocumentReference
corresponding to thisDocumentReference
- Since:
- 8.3
-
getLocalDocumentReference
public LocalDocumentReference getLocalDocumentReference()
- Returns:
- the
LocalDocumentReference
corresponding to thisDocumentReference
- Since:
- 9.3RC1, 8.4.5
-
withoutLocale
public DocumentReference withoutLocale()
- Returns:
- this document reference but without the locale if it contains any
- Since:
- 13.4RC1, 12.10.8
-
toString
public String toString()
- Overrides:
toString
in classEntityReference
-
-