org.xwiki.model.reference
Class AttachmentReference

java.lang.Object
  extended by org.xwiki.model.reference.EntityReference
      extended by org.xwiki.model.reference.AttachmentReference
All Implemented Interfaces:
Serializable, Cloneable, Comparable<EntityReference>

public class AttachmentReference
extends EntityReference

Represents a reference to an Attachment (document reference and file name). Note that an attachment is always attached to a document.

Since:
2.2M1
Version:
$Id: d8298282f856ba0789ab6b444b829520d9bcc971 $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.xwiki.model.reference.EntityReference
TOSTRING_SERIALIZER
 
Constructor Summary
  AttachmentReference(EntityReference reference)
          Special constructor that transforms a generic entity reference into an AttachmentReference.
protected AttachmentReference(EntityReference reference, EntityReference oldReference, EntityReference newReference)
          Clone an AttachmentReference, but replace one of the parent in the chain by a new one.
  AttachmentReference(String fileName, DocumentReference parent)
          Create a new attachment reference based on the attachment name and the parent document reference.
 
Method Summary
 DocumentReference getDocumentReference()
           
 AttachmentReference 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, extractReference, getName, getParameter, getParent, getReversedReferenceChain, getRoot, getType, hashCode, removeParent, setName, setParameter, setParameters, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AttachmentReference

public AttachmentReference(EntityReference reference)
Special constructor that transforms a generic entity reference into an AttachmentReference. 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

AttachmentReference

protected AttachmentReference(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 cloned
oldReference - the old parent that will be replaced
newReference - the new parent that will replace oldReference in the chain
Since:
3.3M2

AttachmentReference

public AttachmentReference(String fileName,
                           DocumentReference parent)
Create a new attachment reference based on the attachment name and the parent document reference.

Parameters:
fileName - the name of the attachment
parent - the reference of the document
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 class EntityReference
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 class EntityReference
Parameters:
type - the type for this entity
Throws:
IllegalArgumentException - if the passed type is not an attachment type

getDocumentReference

public DocumentReference getDocumentReference()
Returns:
the document reference contained in this attachment reference

replaceParent

public AttachmentReference 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 class EntityReference
Parameters:
oldParent - the old parent that will be replaced
newParent - 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


Copyright © 2004-2013 XWiki. All Rights Reserved.