Package org.xwiki.model.reference
Class PageAttachmentReference
- java.lang.Object
-
- org.xwiki.model.reference.EntityReference
-
- org.xwiki.model.reference.PageAttachmentReference
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<EntityReference>
public class PageAttachmentReference extends EntityReference
Represents a reference to an Attachment (page reference and file name). Note that an attachment is always attached to a page.- Since:
- 10.6RC1
- Version:
- $Id: e48bdb035f984807f8255a2530b5faa9234f1ed7 $
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.xwiki.model.reference.EntityReference
TOSTRING_SERIALIZER
-
-
Constructor Summary
Constructors Modifier Constructor Description PageAttachmentReference(String fileName, PageReference parent)
Create a new attachment reference based on the attachment name and the parent page reference.PageAttachmentReference(EntityReference reference)
Special constructor that transforms a generic entity reference into anPageAttachmentReference
.PageAttachmentReference(EntityReference reference, EntityReference parent)
Clone an PageAttachmentReference, but use the specified parent for its new parent.protected
PageAttachmentReference(EntityReference reference, EntityReference oldReference, EntityReference newReference)
Clone an AttachmentReference, 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 PageReference
getPageReference()
PageAttachmentReference
replaceParent(EntityReference newParent)
Return a clone of this reference, but with its parent replaced by the passed one.PageAttachmentReference
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
-
PageAttachmentReference
public PageAttachmentReference(EntityReference reference)
Special constructor that transforms a generic entity reference into anPageAttachmentReference
. It checks the validity of the passed reference (ie correct type and correct parent).- Parameters:
reference
- the reference to be transformed- Throws:
IllegalArgumentException
- if the passed reference is not a valid attachment reference
-
PageAttachmentReference
protected PageAttachmentReference(EntityReference reference, EntityReference oldReference, EntityReference newReference)
Clone an AttachmentReference, 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
-
PageAttachmentReference
public PageAttachmentReference(String fileName, PageReference parent)
Create a new attachment reference based on the attachment name and the parent page reference.- Parameters:
fileName
- the name of the attachmentparent
- the reference of the page
-
PageAttachmentReference
public PageAttachmentReference(EntityReference reference, EntityReference parent)
Clone an PageAttachmentReference, 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 attachment reference parent (ie an attachment reference)
-
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 an attachment type
-
getPageReference
public PageReference getPageReference()
- Returns:
- the page reference contained in this attachment reference
-
replaceParent
public PageAttachmentReference 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 PageAttachmentReference 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
-
-