package Cases; import java.io.*; import java.io.File; import neustore.base.DBIndex;//because we create a object of index.java import neustore.base.LRUBuffer;//because we create an object of it public class Test_Content_Full { public static void main(String[] args)throws IOException { //all the pages will be stored under this file name String filename3="TESTFILE3"; File file= new File(filename3); if(file.delete()) { System.out.println("The old file with that name has been deleted"); } else { System.out.println("The file was not found"); } //'buf' is an object of XMLBuffer class. Passews 2 arguments 5=Buffer size and 120=page size in bytes XMLBuffer buf3= new XMLBuffer(5,120); //Creating an object of XMLContent class and passing the 'buf3'(buffer) , filename and boolean value 'true' (indicating a new file has to be created with the passed filename) //If we do not plan to create a new file for Structure index, then the Constructor of the XMLContent class should send 'false' to its super class //creating an object of XMLContent class to test its methods XMLContent XC=new XMLContent(buf3,filename3,1); //This code would append the content String s=new String("This is just a test file and the length of this statement should be atleast 120 characters.");//this is 91 in length and does not cause overflow DiskAddress addr=XC.insertContent(s); //System.out.println("length:"+s.length()); //appending this string will cause the overflow s=new String("This statemtn would certainly cause the content page to overflow");//this statement lenght is 64, that means the total length is 91+64=155 System.out.println("length:"+s.length()); DiskAddress addr1 = XC.insertContent(s); // DiskAddress da=new DiskAddress(10,1); ///assuming the content page id=10 and we are extracting from record number 1 i.e from the 1st byte System.out.println("Disk Address #1: "+ addr.toString()); System.out.println("Disk Address #2: "+ addr1.toString()); s=XC.getContent(addr1);//155 is the length to be extracted, so we are entracted the whole content System.out.println(s); //lets delete some content, so that page merge can be done int x=XC.deleteContent(addr1); s=XC.getContent(addr1); //should fail to retrieve. System.out.println(s); }//end of Main() method }//end of Test_Content_Full class