KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mckoi > database > global > StreamableObject


1 /**
2  * com.mckoi.database.global.StreamableObject 07 Sep 2002
3  *
4  * Mckoi SQL Database ( http://www.mckoi.com/database )
5  * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * Version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License Version 2 for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * Version 2 along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  *
20  * Change Log:
21  *
22  *
23  */

24
25 package com.mckoi.database.global;
26
27 /**
28  * An object that is streamable (such as a long binary object, or
29  * a long string object). This is passed between client and server and
30  * contains basic primitive information about the object it represents. The
31  * actual contents of the object itself must be obtained through other
32  * means (see com.mckoi.database.jdbc.DatabaseInterface).
33  *
34  * @author Tobias Downer
35  */

36
37 public final class StreamableObject {
38
39   /**
40    * The type of the object.
41    */

42   private byte type;
43   
44   /**
45    * The size of the object in bytes.
46    */

47   private long size;
48   
49   /**
50    * The identifier that identifies this object.
51    */

52   private long id;
53
54   /**
55    * Constructs the StreamableObject.
56    */

57   public StreamableObject(byte type, long size, long id) {
58     this.type = type;
59     this.size = size;
60     this.id = id;
61   }
62   
63   /**
64    * Returns the type of object this stub represents. Returns 1 if it
65    * represents 2-byte unicde character object, 2 if it represents binary data.
66    */

67   public byte getType() {
68     return type;
69   }
70
71   /**
72    * Returns the size of the object stream, or -1 if the size is unknown. If
73    * this represents a unicode character string, you would calculate the total
74    * characters as size / 2.
75    */

76   public long getSize() {
77     return size;
78   }
79
80   /**
81    * Returns an identifier that can identify this object within some context.
82    * For example, if this is a streamable object on the client side, then the
83    * identifier might be the value that is able to retreive a section of the
84    * streamable object from the DatabaseInterface.
85    */

86   public long getIdentifier() {
87     return id;
88   }
89   
90 }
91
92
Popular Tags