Package org.xwiki.model.reference
Class SpaceReference
- java.lang.Object
-
- org.xwiki.model.reference.EntityReference
-
- org.xwiki.model.reference.SpaceReference
-
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<EntityReference>
public class SpaceReference extends EntityReference
Represents a reference to a space (space name). Note that nested spaces are supported.- Since:
- 2.2M1
- Version:
- $Id: 49b2cbb86daffd5a166ff671c3f2d1c2a99d9573 $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static TypeTYPE_PROVIDERTheTypefor aProvider<SpaceReference>.-
Fields inherited from class org.xwiki.model.reference.EntityReference
TOSTRING_SERIALIZER
-
-
Constructor Summary
Constructors Modifier Constructor Description SpaceReference(String wikiName, String... spaceNames)Create a space reference based on a space name and a parent space reference.SpaceReference(String wikiName, List<String> spaceNames)Create a space reference based on a space name and a parent space reference.SpaceReference(String spaceName, EntityReference parent)Create a space reference based on a space name and a parent entity reference.SpaceReference(String spaceName, SpaceReference parent)Create a space reference based on a space name and a parent space reference.SpaceReference(String spaceName, WikiReference parent)Create a space reference based on a space name and a parent wiki reference.SpaceReference(EntityReference reference)Special constructor that transforms a generic entity reference into aSpaceReference.SpaceReference(EntityReference reference, EntityReference parent)Clone an SpaceReference, but use the specified parent for its new parent.protectedSpaceReference(EntityReference reference, EntityReference oldReference, EntityReference newReference)Clone an SpaceReference, but replace one of the parent in the chain by a new one.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WikiReferencegetWikiReference()SpaceReferencereplaceParent(EntityReference newParent)Return a clone of this reference, but with its parent replaced by the passed one.SpaceReferencereplaceParent(EntityReference oldParent, EntityReference newParent)Return a clone of this reference, but with one of its parent replaced by another one.protected voidsetParent(EntityReference parent)Entity reference are immutable since 3.3M2, so this method is now protected.protected voidsetType(EntityType type)Entity reference are immutable since 3.3M2, so this method is now protected.-
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
-
-
-
-
Constructor Detail
-
SpaceReference
public SpaceReference(EntityReference reference)
Special constructor that transforms a generic entity reference into aSpaceReference. 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 space reference
-
SpaceReference
protected SpaceReference(EntityReference reference, EntityReference oldReference, EntityReference newReference)
Clone an SpaceReference, 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
-
SpaceReference
public SpaceReference(String spaceName, WikiReference parent)
Create a space reference based on a space name and a parent wiki reference.- Parameters:
spaceName- the name of the spaceparent- the wiki reference
-
SpaceReference
public SpaceReference(String spaceName, SpaceReference parent)
Create a space reference based on a space name and a parent space reference.- Parameters:
spaceName- the name of the spaceparent- the space reference
-
SpaceReference
public SpaceReference(String spaceName, EntityReference parent)
Create a space reference based on a space name and a parent entity reference. The entity reference may be either a wiki or a space reference.- Parameters:
spaceName- the name of the spaceparent- the entity reference
-
SpaceReference
public SpaceReference(String wikiName, String... spaceNames)
Create a space reference based on a space name and a parent space reference.- Parameters:
wikiName- the name of the wikispaceNames- the spaces names- Since:
- 7.4M1
-
SpaceReference
public SpaceReference(String wikiName, List<String> spaceNames)
Create a space reference based on a space name and a parent space reference.- Parameters:
wikiName- the name of the wikispaceNames- the spaces names- Since:
- 7.4M1
-
SpaceReference
public SpaceReference(EntityReference reference, EntityReference parent)
Clone an SpaceReference, 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:
setParentin 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 space reference parent (ie either a space 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:
setTypein classEntityReference- Parameters:
type- the type for this entity- Throws:
IllegalArgumentException- if the passed type is not a space type- See Also:
EntityReference.setType(org.xwiki.model.EntityType)
-
replaceParent
public SpaceReference replaceParent(EntityReference oldParent, EntityReference newParent)
Description copied from class:EntityReferenceReturn a clone of this reference, but with one of its parent replaced by another one.- Overrides:
replaceParentin 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 SpaceReference replaceParent(EntityReference newParent)
Description copied from class:EntityReferenceReturn a clone of this reference, but with its parent replaced by the passed one.- Overrides:
replaceParentin 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 space
- Since:
- 7.1M2
-
-