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 //NOTE: These are just for testing, so the values do not make sense. // You can change the test file as you want, ex: the for loop can be run for 10000 times. //the XML buffer delaration can be added, if you want to use the one which takes in only the numpages. public class Testcase40 { public static void main(String[] args)throws IOException { //all the pages will be stored under this file name String filename4="TESTFILE4"; File file= new File(filename4); if(file.delete()) { System.out.println("The old file with that name has been deleted"); } else { System.out.println("The file was not found"); } //'buf4' is an object of XMLBuffer class. Passes 2 arguments 5=Buffer size and 2048=page size in bytes XMLBuffer buf4= new XMLBuffer(5,2048); // Those who just pass numPages. uncomment this and comment the previous one /* XMLBuffer buf4= new XMLBuffer(5);*/ //Creating an object of AttributeIndex class and passing the 'buf4'(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 AttributeIndex, then the Constructor of the AttributeIndex class should send 'false' to its super class //creating an object of XMLContent class to test its methods AttributeIndex AI=new AttributeIndex(buf4,filename4,1); //create the record in structure index as we did before proceeding //insert an record in attribute index int y=AI.insertEntry(1,"x","123"); System.out.println("The exit code for inserting an entry is "+y); for(int i=2;i<800;i++) { //if an attribute name is more than 32bytes, then? these kind of situations can be handled by just considering the first 32bytes String name="x",value="123"; name = name+i; value=value+i; System.out.println("name="+name); System.out.println("value="+value); y=AI.insertEntry(i,name,value); System.out.println("The exit code for inserting an entry is "+y); } //The following code will try to get the attribute value of 'x' attribute for element occurence having nodeID=1 String av=AI.getValue(1,"x"); System.out.println("The attribute value for 'x' attribute is "+av); av=AI.getValue(1,"x900");//would return 'null' System.out.println("The attribute value for 'x' attribute is "+av); //delete the attribute "x" for nodeid=1 y=AI.deleteEntry(1,"x"); av=AI.getValue(1,"x"); System.out.println("The attribute value for 'x' attribute is "+av);//this sould not return anything as we delted this attribute. for(int i=60;i<450;i++) { //if an attribute name is more than 32bytes, then? these kind of situations can be handled by just considering the first 32bytes String name="x",value="123"; name = name+i; y=AI.deleteEntry(i,name); } //AI.close();//remove the comments if the file needs to be closed before exiting }//end of main() method }//end of TestCase40