1 23 24 package org.objectweb.medor.datasource.lib; 25 26 import org.objectweb.medor.api.DataSourceException; 27 import org.objectweb.medor.datasource.api.DataStore; 28 29 public class BasicDataStore implements DataStore { 30 31 String sourceName; 32 String clientName; 33 short[] capabilities; 34 short type; 35 36 39 public BasicDataStore(short dataStoreType, 40 String sourceName, 41 short[] capabilities) 42 throws DataSourceException { 43 this.sourceName = sourceName; 44 this.capabilities = capabilities; 45 if (dataStoreType != DataStore.JDBC_STORE && 46 dataStoreType != DataStore.MEDORTC_STORE) 47 throw new DataSourceException("DataStore type not supported"); 48 this.type = dataStoreType; 49 } 50 51 54 public BasicDataStore(short dataStoreType, String sourceName) 55 throws DataSourceException { 56 this.sourceName = sourceName; 57 if (dataStoreType != DataStore.JDBC_STORE && 58 dataStoreType != DataStore.MEDORTC_STORE) 59 throw new DataSourceException("DataStore type not supported"); 60 this.type = dataStoreType; 61 } 62 63 public String getName() { 64 return sourceName; 65 } 66 67 71 public boolean isSameAs(DataStore ds) { 72 return ds.getName().equals(this.sourceName); 73 } 74 75 public boolean isCapable(short operation) { 76 if (capabilities == null) 77 return true; else { 79 int cpt; 80 for (cpt = 0; (cpt < capabilities.length && 81 capabilities[cpt] != operation); cpt++) ; 82 if (cpt == capabilities.length) 83 return false; 84 else 85 return true; 86 } 87 } 88 89 public short getDataStoreType() { 90 return type; 91 } 92 93 public String getClientName() { 94 return clientName; 95 } 96 97 public void setClientName(String cName) { 98 clientName = cName; 99 } 100 } 101 | Popular Tags |