public class PageReference extends AbstractLocalizedEntityReference
Document
object. Both a
PageReference
and a DocumentReference
point to a Document
.
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 in
WebHome
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 the Webhome
part in the reference (e.g. A.B.C
).
Modifier and Type | Field and Description |
---|---|
static Type |
TYPE_PROVIDER
The
Type for a Provider<PageReference> . |
LOCALE
TOSTRING_SERIALIZER
Modifier | Constructor and Description |
---|---|
|
PageReference(EntityReference reference)
Special constructor that transforms a generic entity reference into a
PageReference . |
|
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(EntityReference reference,
Locale locale)
Clone an EntityReference and change/add the passed Locale.
|
|
PageReference(LocalPageReference localPageReference,
WikiReference wikiReference)
Create a new page reference from local page reference and wiki 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 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,
PageReference parent)
Create a page reference based on a page name and a parent page reference.
|
|
PageReference(String wikiName,
String pageName,
String... pageNames)
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.
|
Modifier and Type | Method and 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() |
getLocale, setLocale, setParameter
appendParent, compareTo, equals, equals, equals, equalsNonRecursive, extractFirstReference, extractReference, getName, getParameter, getParameters, getParent, getReversedReferenceChain, getRoot, getType, hashCode, hasParent, removeParent, setName, setParameters, size
public PageReference(EntityReference reference)
PageReference
. It checks the
validity of the passed reference (ie correct type).reference
- the entity reference to transformsIllegalArgumentException
- if the passed reference is not a valid page referenceprotected PageReference(EntityReference reference, EntityReference oldReference, EntityReference newReference)
reference
- the reference that is clonedoldReference
- the old parent that will be replacednewReference
- the new parent that will replace oldReference in the chainpublic PageReference(String pageName, WikiReference parent)
pageName
- the name of the pageparent
- the wiki referencepublic PageReference(String pageName, PageReference parent)
pageName
- the name of the pageparent
- the page referencepublic PageReference(String pageName, EntityReference parent)
pageName
- the name of the pageparent
- the entity referencepublic PageReference(String pageName, EntityReference parent, Locale locale)
pageName
- the name of the pageparent
- the entity referencelocale
- the Locale
of the page.public PageReference(EntityReference reference, Locale locale)
reference
- the reference to clonelocale
- the Locale
of the new referencepublic PageReference(String wikiName, List<String> pageNames)
wikiName
- the name of the wikipageNames
- the pages namespublic PageReference(String wikiName, List<String> pageNames, Locale locale)
wikiName
- the name of the wikipageNames
- the pages nameslocale
- the Locale
of the entity.public PageReference(String wikiName, String pageName, String... pageNames)
wikiName
- the name of the wikipageName
- the root page namepageNames
- the children page namespublic PageReference(LocalPageReference localPageReference, WikiReference wikiReference)
localPageReference
- the page reference without the wiki referencewikiReference
- the wiki referencepublic PageReference(EntityReference reference, EntityReference parent)
reference
- the reference to cloneparent
- the new parent to useprotected void setParent(EntityReference parent)
Overridden in order to verify the validity of the passed parent.
setParent
in class EntityReference
parent
- the parent for this entity, may be null for a root entity.IllegalArgumentException
- if the passed parent is not a valid page reference parent (ie either a page
reference or a wiki reference)EntityReference.setParent(EntityReference)
protected void setType(EntityType type)
Overridden in order to verify the validity of the passed type.
setType
in class EntityReference
type
- the type for this entityIllegalArgumentException
- if the passed type is not a page typeEntityReference.setType(org.xwiki.model.EntityType)
public PageReference replaceParent(EntityReference oldParent, EntityReference newParent)
EntityReference
replaceParent
in class EntityReference
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.public PageReference replaceParent(EntityReference newParent)
EntityReference
replaceParent
in class EntityReference
newParent
- the new parent that will replace the parentpublic WikiReference getWikiReference()
public String toString()
toString
in class EntityReference
Copyright © 2004–2021 XWiki. All rights reserved.