1 24 package org.objectweb.jalisto.se.storage.raf; 25 26 27 import org.objectweb.jalisto.se.api.JalistoProperties; 28 import org.objectweb.jalisto.se.impl.JalistoPropertiesImpl; 29 30 import java.io.PrintWriter ; 31 import java.util.*; 32 33 public class RecordsFileInspector { 34 public void inspectRecordsFile(PrintWriter out, RecordsFile rf) 35 throws Exception { 36 out.println("RecordsFile with " + rf.getNumRecords()); 37 out.println("keys :"); 38 39 Iterator iterator = rf.enumerateKeys(); 40 List keys = new LinkedList(); 41 while (iterator.hasNext()) { 42 String key = iterator.next().toString(); 43 keys.add(key); 44 } 45 Collections.sort(keys); 46 47 for (int i = 0; i < keys.size(); i++) { 48 String key = (String ) keys.get(i); 49 RecordReader reader = rf.readRecord(key); 50 Object o = reader.readObject(); 51 out.println(key + " : " + String.valueOf(o)); 52 reader.reset(); 53 } 54 } 55 56 public static void main(String [] args) { 57 try { 58 JalistoProperties prop; 59 60 if (args.length < 1) { 61 prop = new JalistoPropertiesImpl(""); 62 } else { 63 prop = new JalistoPropertiesImpl(args[0]); 64 } 65 66 RecordsFile rf = new RecordsFile(prop.getSystemDbFilePath(), "rw"); 67 rf.initExistingStorage(prop.getKeyLength(), prop.getAdditionalSpace()); 68 PrintWriter out = new PrintWriter (System.out); 69 (new RecordsFileInspector()).inspectRecordsFile(out, rf); 70 out.flush(); 71 } catch (Exception e) { 72 e.printStackTrace(); 73 } 74 } 75 } 76 | Popular Tags |