KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > YapConst


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;
22
23
24 /**
25  * @exclude
26  */

27 public final class YapConst
28 {
29     static final Object JavaDoc initMe = init();
30
31     public static final byte YAPFILEVERSION = 4;
32
33     public static final byte YAPBEGIN = (byte)'{';
34     public static final byte YAPFILE = (byte)'Y';
35     static final byte YAPID = (byte)'#';
36     static final byte YAPPOINTER = (byte)'>';
37     public static final byte YAPCLASSCOLLECTION = (byte)'A';
38     public static final byte YAPCLASS = (byte)'C';
39     static final byte YAPFIELD = (byte)'F';
40     public static final byte YAPOBJECT = (byte)'O';
41     static final byte YAPARRAY = (byte)'N';
42     static final byte YAPARRAYN = (byte)'Z';
43     public static final byte YAPINDEX = (byte)'X';
44     public static final byte YAPSTRING = (byte)'S';
45     static final byte YAPLONG = (byte)'l';
46     static final byte YAPINTEGER = (byte)'i';
47     static final byte YAPBOOLEAN = (byte)'=';
48     static final byte YAPDOUBLE = (byte)'d';
49     static final byte YAPBYTE = (byte)'b';
50     static final byte YAPSHORT = (byte)'s';
51     static final byte YAPCHAR = (byte)'c';
52     static final byte YAPFLOAT = (byte)'f';
53     static final byte YAPEND = (byte)'}';
54     static final byte YAPNULL = (byte)'0';
55     public static final byte BTREE = (byte)'T';
56     public static final byte BTREE_NODE = (byte)'B';
57     public static final byte HEADER = (byte)'H';
58     
59     static final int IDENTIFIER_LENGTH = (Deploy.debug && Deploy.identifiers)?1:0;
60     public static final int BRACKETS_BYTES = (Deploy.debug && Deploy.brackets)?1:0;
61     static final int BRACKETS_LENGTH = BRACKETS_BYTES * 2;
62
63     public static final int LEADING_LENGTH = IDENTIFIER_LENGTH + BRACKETS_BYTES;
64     public static final int ADDED_LENGTH = IDENTIFIER_LENGTH + BRACKETS_LENGTH;
65
66     static final int SHORT_BYTES = 2;
67     static final int INTEGER_BYTES = (Deploy.debug && Deploy.debugLong)?11:4;
68     static final int LONG_BYTES = (Deploy.debug && Deploy.debugLong)?20:8;
69     static final int CHAR_BYTES = 2;
70
71     static final int UNSPECIFIED = Integer.MIN_VALUE + 100; // make sure we don't fall over the -1 cliff
72

73     public static final int INT_LENGTH = INTEGER_BYTES + ADDED_LENGTH;
74     public static final int ID_LENGTH = INT_LENGTH;
75     public static final int LONG_LENGTH = LONG_BYTES + ADDED_LENGTH;
76     
77     static final int WRITE_LOOP = (INTEGER_BYTES - 1) * 8;
78     
79     public static final int OBJECT_LENGTH = ADDED_LENGTH;
80
81     public static final int POINTER_LENGTH = (INT_LENGTH * 2) + ADDED_LENGTH;
82     
83     public static final int MESSAGE_LENGTH = INT_LENGTH * 2 + 1;
84     
85     public static final byte SYSTEM_TRANS = (byte)'s';
86     public static final byte USER_TRANS = (byte)'u';
87     
88     // debug constants
89
static final byte XBYTE = (byte)'X';
90     
91     // TODO: This one is a terrible low-frequency blunder in YapArray.writeClass!!!
92
// If YapClass-ID == 99999 (not very likely) then we will get IGNORE_ID. Change
93
// to -Integer.MAX_VALUE or protect 99999 in YapFile.getPointerSlot()
94
public static final int IGNORE_ID = -99999;
95     
96     // This is a hard coded 2 Gig-Limit for YapClass-IDs.
97
// TODO: get rid of magic numbers like this one
98
static final int PRIMITIVE = -2000000000;
99     
100     // optimized type information
101
static final int TYPE_SIMPLE = 1;
102     static final int TYPE_CLASS = 2;
103     static final int TYPE_ARRAY = 3;
104     static final int TYPE_NARRAY = 4;
105     
106     // message levels
107
static final int NONE = 0; // Use if > NONE: normal messages
108
static final int STATE = 1; // if > STATE: state messages
109
static final int ACTIVATION = 2; // if > ACTIVATION: activation messages
110

111     static final int TRANSIENT = -1;
112     static final int ADD_MEMBERS_TO_ID_TREE_ONLY = 0;
113     static final int ADD_TO_ID_TREE = 1;
114     
115     // String Encoding
116
static final byte ISO8859 = (byte)1;
117     static final byte UNICODE = (byte)2;
118
119     // Timings
120
public static final int LOCK_TIME_INTERVAL = 1000;
121     static final int SERVER_SOCKET_TIMEOUT = Debug.longTimeOuts ? 1000000: 5000; // jump out of the loop every 5 seconds
122
static final int CLIENT_SOCKET_TIMEOUT = 300000; // 5 minutes response time at the client side
123
static final int CONNECTION_TIMEOUT = Debug.longTimeOuts ? 1000000: 180000; // 1 minute until we start pinging dead or blocking clients
124

125     // TODO: Consider to make configurable
126
public static final int MAXIMUM_BLOCK_SIZE = 70000000; // 70 MB
127
static final int MAXIMUM_ARRAY_ENTRIES = 7000000; // 7 Million
128
static final int MAXIMUM_ARRAY_ENTRIES_PRIMITIVE = MAXIMUM_ARRAY_ENTRIES * 100; // 70 MB for byte arrays
129

130     static Class JavaDoc CLASS_COMPARE;
131     static Class JavaDoc CLASS_DB4OTYPE;
132     static Class JavaDoc CLASS_DB4OTYPEIMPL;
133     static Class JavaDoc CLASS_INTERNAL;
134     static Class JavaDoc CLASS_UNVERSIONED;
135     public static Class JavaDoc CLASS_OBJECT;
136     static Class JavaDoc CLASS_OBJECTCONTAINER;
137     static Class JavaDoc CLASS_REPLICATIONRECORD;
138     static Class JavaDoc CLASS_STATICFIELD;
139     static Class JavaDoc CLASS_STATICCLASS;
140     static Class JavaDoc CLASS_TRANSIENTCLASS;
141     
142     public static final String JavaDoc EMBEDDED_CLIENT_USER = "embedded client";
143     
144     // bits in YapMeta.i_state
145
// and reuse in other classes
146
static final int CLEAN = 0;
147     static final int ACTIVE = 1;
148     static final int PROCESSING = 2;
149     static final int CACHED_DIRTY = 3;
150     static final int CONTINUE = 4;
151     static final int STATIC_FIELDS_STORED = 5;
152     static final int CHECKED_CHANGES = 6;
153     static final int DEAD = 7;
154     static final int READING = 8;
155     
156     static final int UNCHECKED = 0;
157     
158     // Universal speaking variables.
159
public static final int NO = -1;
160     public static final int YES = 1;
161     public static final int DEFAULT = 0;
162     public static final int UNKNOWN = 0;
163     
164     public static final int OLD = -1;
165     public static final int NEW = 1;
166
167     
168     public static final YapStringIOUnicode stringIO = new YapStringIOUnicode();
169     
170     private static final Object JavaDoc init(){
171         CLASS_OBJECT = new Object JavaDoc().getClass();
172         CLASS_COMPARE = com.db4o.config.Compare.class;
173         CLASS_DB4OTYPE = com.db4o.types.Db4oType.class;
174         CLASS_DB4OTYPEIMPL = Db4oTypeImpl.class;
175         CLASS_INTERNAL = Internal4.class;
176         CLASS_UNVERSIONED = com.db4o.types.Unversioned.class;
177         CLASS_OBJECTCONTAINER = ObjectContainer.class;
178         CLASS_REPLICATIONRECORD = new ReplicationRecord().getClass();
179         CLASS_STATICFIELD = new StaticField().getClass();
180         CLASS_STATICCLASS = new StaticClass().getClass();
181         CLASS_TRANSIENTCLASS = com.db4o.types.TransientClass.class;
182         
183         return null;
184     }
185     
186     // system classes that need to get loaded first
187
static final Class JavaDoc[] ESSENTIAL_CLASSES = {
188     // StaticClass should load Staticfield
189

190     // TODO: remove unnecessary
191

192         CLASS_STATICFIELD,
193         CLASS_STATICCLASS
194     };
195     
196     public static final String JavaDoc VIRTUAL_FIELD_PREFIX = "v4o";
197     
198     public static final int MAX_STACK_DEPTH = 20;
199
200
201 }
202
Popular Tags