com.xpn.xwiki.doc
Class XWikiAttachment

java.lang.Object
  extended by com.xpn.xwiki.doc.XWikiAttachment
All Implemented Interfaces:
Cloneable

public class XWikiAttachment
extends Object
implements Cloneable


Constructor Summary
XWikiAttachment()
           
XWikiAttachment(XWikiDocument doc, String filename)
           
 
Method Summary
 Object clone()
           
 void fromXML(org.dom4j.Element docel)
           
 void fromXML(String data)
           
 org.suigeneris.jrcs.rcs.Archive getArchive()
          Deprecated. since 2.6M1 please do not use this, it is bound to a jrcs based implementation.
 XWikiAttachmentArchive getAttachment_archive()
           
 XWikiAttachmentContent getAttachment_content()
           
 XWikiAttachment getAttachmentRevision(String rev, XWikiContext context)
           
 String getAuthor()
           
 String getComment()
           
 byte[] getContent(XWikiContext context)
          Deprecated. use getContentInputStream(XWikiContext) instead
 InputStream getContentInputStream(XWikiContext context)
          Retrive the content of this attachment as an input stream.
 int getContentSize(XWikiContext context)
           
 Date getDate()
           
 XWikiDocument getDoc()
           
 long getDocId()
           
 String getFilename()
           
 int getFilesize()
           
 long getId()
           
 String getMimeType(XWikiContext context)
           
 String getNextVersion()
           
 org.suigeneris.jrcs.rcs.Version getRCSVersion()
           
 AttachmentReference getReference()
           
 String getVersion()
           
 List<org.suigeneris.jrcs.rcs.Version> getVersionList()
          Get the list of all versions up to the current.
 org.suigeneris.jrcs.rcs.Version[] getVersions()
           
 void incrementVersion()
           
 boolean isContentDirty()
           
 boolean isImage(XWikiContext context)
           
 boolean isMetaDataDirty()
           
 XWikiAttachmentArchive loadArchive(XWikiContext context)
           
 void loadContent(XWikiContext context)
           
 void setArchive(org.suigeneris.jrcs.rcs.Archive archive)
          Deprecated. since 2.6M1 please do not use this, it is bound to a jrcs based implementation.
 void setArchive(String data)
           
 void setAttachment_archive(XWikiAttachmentArchive attachment_archive)
           
 void setAttachment_content(XWikiAttachmentContent attachment_content)
           
 void setAuthor(String author)
           
 void setComment(String comment)
           
 void setContent(byte[] data)
          Deprecated. use setContent(java.io.InputStream, int) instead
 void setContent(InputStream is)
          Set the content of the attachment from an InputStream.
 void setContent(InputStream is, int length)
          Set the content of an attachment from an InputStream.
 void setDate(Date date)
           
 void setDoc(XWikiDocument doc)
           
 void setDocId(long id)
           
 void setFilename(String filename)
           
 void setFilesize(int filesize)
          Set cached filesize of the attachment that will be stored as metadata
 void setId(long id)
           
 void setMetaDataDirty(boolean metaDataDirty)
           
 void setRCSVersion(org.suigeneris.jrcs.rcs.Version version)
           
 void setVersion(String version)
           
 String toStringXML(boolean bWithAttachmentContent, boolean bWithVersions, XWikiContext context)
          Retrieve an attachment as an XML string.
 org.dom4j.Element toXML(boolean bWithAttachmentContent, boolean bWithVersions, XWikiContext context)
          Retrieve XML representation of attachment's metadata into an Element.
 void toXML(com.xpn.xwiki.internal.xml.XMLWriter wr, boolean bWithAttachmentContent, boolean bWithVersions, XWikiContext context)
          Write an XML representation of the attachment into an XMLWriter
 org.dom4j.Element toXML(XWikiContext context)
          Retrieve XML representation of attachment's metadata into an Element.
 void updateContentArchive(XWikiContext context)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XWikiAttachment

public XWikiAttachment(XWikiDocument doc,
                       String filename)

XWikiAttachment

public XWikiAttachment()
Method Detail

getReference

public AttachmentReference getReference()

getId

public long getId()

setDocId

public void setDocId(long id)

getDocId

public long getDocId()

setId

public void setId(long id)

clone

public Object clone()
Overrides:
clone in class Object

getFilesize

public int getFilesize()
Returns:
the cached filesize in byte of the attachment, stored as metadata

setFilesize

public void setFilesize(int filesize)
Set cached filesize of the attachment that will be stored as metadata

Parameters:
filesize - in byte

getContentSize

public int getContentSize(XWikiContext context)
                   throws XWikiException
Parameters:
context - current XWikiContext
Returns:
the real filesize in byte of the attachment. We cannot trust the metadata that may be publicly changed.
Throws:
XWikiException
Since:
2.3M2

getFilename

public String getFilename()

setFilename

public void setFilename(String filename)

getAuthor

public String getAuthor()

setAuthor

public void setAuthor(String author)

getVersion

public String getVersion()

setVersion

public void setVersion(String version)

getNextVersion

public String getNextVersion()

getRCSVersion

public org.suigeneris.jrcs.rcs.Version getRCSVersion()

setRCSVersion

public void setRCSVersion(org.suigeneris.jrcs.rcs.Version version)

getComment

public String getComment()

setComment

public void setComment(String comment)

getDoc

public XWikiDocument getDoc()

setDoc

public void setDoc(XWikiDocument doc)

getDate

public Date getDate()

setDate

public void setDate(Date date)

isContentDirty

public boolean isContentDirty()

incrementVersion

public void incrementVersion()

isMetaDataDirty

public boolean isMetaDataDirty()

setMetaDataDirty

public void setMetaDataDirty(boolean metaDataDirty)

toStringXML

