KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > header > FileHeaderVariablePart1


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.header;
22
23 import com.db4o.*;
24 import com.db4o.ext.*;
25 import com.db4o.inside.*;
26
27
28 /**
29  * @exclude
30  */

31 public class FileHeaderVariablePart1 extends YapMeta{
32     
33     // The variable part format is:
34

35     // (int) converter version
36
// (byte) freespace system used
37
// (int) freespace address
38
// (int) identity ID
39
// (long) versionGenerator
40
// (int) uuid index ID
41

42     private static final int LENGTH = 1 + (YapConst.INT_LENGTH * 4) + YapConst.LONG_LENGTH + YapConst.ADDED_LENGTH;
43     
44     private final SystemData _systemData;
45     
46     public FileHeaderVariablePart1(int id, SystemData systemData) {
47         setID(id);
48         _systemData = systemData;
49     }
50     
51     SystemData systemData() {
52         return _systemData;
53     }
54
55     public byte getIdentifier() {
56         return YapConst.HEADER;
57     }
58
59     public int ownLength() {
60         return LENGTH;
61     }
62
63     public void readThis(Transaction trans, YapReader reader) {
64         _systemData.converterVersion(reader.readInt());
65         _systemData.freespaceSystem(reader.readByte());
66         _systemData.freespaceAddress(reader.readInt());
67         readIdentity(trans, reader.readInt());
68         _systemData.lastTimeStampID(reader.readLong());
69         _systemData.uuidIndexId(reader.readInt());
70     }
71
72     public void writeThis(Transaction trans, YapReader writer) {
73         writer.writeInt(_systemData.converterVersion());
74         writer.append(_systemData.freespaceSystem());
75         writer.writeInt(_systemData.freespaceAddress());
76         writer.writeInt(_systemData.identity().getID(trans));
77         writer.writeLong(_systemData.lastTimeStampID());
78         writer.writeInt(_systemData.uuidIndexId());
79     }
80     
81     private void readIdentity(Transaction trans, int identityID) {
82         YapFile file = trans.i_file;
83         Db4oDatabase identity = (Db4oDatabase) file.getByID1(trans, identityID);
84         file.activate1(trans, identity, 2);
85         _systemData.identity(identity);
86     }
87
88 }
89
Popular Tags