Package org.xwiki.model.reference
Class BlockReference
- java.lang.Object
-
- org.xwiki.model.reference.EntityReference
-
- org.xwiki.model.reference.BlockReference
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<EntityReference>
public class BlockReference extends EntityReference
Reference to a block, a structured part of the content of a document or an object property. While other references are generally unique, defined application wide, and usable to reach their target instance, the meaning of block references depends on their usage, may not be unique and are not necessarily a way to reach the referenced instance. We may have different kind of block references, for different purposes (for example identifying a header in the content, linking signature to macro block, etc...).- Since:
- 6.0M1
- Version:
- $Id: 822b02044ad2f24fcc3c8e6691a7eb0b3f2a0064 $
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.xwiki.model.reference.EntityReference
TOSTRING_SERIALIZER
-
-
Constructor Summary
Constructors Modifier Constructor Description BlockReference(String blockName)
BlockReference(String blockName, DocumentReference documentReference)
BlockReference(String blockName, ObjectPropertyReference objectPropertyReference)
BlockReference(EntityReference reference)
Constructor which would raise exceptions if the source entity reference does not have the appropriate type or parent, etc.BlockReference(EntityReference reference, EntityReference parent)
Clone an BlockReference, but use the specified parent for its new parent.protected
BlockReference(EntityReference reference, EntityReference oldReference, EntityReference newReference)
Clone an BlockReference, 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 BlockReference
replaceParent(EntityReference newParent)
Return a clone of this reference, but with its parent replaced by the passed one.BlockReference
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.-
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
-
BlockReference
public BlockReference(EntityReference reference)
Constructor which would raise exceptions if the source entity reference does not have the appropriate type or parent, etc.- Parameters:
reference
- the raw reference to build this block reference from
-
BlockReference
protected BlockReference(EntityReference reference, EntityReference oldReference, EntityReference newReference)
Clone an BlockReference, 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
-
BlockReference
public BlockReference(String blockName)
- Parameters:
blockName
- the name of the block
-
BlockReference
public BlockReference(String blockName, DocumentReference documentReference)
- Parameters:
blockName
- the name of the blockdocumentReference
- the reference of the parent document of the block
-
BlockReference
public BlockReference(String blockName, ObjectPropertyReference objectPropertyReference)
- Parameters:
blockName
- the name of the blockobjectPropertyReference
- the reference of the parent object property of the block
-
BlockReference
public BlockReference(EntityReference reference, EntityReference parent)
Clone an BlockReference, 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
-
setType
protected void setType(EntityType type)
Entity reference are immutable since 3.3M2, so this method is now protected.Overridden to check the type to be an block type.
- Overrides:
setType
in classEntityReference
- Parameters:
type
- the type for this entity- See Also:
EntityReference.setType(org.xwiki.model.EntityType)
-
setParent
protected void setParent(EntityReference parent)
Entity reference are immutable since 3.3M2, so this method is now protected.Overridden to ensure that the parent of a block is either a document or an object property.
- Overrides:
setParent
in classEntityReference
- Parameters:
parent
- the parent for this entity, may be null for a root entity.- See Also:
EntityReference.setParent(org.xwiki.model.reference.EntityReference)
-
replaceParent
public BlockReference 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 BlockReference 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
-
-