* @return Value from field
* @throws IllegalArgumentException Some implementations may throw this.
* @throws NoSuchMethodException Some implementations may throw this.
+ * @throws java.lang.IllegalAccessException If the method cannot be accessed
+ * @throws java.lang.reflect.InvocationTargetException Any other problems?
*/
@Override
- public Object getValueFromColumn (final String columnName) throws IllegalArgumentException, NoSuchMethodException {
+ public Object getValueFromColumn (final String columnName) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
throw new UnsupportedOperationException(MessageFormat.format("Not implemented. columnName={0}", columnName)); //NOI18N
}
* @param targetClass Class name to look for
* @return Class instance
*/
- @SuppressWarnings ("unchecked")
+ @SuppressWarnings("unchecked")
private Class<? extends FrameworkInterface> getClassFromTarget (final FrameworkInterface instance, final String targetClass) {
// Trace message
this.getLogger().debug(MessageFormat.format("instance={0},targetClass={1}", instance, targetClass)); //NOI18N
-
+
// Instance reflaction of this class
Class<? extends FrameworkInterface> c = instance.getClass();
-
+
// Analyze class
while (!targetClass.equals(c.getSimpleName())) {
// Debug message
this.getLogger().debug(MessageFormat.format("c={0}", c.getSimpleName())); //NOI18N
-
+
// Get super class (causes unchecked warning)
c = (Class<? extends FrameworkInterface>) c.getSuperclass();
}
// Trace message
this.getLogger().trace(MessageFormat.format("c={0} - EXIT!", c)); //NOI18N
-
+
// Return it
return c;
}
protected final void abortProgramWithException (final Throwable throwable) {
// Log exception ...
this.getLogger().catching(throwable);
-
+
// .. and exit
System.exit(1);
}
* @param bool Boolean value
* @return Whether all conditions are met
* @throws NoSuchMethodException May be thrown by some implementations
+ * @throws java.lang.IllegalAccessException If the method cannot be accessed
+ * @throws java.lang.reflect.InvocationTargetException Any other problems?
*/
@Override
- public boolean isValueEqual (final String columnName, final boolean bool) throws NoSuchMethodException {
+ public boolean isValueEqual (final String columnName, final boolean bool) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
// Not implemented
throw new UnsupportedOperationException(MessageFormat.format("Not implemented. columnName={0},bool={1}", columnName, bool)); //NOI18N
}
// Init default values:
// Default database backend
BaseFrameworkSystem.properties.put("org.mxchange.database.backend.class", "org.mxchange.jcore.database.backend.base64.Base64CsvDatabaseBackend"); //NOI18N
- BaseFrameworkSystem.properties.put("database.backend.storagepath", "data");
+ BaseFrameworkSystem.properties.put("database.backend.storagepath", "data/"); //NOI18N
// For MySQL backend
BaseFrameworkSystem.properties.put("org.mxchange.database.mysql.host", "localhost"); //NOI18N
protected Object getField (final FrameworkInterface instance, final String targetClass, final String methodName) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
// Trace messahe
this.getLogger().trace(MessageFormat.format("targetClass={0},methodName={1}", targetClass, methodName)); //NOI18N
-
+
// Get method to call
Method method = this.getMethodFromName(instance, targetClass, methodName);
-
+
// Get value from field
Object object = method.invoke(instance);
protected Object convertNullToEmpty (final Object str) {
// Trace message
this.getLogger().trace(MessageFormat.format("str={0}", str)); //NOI18N
-
+
// Is it null?
if (str == null) {
// Return empty string
// Trace message
this.getLogger().trace(MessageFormat.format("str={0} - EXIT!", str)); //NOI18N
-
+
// Return it
return str;
}
* @param className Class name to iterate over
* @return An iterator over all object's fields
* @throws java.lang.NoSuchMethodException If the called method does not exist
+ * @throws java.lang.IllegalAccessException If the method cannot be accessed
+ * @throws java.lang.reflect.InvocationTargetException Any other problems?
*/
- protected Iterator<Map.Entry<Field, Object>> fieldIterator (final FrameworkInterface instance, final String className) throws IllegalArgumentException, NoSuchMethodException {
+ protected Iterator<Map.Entry<Field, Object>> fieldIterator (final FrameworkInterface instance, final String className) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
// Trace message
this.getLogger().trace(MessageFormat.format("instance={0},className={1} - CALLED!", instance, className)); //NOI18N
}
// Debug message
- this.getLogger().debug(MessageFormat.format("Calling getValueFromColumn({0}) on instance {1} ...", field.getName(), instance));
+ this.getLogger().debug(MessageFormat.format("Calling getValueFromColumn({0}) on instance {1} ...", field.getName(), instance)); //NOI18N
// Get value from it
Object value = instance.getValueFromColumn(field.getName());
* Initializes i18n bundles
*/
protected void initBundle () {
+ // Trace message
+ this.getLogger().trace("CALLED!");
+
// Is the bundle set?
if (bundle instanceof ResourceBundle) {
// Is already set
// Set instance
bundle = ResourceBundle.getBundle(FrameworkInterface.I18N_BUNDLE_FILE); // NOI18N
+
+ // Trace message
+ this.getLogger().trace("EXIT!");
}
/**
* Prepares all properties, the file is written if it is not found
- *
+ *
* @throws java.io.IOException If any IO problem occurs
*/
protected void initProperties () throws IOException {
*/
protected void setProperty (final String key, final String value) {
// Trace message
- this.getLogger().trace(MessageFormat.format("key={0},value={1} - CALLED!", key, value));
+ this.getLogger().trace(MessageFormat.format("key={0},value={1} - CALLED!", key, value)); //NOI18N
+
+ // Both should not be null
+ if (key == null) {
+ // key is null
+ throw new NullPointerException("key is null");
+ } else if (value == null) {
+ // value is null
+ throw new NullPointerException("value is null");
+ }
// Set it
- properties.setProperty(String.format("org.mxchange.%s", key), value);
+ properties.setProperty(String.format("org.mxchange.%s", key), value); //NOI18N
// Trace message
- this.getLogger().trace("EXIT!");
+ this.getLogger().trace("EXIT!"); //NOI18N
}
/**
protected String[] getPropertyNames () {
// Init array
String[] names = {
- "database.backend.class",
- "database.backend.storagepath",
- "database.mysql.login",
- "database.mysql.host",
- "database.mysql.password",
- "database.mysql.dbname",
+ "database.backend.class", //NOI18N
+ "database.backend.storagepath", //NOI18N
+ "database.mysql.login", //NOI18N
+ "database.mysql.host", //NOI18N
+ "database.mysql.password", //NOI18N
+ "database.mysql.dbname", //NOI18N
};
// Return it