1 17 18 package org.apache.geronimo.console.internaldb; 19 20 import java.io.File ; 21 import java.util.Collection ; 22 import java.util.Vector ; 23 24 public class DBViewerHelper { 25 26 private static final String SYS_TBL_PREFIX = "SYS."; 27 28 private static final int COUNT_COL = 1; 29 30 36 public Collection getDerbyDatabases(String derbySysHome) { 37 Vector databases = new Vector (); 38 File f = new File (derbySysHome); 39 if (f.isDirectory()) { 41 File [] files = f.listFiles(); 43 for (int i = 0; i < files.length; i++) { 44 if (files[i].isDirectory()) { 45 databases.add(files[i].getName()); 46 } 47 } 48 } 49 50 return databases; 51 } 52 53 58 public boolean isDBValid(String derbySysHome, String dbName) { 59 if ((derbySysHome == null) || (derbySysHome.trim().length() == 0)) { 60 return false; 61 } 62 if ((dbName == null) || (dbName.trim().length() == 0)) { 63 return false; 64 } 65 66 Collection databases = getDerbyDatabases(derbySysHome); 67 return databases.contains(dbName); 68 } 69 70 75 public boolean isTblValid(String dbName, String tblName) { 76 if ((dbName == null) || (dbName.trim().length() == 0)) { 77 return false; 78 } 79 if ((tblName == null) || (tblName.trim().length() == 0)) { 80 return false; 81 } 82 return true; 83 84 132 } 133 134 } 135 | Popular Tags |