Class PageReference
- java.lang.Object
-
- org.xwiki.model.reference.EntityReference
-
- org.xwiki.model.reference.AbstractLocalizedEntityReference
-
- org.xwiki.model.reference.PageReference
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<EntityReference>
public class PageReference extends AbstractLocalizedEntityReference
Represents a reference to a page. Note that nested pages are supported. A page is essentially the same thing as a document. A document represents the data displayed in a wiki page, stored in aDocument
object. Both aPageReference
and aDocumentReference
point to aDocument
.In XWiki 7.2, we introduced the ability to have pages inside pages (we called it Nested Pages). We did that by creating a space to represent a Nested Page. Indeed, a space always has
WebHome
document and this document contains the content of the Nested Page. In other words all Nested Page are located inWebHome
documents.This means that a reference to a Nested Page always ends with
WebHome
, which is an implementation detail, and hard to remember and use (e.g.A.B.C.WebHome
). Thus we introduced the concept of a Page Reference to reference a Nested Page and this allows us to drop theWebhome
part in the reference (e.g.A.B.C
).- Since:
- 10.6RC1
- Version:
- $Id: d211c512c8fa5741cd9d8b75ca8a582b97fe6555 $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Type
TYPE_PROVIDER
TheType
for aProvider<PageReference>
.-
Fields inherited from class org.xwiki.model.reference.AbstractLocalizedEntityReference
LOCALE
-
Fields inherited from class org.xwiki.model.reference.EntityReference
TOSTRING_SERIALIZER
-
-
Constructor Summary
Constructors Modifier Constructor Description PageReference(String wikiName, String pageName, String... pageNames)
Create a page reference based on a page name and a parent page reference.PageReference(String wikiName, List<String> pageNames)
Create a page reference based on a page name and a parent page reference.PageReference(String wikiName, List<String> pageNames, Locale locale)
Create a page reference based on a page name and a parent page reference.PageReference(String pageName, EntityReference parent)
Create a page reference based on a page name and a parent entity reference.PageReference(String pageName, EntityReference parent, Locale locale)
Create a page reference based on a page name and a parent entity reference.PageReference(String pageName, PageReference parent)
Create a page reference based on a page name and a parent page reference.PageReference(String pageName, WikiReference parent)
Create a page reference based on a page name and a parent wiki reference.PageReference(EntityReference reference)
Special constructor that transforms a generic entity reference into aPageReference
.PageReference(EntityReference reference, Locale locale)
Clone an EntityReference and change/add the passed Locale.PageReference(EntityReference reference, EntityReference parent)
Clone an PageReference, but use the specified parent for its new parent.protected
PageReference(EntityReference reference, EntityReference oldReference, EntityReference newReference)
Clone a page reference, but replace one of the parent in the chain by a new one.PageReference(LocalPageReference localPageReference, WikiReference wikiReference)
Create a new page reference from local page reference and wiki reference.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WikiReference
getWikiReference()
PageReference
replaceParent(EntityReference newParent)
Return a clone of this reference, but with its parent replaced by the passed one.PageReference
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.String
toString()
-
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
-
PageReference
public PageReference(EntityReference reference)
Special constructor that transforms a generic entity reference into aPageReference
. It checks the validity of the passed reference (ie correct type).- Parameters:
reference
- the entity reference to transforms- Throws:
IllegalArgumentException
- if the passed reference is not a valid page reference
-
PageReference
protected PageReference(EntityReference reference, EntityReference oldReference, EntityReference newReference)
Clone a page reference, 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
-
PageReference
public PageReference(String pageName, WikiReference parent)
Create a page reference based on a page name and a parent wiki reference.- Parameters:
pageName
- the name of the pageparent
- the wiki reference
-
PageReference
public PageReference(String pageName, PageReference parent)
Create a page reference based on a page name and a parent page reference.- Parameters:
pageName
- the name of the pageparent
- the page reference
-
PageReference
public PageReference(String pageName, EntityReference parent)
Create a page reference based on a page name and a parent entity reference. The entity reference may be either a wiki or a page reference.- Parameters:
pageName
- the name of the pageparent
- the entity reference
-
PageReference
public PageReference(String pageName, EntityReference parent, Locale locale)
Create a page reference based on a page name and a parent entity reference. The entity reference may be either a wiki or a page reference.- Parameters:
pageName
- the name of the pageparent
- the entity referencelocale
- theLocale
of the page.
-
PageReference
public PageReference(EntityReference reference, Locale locale)
Clone an EntityReference and change/add the passed Locale.- Parameters:
reference
- the reference to clonelocale
- theLocale
of the new reference
-
PageReference
public PageReference(String wikiName, List<String> pageNames)
Create a page reference based on a page name and a parent page reference.- Parameters:
wikiName
- the name of the wikipageNames
- the pages names
-
PageReference
public PageReference(String wikiName, List<String> pageNames, Locale locale)
Create a page reference based on a page name and a parent page reference.- Parameters:
wikiName
- the name of the wikipageNames
- the pages nameslocale
- theLocale
of the entity.
-
PageReference
public PageReference(String wikiName, String pageName, String... pageNames)
Create a page reference based on a page name and a parent page reference.- Parameters:
wikiName
- the name of the wikipageName
- the root page namepageNames
- the children page names
-
PageReference
public PageReference(LocalPageReference localPageReference, WikiReference wikiReference)
Create a new page reference from local page reference and wiki reference.- Parameters:
localPageReference
- the page reference without the wiki referencewikiReference
- the wiki reference
-
PageReference
public PageReference(EntityReference reference, EntityReference parent)
Clone an PageReference, 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 page reference parent (ie either a page reference or a wiki 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 page type- See Also:
EntityReference.setType(org.xwiki.model.EntityType)
-
replaceParent
public PageReference 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 PageReference 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
-
getWikiReference
public WikiReference getWikiReference()
- Returns:
- the reference of the wiki containing this page
-
toString
public String toString()
- Overrides:
toString
in classEntityReference
-
-