KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > types > Blob


1 /* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com
2
3 This file is part of the db4o open source object database.
4
5 db4o is free software; you can redistribute it and/or modify it under
6 the terms of version 2 of the GNU General Public License as published
7 by the Free Software Foundation and as clarified by db4objects' GPL
8 interpretation policy, available at
9 http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10 Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11 Suite 350, San Mateo, CA 94403, USA.
12
13 db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

21 package com.db4o.types;
22
23 import java.io.*;
24
25 /**
26  * the db4o Blob type to store blobs independant of the main database
27  * file and allows to perform asynchronous upload and download operations.
28  * <br><br>
29  * <b>Usage:</b><br>
30  * - Define Blob fields on your user classes.<br>
31  * - As soon as an object of your class is stored, db4o automatically
32  * takes care that the Blob field is set.<br>
33  * - Call readFrom to read a blob file into the db4o system.<br>
34  * - Call writeTo to write a blob file from within the db4o system.<br>
35  * - getStatus may help you to determine, whether data has been
36  * previously stored. It may also help you to track the completion
37  * of the current process.
38  * <br><br>
39  * db4o client/server carries out all blob operations in a seperate
40  * thread on a specially dedicated socket. One socket is used for
41  * all blob operations and operations are queued. Your application
42  * may continue to access db4o while a blob is transferred in the
43  * background.
44  */

45 public interface Blob extends Db4oType {
46
47     /**
48      * returns the name of the file the blob was stored to.
49      * <br><br>The method may return null, if the file was never
50      * stored.
51      * @return String the name of the file.
52      */

53     public String JavaDoc getFileName();
54
55     /**
56      * returns the status after the last read- or write-operation.
57      * <br><br>The status value returned may be any of the following:<br>
58      * Status.UNUSED no data was ever stored to the Blob field.<br>
59      * Status.AVAILABLE available data was previously stored to the Blob field.<br>
60      * Status.QUEUED an operation was triggered and is waiting for it's turn in the Blob queue.<br>
61      * Status.COMPLETED the last operation on this field was completed successfully.<br>
62      * Status.PROCESSING for internal use only.<br>
63      * Status.ERROR the last operation failed.<br>
64      * or a double between 0 and 1 that signifies the current completion percentage of the currently
65      * running operation.<br><br> the five STATUS constants defined in this interface or a double
66      * between 0 and 1 that signifies the completion of the currently running operation.<br><br>
67      * @return status - the current status
68      * @see com.db4o.ext.Status STATUS constants
69      */

70     public double getStatus();
71
72     /**
73      * reads a file into the db4o system and stores it as a blob.
74      * <br><br>
75      * In Client/Server mode db4o will open an additional socket and
76      * process writing data in an additional thread.
77      * <br><br>
78      * @param file the file the blob is to be read from.
79      * @throws IOException in case of errors
80      */

81     public void readFrom(File file) throws IOException;
82
83     /**
84      * reads a file into the db4o system and stores it as a blob.
85      * <br><br>
86      * db4o will use the local file system in Client/Server mode also.
87      * <br><br>
88      * @param file the file the blob is to be read from.
89      * @throws IOException in case of errors
90      */

91     public void readLocal(File file) throws IOException;
92
93     /**
94      * writes stored blob data to a file.
95      * <br><br>
96      * db4o will use the local file system in Client/Server mode also.
97      * <br><br>
98      * @throws IOException in case of errors and in case no blob
99      * data was stored
100      * @param file the file the blob is to be written to.
101      */

102     public void writeLocal(File file) throws IOException;
103
104     /**
105      * writes stored blob data to a file.
106      * <br><br>
107      * In Client/Server mode db4o will open an additional socket and
108      * process writing data in an additional thread.
109      * <br><br>
110      * @throws IOException in case of errors and in case no blob
111      * data was stored
112      * @param file the file the blob is to be written to.
113      */

114     public void writeTo(File file) throws IOException;
115
116 }
Popular Tags