001: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
002:
003: This file is part of the db4o open source object database.
004:
005: db4o is free software; you can redistribute it and/or modify it under
006: the terms of version 2 of the GNU General Public License as published
007: by the Free Software Foundation and as clarified by db4objects' GPL
008: interpretation policy, available at
009: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011: Suite 350, San Mateo, CA 94403, USA.
012:
013: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014: WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: for more details.
017:
018: You should have received a copy of the GNU General Public License along
019: with this program; if not, write to the Free Software Foundation, Inc.,
020: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
021: package com.db4o.internal;
022:
023: import com.db4o.*;
024:
025: /**
026: * @exclude
027: *
028: * TODO: Split into separate enums with defined range and values.
029: */
030: public final class Const4 {
031: public static final byte YAPFILEVERSION = 4;
032:
033: public static final byte YAPBEGIN = (byte) '{';
034: public static final byte YAPFILE = (byte) 'Y';
035: public static final byte YAPID = (byte) '#';
036: public static final byte YAPPOINTER = (byte) '>';
037: public static final byte YAPCLASSCOLLECTION = (byte) 'A';
038: public static final byte YAPCLASS = (byte) 'C';
039: public static final byte YAPFIELD = (byte) 'F';
040: public static final byte YAPOBJECT = (byte) 'O';
041: public static final byte YAPARRAY = (byte) 'N';
042: public static final byte YAPARRAYN = (byte) 'Z';
043: public static final byte YAPINDEX = (byte) 'X';
044: public static final byte YAPSTRING = (byte) 'S';
045: public static final byte YAPLONG = (byte) 'l';
046: public static final byte YAPINTEGER = (byte) 'i';
047: public static final byte YAPBOOLEAN = (byte) '=';
048: public static final byte YAPDOUBLE = (byte) 'd';
049: public static final byte YAPBYTE = (byte) 'b';
050: public static final byte YAPSHORT = (byte) 's';
051: public static final byte YAPCHAR = (byte) 'c';
052: public static final byte YAPFLOAT = (byte) 'f';
053: public static final byte YAPEND = (byte) '}';
054: public static final byte YAPNULL = (byte) '0';
055: public static final byte BTREE = (byte) 'T';
056: public static final byte BTREE_NODE = (byte) 'B';
057: public static final byte HEADER = (byte) 'H';
058: public static final byte INTEGER_ARRAY = (byte) 'I';
059:
060: public static final int IDENTIFIER_LENGTH = (Deploy.debug && Deploy.identifiers) ? 1
061: : 0;
062: public static final int BRACKETS_BYTES = (Deploy.debug && Deploy.brackets) ? 1
063: : 0;
064: public static final int BRACKETS_LENGTH = BRACKETS_BYTES * 2;
065:
066: public static final int LEADING_LENGTH = IDENTIFIER_LENGTH
067: + BRACKETS_BYTES;
068: public static final int ADDED_LENGTH = IDENTIFIER_LENGTH
069: + BRACKETS_LENGTH;
070:
071: public static final int SHORT_BYTES = 2;
072: public static final int INTEGER_BYTES = (Deploy.debug && Deploy.debugLong) ? 11
073: : 4;
074: public static final int LONG_BYTES = (Deploy.debug && Deploy.debugLong) ? 20
075: : 8;
076: public static final int CHAR_BYTES = 2;
077:
078: public static final int UNSPECIFIED = Integer.MIN_VALUE + 100; // make sure we don't fall over the -1 cliff
079:
080: public static final int INT_LENGTH = INTEGER_BYTES + ADDED_LENGTH;
081: public static final int ID_LENGTH = INT_LENGTH;
082: public static final int LONG_LENGTH = LONG_BYTES + ADDED_LENGTH;
083:
084: public static final int WRITE_LOOP = (INTEGER_BYTES - 1) * 8;
085:
086: public static final int OBJECT_LENGTH = ADDED_LENGTH;
087:
088: public static final int POINTER_LENGTH = (INT_LENGTH * 2)
089: + ADDED_LENGTH;
090:
091: public static final int MESSAGE_LENGTH = INT_LENGTH * 2 + 1;
092:
093: public static final byte SYSTEM_TRANS = (byte) 's';
094: public static final byte USER_TRANS = (byte) 'u';
095:
096: // debug constants
097: public static final byte XBYTE = (byte) 'X';
098:
099: // TODO: This one is a terrible low-frequency blunder in YapArray.writeClass!!!
100: // If YapClass-ID == 99999 (not very likely) then we will get IGNORE_ID. Change
101: // to -Integer.MAX_VALUE or protect 99999 in YapFile.getPointerSlot()
102: public static final int IGNORE_ID = -99999;
103:
104: // This is a hard coded 2 Gig-Limit for YapClass-IDs.
105: // TODO: get rid of magic numbers like this one
106: public static final int PRIMITIVE = -2000000000;
107:
108: // array type information
109: public static final int TYPE_ARRAY = 3;
110: public static final int TYPE_NARRAY = 4;
111:
112: // message levels
113: public static final int NONE = 0; // Use if > NONE: normal messages
114: public static final int STATE = 1; // if > STATE: state messages
115: public static final int ACTIVATION = 2; // if > ACTIVATION: activation messages
116:
117: public static final int TRANSIENT = -1;
118: public static final int ADD_MEMBERS_TO_ID_TREE_ONLY = 0;
119: public static final int ADD_TO_ID_TREE = 1;
120:
121: // String Encoding
122: public static final byte ISO8859 = (byte) 1;
123: public static final byte UNICODE = (byte) 2;
124:
125: // Timings
126: public static final int LOCK_TIME_INTERVAL = 1000;
127:
128: // 10 minutes until clients are disconnected, (5 minutes until they get pinged)
129: public static final int SERVER_SOCKET_TIMEOUT = Debug.longTimeOuts ? 1000000
130: : 600000;
131: public static final int CLIENT_SOCKET_TIMEOUT = SERVER_SOCKET_TIMEOUT;
132:
133: // TODO: Consider to make configurable
134: public static final int MAXIMUM_BLOCK_SIZE = 70000000; // 70 MB
135: public static final int MAXIMUM_ARRAY_ENTRIES = 7000000; // 7 Million
136: public static final int MAXIMUM_ARRAY_ENTRIES_PRIMITIVE = MAXIMUM_ARRAY_ENTRIES * 100; // 70 MB for byte arrays
137:
138: public final static Class CLASS_COMPARE = com.db4o.config.Compare.class;
139: public final static Class CLASS_DB4OTYPE = com.db4o.types.Db4oType.class;
140: public final static Class CLASS_DB4OTYPEIMPL = Db4oTypeImpl.class;
141: public final static Class CLASS_INTERNAL = Internal4.class;
142: public final static Class CLASS_UNVERSIONED = com.db4o.types.Unversioned.class;
143: public final static Class CLASS_OBJECT = new Object().getClass();
144: public final static Class CLASS_OBJECTCONTAINER = ObjectContainer.class;
145: public final static Class CLASS_REPLICATIONRECORD = new ReplicationRecord()
146: .getClass();
147: public final static Class CLASS_STATICFIELD = new StaticField()
148: .getClass();
149: public final static Class CLASS_STATICCLASS = new StaticClass()
150: .getClass();
151: public final static Class CLASS_TRANSIENTCLASS = com.db4o.types.TransientClass.class;
152:
153: public static final String EMBEDDED_CLIENT_USER = "embedded client";
154:
155: // bits in YapMeta.i_state
156: // and reuse in other classes
157: public static final int CLEAN = 0;
158: public static final int ACTIVE = 1;
159: public static final int PROCESSING = 2;
160: public static final int CACHED_DIRTY = 3;
161: public static final int CONTINUE = 4;
162: public static final int STATIC_FIELDS_STORED = 5;
163: public static final int CHECKED_CHANGES = 6;
164: public static final int DEAD = 7;
165: public static final int READING = 8;
166:
167: public static final int OLD = -1;
168: public static final int NEW = 1;
169:
170: public static final UnicodeStringIO stringIO = new UnicodeStringIO();
171:
172: // system classes that need to get loaded first
173: public static final Class[] ESSENTIAL_CLASSES = {
174: // StaticClass should load Staticfield
175:
176: // TODO: remove unnecessary
177:
178: CLASS_STATICFIELD, CLASS_STATICCLASS };
179:
180: public static final String VIRTUAL_FIELD_PREFIX = "v4o";
181:
182: public static final int MAX_STACK_DEPTH = 20;
183:
184: }
|