public String toStringXML(boolean bWithAttachmentContent,
                          boolean bWithVersions,
                          XWikiContext context)
                   throws XWikiException
Retrieve an attachment as an XML string. You should prefer toXML(com.xpn.xwiki.internal.xml.XMLWriter, boolean, boolean, com.xpn.xwiki.XWikiContext) to avoid memory loads when appropriate.

Parameters:
bWithAttachmentContent - if true, binary content of the attachment is included (base64 encoded)
bWithVersions - if true, all archived versions are also included
context - current XWikiContext
Returns:
a string containing an XML representation of the attachment
Throws:
XWikiException - when an error occurs during wiki operations

toXML

public org.dom4j.Element toXML(XWikiContext context)
                        throws XWikiException
Retrieve XML representation of attachment's metadata into an Element.

Returns:
a Element containing an XML representation of the attachment without content
Throws:
XWikiException - when an error occurs during wiki operations

toXML

public void toXML(com.xpn.xwiki.internal.xml.XMLWriter wr,
                  boolean bWithAttachmentContent,
                  boolean bWithVersions,
                  XWikiContext context)
           throws IOException,
                  XWikiException
Write an XML representation of the attachment into an XMLWriter

Parameters:
wr - the XMLWriter to write to
bWithAttachmentContent - if true, binary content of the attachment is included (base64 encoded)
bWithVersions - if true, all archive version is also included
context - current XWikiContext
Throws:
IOException - when an error occurs during streaming operation
XWikiException - when an error occurs during xwiki operation
Since:
2.3M2

toXML

public org.dom4j.Element toXML(boolean bWithAttachmentContent,
                               boolean bWithVersions,
                               XWikiContext context)
                        throws XWikiException
Retrieve XML representation of attachment's metadata into an Element. You should prefer toXML(com.xpn.xwiki.internal.xml.XMLWriter, boolean, boolean, com.xpn.xwiki.XWikiContext) to avoid memory loads when appropriate.

Parameters:
bWithAttachmentContent - if true, binary content of the attachment is included (base64 encoded)
bWithVersions - if true, all archived versions are also included
context - current XWikiContext
Returns:
an Element containing an XML representation of the attachment
Throws:
XWikiException - when an error occurs during wiki operations
Since:
2.3M2

fromXML

public void fromXML(String data)
             throws XWikiException
Throws:
XWikiException

fromXML

public void fromXML(org.dom4j.Element docel)
             throws XWikiException
Throws:
XWikiException

getAttachment_content

public XWikiAttachmentContent getAttachment_content()

setAttachment_content

public void setAttachment_content(XWikiAttachmentContent attachment_content)

getAttachment_archive

public XWikiAttachmentArchive getAttachment_archive()

setAttachment_archive

public void setAttachment_archive(XWikiAttachmentArchive attachment_archive)

getContent

@Deprecated
public byte[] getContent(XWikiContext context)
                  throws XWikiException
Deprecated. use getContentInputStream(XWikiContext) instead

Retrive the content of this attachment as a byte array.

Parameters:
context - current XWikiContext
Returns:
a byte array containing the binary data content of the attachment
Throws:
XWikiException - when an error occurs during wiki operation

getContentInputStream

public InputStream getContentInputStream(XWikiContext context)
                                  throws XWikiException
Retrive the content of this attachment as an input stream.

Parameters:
context - current XWikiContext
Returns:
an InputStream to consume for receiving the content of this attachment
Throws:
XWikiException - when an error occurs during wiki operation
Since:
2.3M2

getArchive

@Deprecated
public org.suigeneris.jrcs.rcs.Archive getArchive()
Deprecated. since 2.6M1 please do not use this, it is bound to a jrcs based implementation.


setArchive

@Deprecated
public void setArchive(org.suigeneris.jrcs.rcs.Archive archive)
Deprecated. since 2.6M1 please do not use this, it is bound to a jrcs based implementation.


setArchive

public void setArchive(String data)
                throws XWikiException
Throws:
XWikiException

getVersions

public org.suigeneris.jrcs.rcs.Version[] getVersions()

getVersionList

public List<org.suigeneris.jrcs.rcs.Version> getVersionList()
                                                     throws XWikiException
Get the list of all versions up to the current. We assume versions go from 1.1 to the current one This allows not to read the full archive file.

Returns:
a list of Version from 1.1 to the current version.
Throws:
XWikiException - never happens.

setContent

@Deprecated
public void setContent(byte[] data)
Deprecated. use setContent(java.io.InputStream, int) instead

Set the content of an attachment from a byte array.

Parameters:
data - a byte array with the binary content of the attachment

setContent

public void setContent(InputStream is,
                       int length)
                throws IOException
Set the content of an attachment from an InputStream.

Parameters:
is - the input stream that will be read
length - the length in byte to read
Throws:
IOException - when an error occurs during streaming operation
Since:
2.3M2

setContent

public void setContent(InputStream is)
                throws IOException
Set the content of the attachment from an InputStream.

Parameters:
is - the input stream that will be read
Throws:
IOException - when an error occurs during streaming operation
Since:
2.6M1

loadContent

public void loadContent(XWikiContext context)
                 throws XWikiException
Throws:
XWikiException

loadArchive

public XWikiAttachmentArchive loadArchive(XWikiContext context)
                                   throws XWikiException
Throws:
XWikiException

updateContentArchive

public void updateContentArchive(XWikiContext context)
                          throws XWikiException
Throws:
XWikiException

getMimeType

public String getMimeType(XWikiContext context)

isImage

public boolean isImage(XWikiContext context)

getAttachmentRevision

public XWikiAttachment getAttachmentRevision(String rev,
                                             XWikiContext context)
                                      throws XWikiException
Throws:
XWikiException


Copyright © 2004-2013 XWiki. All Rights Reserved.