FODBIndexHeader.java

00001 /*
00002  * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM)
00003  * Copyright (C) 2004-2006 Philippe Delrieu
00004  * All rights reserved.
00005  * Contact: pdelrieu@openmobileis.org
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00020  * USA
00021  *
00022  *  Author : Philippe Delrieu
00023  *  
00024  *  Modifications :
00025  *  2004 Creation P.Delrieu
00026  *  2004 Modified by Romain Beaugrand
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     // fields
00048     //---------------------
00049 //      private String name;
00050 //    private String memberName;
00051 //    public int type;
00052 //    public int  order;
00053  //   public int  keyLen;
00054 //    public int incTabSize;
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 }

Generated on Mon Dec 4 11:03:26 2006 for OpenMobileIS by  doxygen 1.5.1-p1