1 5 6 package jena; 7 8 import com.hp.hpl.jena.db.* ; 9 import com.hp.hpl.jena.rdf.model.* ; 10 import com.hp.hpl.jena.util.iterator.*; 11 12 13 27 28 public class dblist extends DBcmd 29 { 30 public static final String [] usage = new String [] 31 { 32 "dblist [--spec spec] | [db_description] [--model name]" , 33 " where db_description is" , 34 " --db JDBC URL --dbType type" , 35 " --dbUser user --dbPassword password" 36 } ; 37 38 39 40 public static void main(String [] args) 41 { 42 dblist db = new dblist(); 43 db.setUsage(usage) ; 44 db.init(args); 45 db.exec(); 46 } 47 48 public dblist() 49 { 50 super("dblist", false) ; 51 } 52 53 protected void exec0() 54 { 55 if ( getConnection().containsDefaultModel() ) 56 { 57 System.out.println("Model: <<default model>>") ; 58 properties(null) ; 59 } 60 61 ClosableIterator iter = getConnection().getAllModelNames() ; 62 try { 63 for ( ; iter.hasNext() ; ) 64 { 65 String name = (String )iter.next() ; 66 System.out.println("Model: "+name) ; 67 properties(name) ; 68 } 69 } 70 finally 71 { 72 iter.close() ; 73 } 74 75 } 76 77 protected boolean exec1(String arg) { return true ; } 78 79 private void properties(String name) 80 { 81 if ( true ) 82 return ; 83 ModelRDB m = ModelRDB.open(getConnection(), name) ; 84 Model props = m.getModelProperties() ; 85 props.setNsPrefix("db", "http://jena.hpl.hp.com/2003/04/DB#") ; 86 props.write(System.out, "N3") ; 87 props.close() ; 88 } 89 90 } 91 92 93 119 | Popular Tags |