Binary SQL encapsulation - By Tony
Swain. Dec 3/2013
public interface
DataBaseConstants
{
final static String
DEFAULT_RECORD =
"default.rec"; // Default-
// fileName
// The default record is
"Account"
//-- If you don't add any more record
types then then at least
// you have an account record
for basic login/authentication.
//
final static String
DEFAULT_RECORD_TYPE="account";
//
final static int MAX_RECORD_TYPES =
255;
//-- You can change this
final static int MAX_RECORDS
=
1024; //--
this will be set in preferences
// DataBase definition
bits
final static int DB_MONOLITHIC =
0x00000001; // Else segmented
// individual files
final static int DB_RAM_RECORD =
0x00000002; // Load Record into ram-
// buffer
final static int DB_FILE_JOURNAL =
0x00000004; // Journal all IO.
final static int DB_TIMESTAMP =
0x00000008; // include timestamp in
// output
final static int RECORD_JOINED =
0x00000010; //
final static int RECORD_BACKUP =
0x00000020; // save in concurrent file
final static int RECORD_TIMEOUT =
0x00000040; // record expires
//-- 8 bit Command/Query bits
final static int
GET
= 0x00000001;
final static int
PUT
= 0xfffffffe; // toggle get/putmask
final static int
ALL
= 0x00000002;
final static int
GT
= 0x00000004; // >
final static int
LT
= 0x00000008; // <
final static int
EQU
= 0x00000010; //
final static int
ORDER_BY1 =
0x00000020; // 0 name 1 date
final static int
ORDER_BY2 =
0x00000040; // 2 size 3 data type
// specific.
final static int EXTENDED_ENABLE = 0x00000080;
//(ie: resolution for an-
// image)
//-- 16 bit alternate commands set
// Bye using the RESERVED BIT we
could extend this to 32 bits.
//
final static int
JOIN
= 0x00000001; // Make cross record field
// relation
final static int SPLIT
= 0x00000002;
final static String DATA_SUFFIX = ".dat";
//------------------------------------------------------------------
// This is for branch index
block constructed from backing store.
// bit size of search index branch
table
// Basic command dispatch table is
256 bytes.
//------------------------------------------------------------------
final static int BRANCH_8 =
0x00000001; // 256 bytes 1 byte
index
final static int BRANCH_16 =
0x00000002; //
64K
2 byte 16 bit
final static int BRANCH_24 =
0x00000003; // 16
Meg 3 byte 24
final static int BRANCH_32 =
0x00000004; // 4
Gig 4 "
" 32
}
//---------- Hardware
MEMORY mode definitions.
//
// By Tony Swain. 2006 encode data type and
memory address mode.
//
//
public interface DataConstants
{
final static int EXTERNALIZER_BUFFER_SIZE =
512*1024;
final static int INTERNALIZER_BUFFER_SIZE =
512*1024; // For database
final static int PRIMITIVE_WIDTH[] =
{
1,2,2,4,4,8,16
};
//
// 2 bit for 8,16,32 or 64 bit
addressing/index mode.
//
public final static int
ENCRYPTION_ENA =
0x80;
//1 000 0000
public final static int ADDRESSING_MASK
=
0x60;
//0 110 0000
final static int
ADDRESS_SHIFT
= 5;
//
// These bits control the addressing mode.
// This means the address mode can be modified
for device specific tasks
//
//
public final static int BYTE_ADDRESSING
= 0x00; // 00 xxxx = 8 bit-
addressing
public final static int SHORT_ADDRESSING =
0x01; // 01 xxxx = 16 bit-
// addressing
public final static int
INT_ADDRESSING = 0x02; // 10 xxxx
= 32 bit-
// addressing
public final static int LONG_ADDRESSING
= 0x04; // 11 xxxx = 64 bit
// addressing
// Type/Addressing bits top 3 = address mode.
bottom 5 = type
public final static int
TYPE_MASK
=
0x1f;
// 0001 1111
public final static int
ADDRESS_MASK =
0xe0;
// 1110 0000
//
public final static int
BYTE
= 0;
public final static int
SHORT
= 1;
public final static int
CHAR
= 2;
public final static int
INT
= 3;
public final static int
LONG
= 4;
public final static int
FLOAT
= 5;
public final static int
DOUBLE
= 6;
public final static int
OBJECT
= 7;
//
public final static int
BYTE_ARRAY = 8;
public final static int
SHORT_ARRAY = 9;
public final static int
CHAR_ARRAY = 10;
public final static int
INT_ARRAY
= 11;
public final static int
LONG_ARRAY = 12;
public final static int
FLOAT_ARRAY = 13;
public final static int
DOUBLE_ARRAY = 14;
public final static int
OBJECT_ARRAY = 15;
//
public final static int
BYTE_2D_ARRAY = 16;
public final static int
SHORT_2D_ARRAY = 17;
public final static int
CHAR_2D_ARRAY = 18;
public final static int
INT_2D_ARRAY =
19;
public final static int
LONG_2D_ARRAY = 20;
public final static int
FLOAT_2D_ARRAY = 21;
public final static int
DOUBLE_2D_ARRAY = 22;
public final static int
OBJECT_2D_ARRAY = 23;
//
public final static int
BYTE_3D_ARRAY = 24;
public final static int
SHORT_3D_ARRAY = 25;
public final static int
CHAR_3D_ARRAY = 26;
public final static int
INT_3D_ARRAY =
27;
public final static int
LONG_3D_ARRAY = 28;
public final static int
FLOAT_3D_ARRAY = 29;
public final static int
DOUBLE_3D_ARRAY = 30;
public final static int
OBJECT_3D_ARRAY = 31;
final static int
TOTAL_TYPES
= 32;
final static int DEFAULT_BUFFER_SIZE =
0x0000ffff; // 64k tweak for your purpose.
//
final static String[] TYPE_STRING =
{
" byte "," short "," char "," int "," long ","
float "," double "," Object ",
" byte "," short "," char "," int "," long ","
float "," double "," Object ",
" byte "," short "," char "," int "," long ","
float "," double "," Object ",
" byte "," short "," char "," int "," long ","
float "," double "," Object
"
};