org.yawlfoundation.yawl.documentStore
Class YDocument

java.lang.Object
  extended by org.yawlfoundation.yawl.documentStore.YDocument

public class YDocument
extends Object

Holds a binary file (of any type) to be passed as work item data. Note that the file itself is located in the 'Document Store' service, only its name and id are passed to and from the engine

Author:
Michael Adams
Created/Last Date:
18/11/11

Constructor Summary
YDocument()
          Constructs a new, empty YDocument
YDocument(String caseID, long docID, byte[] docAsBytes)
          Constructs a new YDocument
YDocument(String caseID, long docID, InputStream docStream)
          Constructs a new YDocument
 
Method Summary
 String getCaseId()
          Gets the case id for this document
 byte[] getDocument()
          Gets the binary file stored in this document
 int getDocumentSize()
          Gets the size of the store binary file
 long getId()
          Gets the document identifier
 boolean hasValidId()
          Checks that the document identifier has a valid value
 void setCaseId(String id)
          Sets the case id for this document
 void setDocument(byte[] doc)
          Sets the binary file to be stored in this document
 void setDocument(File file)
          Sets the binary file to be stored in this document
 void setDocument(InputStream in)
          Sets the binary file to be stored in this document
 void setDocument(String fileName)
          Sets the binary file to be stored in this document
 void setId(long id)
          Sets the document identifier
 void writeToFile(File file)
          Writes the binary file stored in this document to a disk file
 void writeToFile(String fileName)
          Writes the binary file stored in this document to a disk file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

YDocument

public YDocument()
Constructs a new, empty YDocument


YDocument

public YDocument(String caseID,
                 long docID,
                 byte[] docAsBytes)
Constructs a new YDocument

Parameters:
caseID - the id of the case the document is a member of
docID - the id of the internal binary file. Set it to a negative value if the document has not yet been stored (and so does not yet have an id)
docAsBytes - a byte array representing the contents of the binary file

YDocument

public YDocument(String caseID,
                 long docID,
                 InputStream docStream)
          throws IOException
Constructs a new YDocument

Parameters:
caseID - the id of the case the document is a member of
docID - the id of the internal binary file. Set it to a negative value if the document has not yet been stored (and so does not yet have an id)
docStream - a stream from which the contents of the binary file may be read
Throws:
IOException - if there's a problem reading from the stream
Method Detail

getId

public long getId()
Gets the document identifier

Returns:
the current document identifier

setId

public void setId(long id)
Sets the document identifier

Parameters:
id - the document identifier to set

hasValidId

public boolean hasValidId()
Checks that the document identifier has a valid value

Returns:
true if the identifier is set and valid

getCaseId

public String getCaseId()
Gets the case id for this document

Returns:
the case id, or an empty String id it has not been set

setCaseId

public void setCaseId(String id)
Sets the case id for this document

Parameters:
id - the case id to set for this document

getDocument

public byte[] getDocument()
Gets the binary file stored in this document

Returns:
the store binary file, as a byte array

getDocumentSize

public int getDocumentSize()
Gets the size of the store binary file

Returns:
the size of the file as a number of bytes

setDocument

public void setDocument(byte[] doc)
Sets the binary file to be stored in this document

Parameters:
doc - a byte array representing the contents of a binary file

setDocument

public void setDocument(File file)
                 throws IOException
Sets the binary file to be stored in this document

Parameters:
file - a File object containing a reference to a disk file to be read into this document
Throws:
IOException - if there's a problem loading the file

setDocument

public void setDocument(String fileName)
                 throws IOException
Sets the binary file to be stored in this document

Parameters:
fileName - a fully qualified path and file name of a disk file to be read into this document
Throws:
IOException - if there's a problem loading the file

setDocument

public void setDocument(InputStream in)
                 throws IOException
Sets the binary file to be stored in this document

Parameters:
in - a stream from which the contents of the binary file may be read
Throws:
IOException - if there's a problem loading the file

writeToFile

public void writeToFile(String fileName)
                 throws IOException
Writes the binary file stored in this document to a disk file

Parameters:
fileName - a fully qualified path and file name of a disk file to write
Throws:
IOException - if there's a problem writing the file

writeToFile

public void writeToFile(File file)
                 throws IOException
Writes the binary file stored in this document to a disk file

Parameters:
file - a File object containing a reference to a disk file to be written to
Throws:
IOException - if there's a problem writing the file


Copyright © 2004-2012 The YAWL Foundation.