00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 package org.openmobileis.database.fastobjectdb.db.index;
00030
00031 import java.io.*;
00032
00033 import org.openmobileis.database.fastobjectdb.FODBIndexDescriptor;
00034
00042 public class FODBIndexHeader implements Externalizable
00043 {
00044 static final long serialVersionUID = 3138616672520914061L;
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 public long pos;
00056 public long rootPtr;
00057 public FODBIndexDescriptor descriptor;
00058
00059 public FODBIndexHeader() {
00060 }
00061
00062 public FODBIndexHeader(FODBIndexDescriptor descriptor) {
00063 this.descriptor = descriptor;
00064 }
00065
00066 public String getName() {
00067 return this.descriptor.getName();
00068 }
00069
00070 public String getMemberName() {
00071 return this.descriptor.getMemberName();
00072 }
00073
00074 public void writeExternal(ObjectOutput out) throws IOException {
00075 out.writeChars(this.descriptor.getClass().getName());
00076 out.writeChar('\0');
00077 this.descriptor.writeExternal(out);
00078 out.writeLong(pos);
00079 out.writeLong(rootPtr);
00080 }
00081
00082 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
00083 char parseChar;
00084
00085 StringBuffer tmpName = new StringBuffer();
00086 while ((parseChar = in.readChar()) != '\0') {
00087 tmpName.append(parseChar);
00088 }
00089 try {
00090 this.descriptor = (FODBIndexDescriptor)Class.forName(tmpName.toString()).newInstance();
00091 this.descriptor.readExternal(in);
00092 } catch (Throwable ex) {
00093 throw new ClassNotFoundException(ex.getMessage());
00094 }
00095 pos = in.readLong();
00096 rootPtr = in.readLong();
00097 }
00098 }