Renamed some of the database methods.
This commit is contained in:
parent
c1c00648d9
commit
c44e432aa3
|
@ -62,7 +62,7 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public T selectObject(String key) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException, ClassNotFoundException {
|
public T loadObject(String key) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException, ClassNotFoundException {
|
||||||
YamlConfiguration config = databaseConnecter.loadYamlFile(type.getSimpleName(), key);
|
YamlConfiguration config = databaseConnecter.loadYamlFile(type.getSimpleName(), key);
|
||||||
return createObject(config);
|
return createObject(config);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<T> selectObjects() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException, ClassNotFoundException {
|
public List<T> loadObjects() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException, ClassNotFoundException {
|
||||||
List<T> list = new ArrayList<T>();
|
List<T> list = new ArrayList<T>();
|
||||||
FilenameFilter ymlFilter = new FilenameFilter() {
|
FilenameFilter ymlFilter = new FilenameFilter() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -201,7 +201,7 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void insertObject(T instance) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException {
|
public void saveObject(T instance) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException {
|
||||||
// This is the Yaml Configuration that will be used and saved at the end
|
// This is the Yaml Configuration that will be used and saved at the end
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
// The file name of the Yaml file.
|
// The file name of the Yaml file.
|
||||||
|
|
|
@ -110,7 +110,7 @@ public abstract class AbstractDatabaseHandler<T> {
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
protected abstract List<T> selectObjects() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException, SQLException, SecurityException, ClassNotFoundException;
|
protected abstract List<T> loadObjects() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException, SQLException, SecurityException, ClassNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a <T> filled with values from the corresponding
|
* Creates a <T> filled with values from the corresponding
|
||||||
|
@ -126,10 +126,10 @@ public abstract class AbstractDatabaseHandler<T> {
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
* @throws SecurityException
|
* @throws SecurityException
|
||||||
*/
|
*/
|
||||||
protected abstract T selectObject(String uniqueId) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException, SQLException, SecurityException, ClassNotFoundException;
|
protected abstract T loadObject(String uniqueId) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException, SQLException, SecurityException, ClassNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts T into the corresponding database-table
|
* Save T into the corresponding database
|
||||||
*
|
*
|
||||||
* @param instance that should be inserted into the database
|
* @param instance that should be inserted into the database
|
||||||
* @throws IllegalAccessException
|
* @throws IllegalAccessException
|
||||||
|
@ -141,6 +141,6 @@ public abstract class AbstractDatabaseHandler<T> {
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
* @throws NoSuchMethodException
|
* @throws NoSuchMethodException
|
||||||
*/
|
*/
|
||||||
protected abstract void insertObject(T instance) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException, SQLException, SecurityException, InstantiationException, NoSuchMethodException;
|
protected abstract void saveObject(T instance) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException, SQLException, SecurityException, InstantiationException, NoSuchMethodException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class IslandsManager {
|
||||||
islandsByUUID.clear();
|
islandsByUUID.clear();
|
||||||
spawn = null;
|
spawn = null;
|
||||||
try {
|
try {
|
||||||
for (Object island : handler.selectObjects()) {
|
for (Object island : handler.loadObjects()) {
|
||||||
if (island instanceof Island) {
|
if (island instanceof Island) {
|
||||||
islands.put(((Island)island).getCenter(), (Island)island);
|
islands.put(((Island)island).getCenter(), (Island)island);
|
||||||
islandsByUUID.put(((Island)island).getOwner(), (Island)island);
|
islandsByUUID.put(((Island)island).getOwner(), (Island)island);
|
||||||
|
@ -76,7 +76,7 @@ public class IslandsManager {
|
||||||
public void run() {
|
public void run() {
|
||||||
for(Island island : islands.values()){
|
for(Island island : islands.values()){
|
||||||
try {
|
try {
|
||||||
handler.insertObject(island);
|
handler.saveObject(island);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -87,7 +87,7 @@ public class IslandsManager {
|
||||||
} else {
|
} else {
|
||||||
for(Island island : islands.values()){
|
for(Island island : islands.values()){
|
||||||
try {
|
try {
|
||||||
handler.insertObject(island);
|
handler.saveObject(island);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -41,11 +41,11 @@ public class RunTest {
|
||||||
BSBDatabase database = BSBDatabase.getDatabase();
|
BSBDatabase database = BSBDatabase.getDatabase();
|
||||||
AbstractDatabaseHandler<Island> handler = (AbstractDatabaseHandler<Island>) database.getHandler(plugin, Island.class);
|
AbstractDatabaseHandler<Island> handler = (AbstractDatabaseHandler<Island>) database.getHandler(plugin, Island.class);
|
||||||
|
|
||||||
handler.insertObject(test);
|
handler.saveObject(test);
|
||||||
|
|
||||||
plugin.getLogger().info("DEBUG: ALL WRITTEN! Now reading...");
|
plugin.getLogger().info("DEBUG: ALL WRITTEN! Now reading...");
|
||||||
|
|
||||||
test = handler.selectObject(test.getUniqueId());
|
test = handler.loadObject(test.getUniqueId());
|
||||||
|
|
||||||
plugin.getLogger().info("DEBUG: name = " + test.getName());
|
plugin.getLogger().info("DEBUG: name = " + test.getName());
|
||||||
plugin.getLogger().info("DEBUG: owner = " + test.getOwner());
|
plugin.getLogger().info("DEBUG: owner = " + test.getOwner());
|
||||||
|
|
|
@ -310,7 +310,7 @@ public class MySQLDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||||
* @see us.tastybento.bskyblock.database.managers.AbstractDatabaseHandler#insertObject(java.lang.Object)
|
* @see us.tastybento.bskyblock.database.managers.AbstractDatabaseHandler#insertObject(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void insertObject(T instance) throws SQLException,
|
public void saveObject(T instance) throws SQLException,
|
||||||
SecurityException, IllegalArgumentException,
|
SecurityException, IllegalArgumentException,
|
||||||
InstantiationException, IllegalAccessException,
|
InstantiationException, IllegalAccessException,
|
||||||
IntrospectionException, InvocationTargetException, NoSuchMethodException {
|
IntrospectionException, InvocationTargetException, NoSuchMethodException {
|
||||||
|
@ -484,7 +484,7 @@ public class MySQLDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<T> selectObjects() throws SQLException,
|
public List<T> loadObjects() throws SQLException,
|
||||||
SecurityException, IllegalArgumentException,
|
SecurityException, IllegalArgumentException,
|
||||||
InstantiationException, IllegalAccessException,
|
InstantiationException, IllegalAccessException,
|
||||||
IntrospectionException, InvocationTargetException, ClassNotFoundException {
|
IntrospectionException, InvocationTargetException, ClassNotFoundException {
|
||||||
|
@ -511,7 +511,7 @@ public class MySQLDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||||
* @see us.tastybento.bskyblock.database.managers.AbstractDatabaseHandler#selectObject(java.lang.String)
|
* @see us.tastybento.bskyblock.database.managers.AbstractDatabaseHandler#selectObject(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected T selectObject(String uniqueId) throws InstantiationException,
|
protected T loadObject(String uniqueId) throws InstantiationException,
|
||||||
IllegalAccessException, IllegalArgumentException,
|
IllegalAccessException, IllegalArgumentException,
|
||||||
InvocationTargetException, IntrospectionException, SQLException, SecurityException, ClassNotFoundException {
|
InvocationTargetException, IntrospectionException, SQLException, SecurityException, ClassNotFoundException {
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
|
|
Loading…
Reference in New Issue