|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xwiki.model.reference.EntityReference
public class EntityReference
Represents a reference to an Entity (Document, Attachment, Space, Wiki, etc).
Field Summary | |
---|---|
protected static LocalizedStringEntityReferenceSerializer |
TOSTRING_SERIALIZER
Used to provide a nice and readable pretty name for the toString() method. |
Constructor Summary | |
---|---|
|
EntityReference(EntityReference reference)
Clone an EntityReference. |
|
EntityReference(EntityReference reference,
EntityReference parent)
Clone an EntityReference, but use the specified parent for its new parent. |
protected |
EntityReference(EntityReference reference,
EntityReference oldReference,
EntityReference newReference)
Clone an EntityReference, but replace one of the parent in the chain by an other one. |
|
EntityReference(String name,
EntityType type)
Create a new root EntityReference. |
|
EntityReference(String name,
EntityType type,
EntityReference parent)
Create a new EntityReference. |
protected |
EntityReference(String name,
EntityType type,
EntityReference parent,
Map<String,Serializable> parameters)
Create a new EntityReference. |
Method Summary | ||
---|---|---|
EntityReference |
appendParent(EntityReference newParent)
Return a clone of this reference with a parent appended at the root of its parents chain. |
|
int |
compareTo(EntityReference reference)
|
|
boolean |
equals(Object obj)
|
|
EntityReference |
extractReference(EntityType type)
Extract the entity of the given type from this one. |
|
String |
getName()
Returns the name of this entity. |
|
protected
|
getParameter(String name)
Get the value of a parameter. |
|
EntityReference |
getParent()
|
|
List<EntityReference> |
getReversedReferenceChain()
|
|
EntityReference |
getRoot()
|
|
EntityType |
getType()
Returns the type of this entity. |
|
int |
hashCode()
|
|
EntityReference |
removeParent(EntityReference oldParent)
Return a clone of this reference truncated to a null parent when it reach the given parent. |
|
EntityReference |
replaceParent(EntityReference oldParent,
EntityReference newParent)
Return a clone of this reference, but with one of its parent replaced by another one. |
|
protected void |
setName(String name)
Entity reference are immutable since 3.3M2, so this method is now protected. |
|
protected void |
setParameter(String name,
Serializable value)
Add or set a parameter value. |
|
protected void |
setParameters(Map<String,Serializable> parameters)
Set multiple parameters at once. |
|
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 java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final LocalizedStringEntityReferenceSerializer TOSTRING_SERIALIZER
toString()
method.
Constructor Detail |
---|
public EntityReference(EntityReference reference)
reference
- the reference to clonepublic EntityReference(EntityReference reference, EntityReference parent)
reference
- the reference to cloneparent
- the new parent to useprotected EntityReference(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 EntityReference(String name, EntityType type)
name
- name for the newly created entity reference, could not be null.type
- type for the newly created entity reference, could not be null.public EntityReference(String name, EntityType type, EntityReference parent)
name
- name for the newly created entity reference, could not be null.type
- type for the newly created entity reference, could not be null.parent
- parent reference for the newly created entity reference, may be null.protected EntityReference(String name, EntityType type, EntityReference parent, Map<String,Serializable> parameters)
name
- name for the newly created entity, could not be null.type
- type for the newly created entity, could not be null.parent
- parent reference for the newly created entity reference, may be null.parameters
- parameters for this reference, may be nullMethod Detail |
---|
protected void setName(String name)
name
- the name for this entity
IllegalArgumentException
- if the passed name is null or emptypublic final String getName()
protected void setParent(EntityReference parent)
parent
- the parent for this entity, may be null for a root entity.public final EntityReference getParent()
protected void setType(EntityType type)
type
- the type for this entity
IllegalArgumentException
- if the passed type is nullpublic final EntityType getType()
protected void setParameters(Map<String,Serializable> parameters)
parameters
- the map of parameter to setprotected void setParameter(String name, Serializable value)
name
- the name of the parametervalue
- the value of the parameterprotected final <T> T getParameter(String name)
T
- the type of the value of the requested parametername
- the name of the parameter to get
public EntityReference getRoot()
public List<EntityReference> getReversedReferenceChain()
public EntityReference extractReference(EntityType type)
type
- the type of the entity to be extracted
public EntityReference replaceParent(EntityReference oldParent, EntityReference newParent)
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 EntityReference appendParent(EntityReference newParent)
newParent
- the parent that became the root parent of this reference (and its parent).
If null, this is returned.
public EntityReference removeParent(EntityReference oldParent)
oldParent
- the parent that will be replaced by a null. If null, this is returned.
public String toString()
toString
in class Object
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public int compareTo(EntityReference reference)
compareTo
in interface Comparable<EntityReference>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |