]> git.mxchange.org Git - jcore.git/blob - src/org/mxchange/jcore/BaseFrameworkSystem.java
Data path is now configurable
[jcore.git] / src / org / mxchange / jcore / BaseFrameworkSystem.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.jcore;
18
19 import java.io.BufferedReader;
20 import java.io.FileInputStream;
21 import java.io.FileNotFoundException;
22 import java.io.IOException;
23 import java.io.InputStreamReader;
24 import java.io.PrintWriter;
25 import java.lang.reflect.Field;
26 import java.lang.reflect.InvocationTargetException;
27 import java.lang.reflect.Method;
28 import java.text.MessageFormat;
29 import java.util.Arrays;
30 import java.util.HashMap;
31 import java.util.Iterator;
32 import java.util.Map;
33 import java.util.Properties;
34 import java.util.ResourceBundle;
35 import java.util.StringTokenizer;
36 import org.apache.logging.log4j.LogManager;
37 import org.apache.logging.log4j.Logger;
38 import org.mxchange.jcore.application.Application;
39 import org.mxchange.jcore.client.Client;
40 import org.mxchange.jcore.contact.Contact;
41 import org.mxchange.jcore.database.backend.DatabaseBackend;
42 import org.mxchange.jcore.database.frontend.DatabaseFrontend;
43 import org.mxchange.jcore.manager.Manageable;
44
45 /**
46  * General class
47  *
48  * @author Roland Haeder
49  */
50 public class BaseFrameworkSystem implements FrameworkInterface {
51
52         /**
53          * Bundle instance
54          */
55         private static ResourceBundle bundle;
56
57         /**
58          * Instance for own properties
59          */
60         private static final Properties properties = new Properties(System.getProperties());
61
62         /**
63          * Self instance
64          */
65         private static FrameworkInterface selfInstance;
66
67         /**
68          * Class' logger
69          */
70         private final Logger LOG;
71
72         /**
73          * Application instance
74          */
75         private Application application;
76
77         /**
78          * Instance for database backend
79          */
80         private DatabaseBackend backend;
81
82         /**
83          * Client instance
84          */
85         private Client client;
86
87         /**
88          * Contact instance
89          */
90         private Contact contact;
91
92         /**
93          * Manager instance
94          */
95         private Manageable manager;
96
97         /**
98          * Name of used database table, handled over to backend
99          */
100         private String tableName;
101
102         /**
103          * DatabaseFrontend instance
104          */
105         private DatabaseFrontend wrapper;
106
107         /**
108          * Initialize object
109          */
110         {
111                 LOG = LogManager.getLogger(this);
112         }
113
114         /**
115          * No instances can be created of this class
116          */
117         protected BaseFrameworkSystem () {
118                 // Set own instance
119                 this.setSelfInstance();
120         }
121
122         /**
123          * Getter for this application
124          *
125          * @return Instance from this application
126          */
127         public static final FrameworkInterface getInstance () {
128                 // Return it
129                 return selfInstance;
130         }
131
132         /**
133          * Application instance
134          *
135          * @return the application
136          */
137         @Override
138         public final Application getApplication () {
139                 return this.application;
140         }
141
142         /**
143          * Getter for logger
144          *
145          * @return Logger
146          */
147         @Override
148         public final Logger getLogger () {
149                 return this.LOG;
150         }
151
152         /**
153          * Manager instance
154          *
155          * @return the contactManager
156          */
157         @Override
158         public final Manageable getManager () {
159                 return this.manager;
160         }
161
162         /**
163          * Getter for human-readable string from given key
164          *
165          * @param key Key to return
166          * @return Human-readable message
167          */
168         @Override
169         public final String getMessageStringFromKey (final String key) {
170                 // Return message
171                 return this.getBundle().getString(key);
172         }
173
174         /**
175          * Some "getter for a value from given column name. This name will be
176          * translated into a method name and then this method is called.
177          *
178          * @param columnName Column name
179          * @return Value from field
180          * @throws IllegalArgumentException Some implementations may throw this.
181          * @throws NoSuchMethodException Some implementations may throw this.
182          */
183         @Override
184         public Object getValueFromColumn (final String columnName) throws IllegalArgumentException, NoSuchMethodException {
185                 throw new UnsupportedOperationException(MessageFormat.format("Not implemented. columnName={0}", columnName)); //NOI18N
186         }
187
188         /**
189          * Some "getter" for target class instance from given name.
190          *
191          * @param instance Instance to iterate on
192          * @param targetClass Class name to look for
193          * @return Class instance
194          */
195         @SuppressWarnings ("unchecked")
196         private Class<? extends FrameworkInterface> getClassFromTarget (final FrameworkInterface instance, final String targetClass) {
197                 // Trace message
198                 this.getLogger().debug(MessageFormat.format("instance={0},targetClass={1}", instance, targetClass)); //NOI18N
199                 
200                 // Instance reflaction of this class
201                 Class<? extends FrameworkInterface> c = instance.getClass();
202                 
203                 // Analyze class
204                 while (!targetClass.equals(c.getSimpleName())) {
205                         // Debug message
206                         this.getLogger().debug(MessageFormat.format("c={0}", c.getSimpleName())); //NOI18N
207                         
208                         // Get super class (causes unchecked warning)
209                         c = (Class<? extends FrameworkInterface>) c.getSuperclass();
210                 }
211
212                 // Trace message
213                 this.getLogger().trace(MessageFormat.format("c={0} - EXIT!", c)); //NOI18N
214                 
215                 // Return it
216                 return c;
217         }
218
219         /**
220          * Some "getter" for a Method instance from given method name
221          *
222          * @param instance Actual instance to call
223          * @param targetClass Target class name
224          * @param methodName Method name
225          * @return A Method instance
226          */
227         private Method getMethodFromName (final FrameworkInterface instance, final String targetClass, final String methodName) throws NoSuchMethodException {
228                 // Trace messahe
229                 this.getLogger().trace(MessageFormat.format("targetClass={0},methodName={1}", targetClass, methodName)); //NOI18N
230
231                 // Get target class instance
232                 Class<? extends FrameworkInterface> c = this.getClassFromTarget(instance, targetClass);
233
234                 // Init field instance
235                 Method method = null;
236
237                 // Use reflection to get all attributes
238                 method = c.getDeclaredMethod(methodName, new Class<?>[0]);
239
240                 // Assert on field
241                 assert (method instanceof Method) : "method is not a Method instance"; //NOI18N
242
243                 // Trace message
244                 this.getLogger().trace(MessageFormat.format("method={0} - EXIT!", method)); //NOI18N
245
246                 // Return it
247                 return method;
248         }
249
250         /**
251          * Setter for self instance
252          */
253         private void setSelfInstance () {
254                 // Need to set it here
255                 selfInstance = this;
256         }
257
258         /**
259          * Aborts program with given exception
260          *
261          * @param throwable Any type of Throwable
262          */
263         protected final void abortProgramWithException (final Throwable throwable) {
264                 // Log exception ...
265                 this.getLogger().catching(throwable);
266                 
267                 // .. and exit
268                 System.exit(1);
269         }
270
271         /**
272          * Application instance
273          *
274          * @param application the application to set
275          */
276         protected final void setApplication (final Application application) {
277                 this.application = application;
278         }
279
280         /**
281          * Client instance
282          *
283          * @return the client
284          */
285         @Override
286         public final Client getClient () {
287                 return this.client;
288         }
289
290         /**
291          * Getter for bundle instance
292          *
293          * @return Resource bundle
294          */
295         protected final ResourceBundle getBundle () {
296                 return BaseFrameworkSystem.bundle;
297         }
298
299         /**
300          * Client instance
301          *
302          * @param client the client to set
303          */
304         protected final void setClient (final Client client) {
305                 this.client = client;
306         }
307
308         /**
309          * Name of used database table, handled over to backend
310          *
311          * @return the tableName
312          */
313         public final String getTableName () {
314                 return this.tableName;
315         }
316
317         /**
318          * Checks if given boolean field is available and set to same value
319          *
320          * @param columnName Column name to check
321          * @param bool Boolean value
322          * @return Whether all conditions are met
323          * @throws NoSuchMethodException May be thrown by some implementations
324          */
325         @Override
326         public boolean isValueEqual (final String columnName, final boolean bool) throws NoSuchMethodException {
327                 // Not implemented
328                 throw new UnsupportedOperationException(MessageFormat.format("Not implemented. columnName={0},bool={1}", columnName, bool)); //NOI18N
329         }
330
331         /**
332          * Log exception
333          *
334          * @param exception Exception to log
335          */
336         @Override
337         public final void logException (final Throwable exception) {
338                 // Log this exception
339                 this.getLogger().catching(exception);
340         }
341
342         /**
343          * Initializes properties with default values
344          */
345         private void initPropertiesWithDefault () {
346                 // Trace message
347                 this.getLogger().trace("CALLED!"); //NOI18N
348
349                 // Init default values:
350                 // Default database backend
351                 BaseFrameworkSystem.properties.put("org.mxchange.database.backend.class", "org.mxchange.jcore.database.backend.base64.Base64CsvDatabaseBackend"); //NOI18N
352                 BaseFrameworkSystem.properties.put("database.backend.storagepath", "data");
353
354                 // For MySQL backend
355                 BaseFrameworkSystem.properties.put("org.mxchange.database.mysql.host", "localhost"); //NOI18N
356                 BaseFrameworkSystem.properties.put("org.mxchange.database.mysql.dbname", "test"); //NOI18N
357                 BaseFrameworkSystem.properties.put("org.mxchange.database.mysql.login", ""); //NOI18N
358                 BaseFrameworkSystem.properties.put("org.mxchange.database.mysql.password", ""); //NOI18N
359
360                 // Trace message
361                 this.getLogger().trace("EXIT!"); //NOI18N
362         }
363
364         /**
365          * Writes the properties file to disk
366          */
367         private void writePropertiesFile () throws IOException {
368                 // Trace message
369                 this.getLogger().trace("CALLED!"); //NOI18N
370
371                 // Write it
372                 BaseFrameworkSystem.properties.store(new PrintWriter(FrameworkInterface.PROPERTIES_CONFIG_FILE), "This file is automatically generated. You may wish to alter it."); //NOI18N
373
374                 // Trace message
375                 this.getLogger().trace("EXIT!"); //NOI18N
376         }
377
378         /**
379          * Converts a column name like "foo_bar" to an attribute name like "fooBar"
380          *
381          * @param columnName Column name to convert
382          * @return Attribute name
383          */
384         protected String convertColumnNameToAttribute (final String columnName) {
385                 // Trace message
386                 this.getLogger().trace(MessageFormat.format("columnName={0} - CALLED!", columnName)); //NOI18N
387
388                 // First all lower case
389                 String lower = columnName.toLowerCase();
390
391                 // Then split on "_"
392                 StringTokenizer tokenizer = new StringTokenizer(lower, "_"); //NOI18N
393
394                 // Resulting string
395                 StringBuilder builder = new StringBuilder(tokenizer.countTokens());
396
397                 // Init counter
398                 int count = 0;
399
400                 // Walk through all
401                 while (tokenizer.hasMoreTokens()) {
402                         // Get token
403                         String token = tokenizer.nextToken();
404
405                         // Is later than first element?
406                         if (count > 0) {
407                                 // Make first character upper-case
408                                 char c = token.charAt(0);
409                                 token = String.valueOf(c).toUpperCase() + token.substring(1);
410                         }
411
412                         // Add token
413                         builder.append(token);
414
415                         // Increment counter
416                         count++;
417                 }
418
419                 // Trace message
420                 this.getLogger().trace(MessageFormat.format("builder={0} - EXIT!", builder)); //NOI18N
421
422                 // Return result
423                 return builder.toString();
424         }
425
426         /**
427          * Converts a column name like "foo_bar" to a method name like "getFooBar"
428          * for non-booleans and to "isFooBar" for boolean fields.
429          *
430          * @param columnName Column name to convert
431          * @param isBool Whether the parameter is boolean
432          * @return Attribute name
433          */
434         protected String convertColumnNameToGetterMethod (final String columnName, boolean isBool) {
435                 // Trace message
436                 this.getLogger().trace(MessageFormat.format("columnName={0} - CALLED!", columnName)); //NOI18N
437
438                 // Then split on "_"
439                 StringTokenizer tokenizer = new StringTokenizer(columnName, "_"); //NOI18N
440
441                 // Resulting string
442                 StringBuilder builder = new StringBuilder(tokenizer.countTokens());
443
444                 // Is it boolean?
445                 if (isBool) {
446                         // Append "is"
447                         builder.append("is"); //NOI18N
448                 } else {
449                         // Append "get"
450                         builder.append("get"); //NOI18N
451                 }
452
453                 // Walk through all
454                 while (tokenizer.hasMoreTokens()) {
455                         // Get token
456                         String token = tokenizer.nextToken();
457
458                         // Debug message
459                         this.getLogger().debug(MessageFormat.format("token={0}", token)); //NOI18N
460
461                         // Make it upper-case
462                         char c = token.charAt(0);
463                         token = String.valueOf(c).toUpperCase() + token.substring(1);
464
465                         // Add token
466                         builder.append(token);
467                 }
468
469                 // Trace message
470                 this.getLogger().trace(MessageFormat.format("builder={0} - EXIT!", builder)); //NOI18N
471
472                 // Return result
473                 return builder.toString();
474         }
475
476         /**
477          * Some "getter" for an array from given string and tokenizer
478          *
479          * @param str String to tokenize and get array from
480          * @param delimiter Delimiter
481          * @param size Size of array
482          * @return Array from tokenized string
483          * @todo Get rid of size parameter
484          */
485         protected String[] getArrayFromString (final String str, final String delimiter, final int size) {
486                 // Trace message
487                 this.getLogger().trace(MessageFormat.format("str={0},delimiter={1},size={2} - CALLED!", str, delimiter, size)); //NOI18N
488
489                 // Get tokenizer
490                 StringTokenizer tokenizer = new StringTokenizer(str, delimiter);
491
492                 // Init array and index
493                 String[] tokens = new String[size];
494                 int index = 0;
495
496                 // Run through all tokens
497                 while (tokenizer.hasMoreTokens()) {
498                         // Get current token and add it
499                         tokens[index] = tokenizer.nextToken();
500
501                         // Debug message
502                         this.getLogger().debug(MessageFormat.format("Token at index{0}: {1}", index, tokens[1])); //NOI18N
503
504                         // Increment index
505                         index++;
506                 }
507
508                 // Trace message
509                 this.getLogger().trace(MessageFormat.format("tokens({0})={1} - EXIT!", tokens.length, Arrays.toString(tokens))); //NOI18N
510
511                 // Return it
512                 return tokens;
513         }
514
515         /**
516          * Returns boolean field value from given method name by invoking it
517          *
518          * @param instance The instance to call
519          * @param targetClass Target class to look in
520          * @param methodName Method name to look for
521          * @return Boolean value from field
522          * @throws java.lang.NoSuchMethodException If the method was not found
523          * @throws java.lang.IllegalAccessException If the method cannot be accessed
524          * @throws java.lang.reflect.InvocationTargetException Some other problems?
525          */
526         protected boolean getBooleanField (final FrameworkInterface instance, final String targetClass, final String methodName) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
527                 // Trace messahe
528                 this.getLogger().trace(MessageFormat.format("targetClass={0},methodName={1}", targetClass, methodName)); //NOI18N
529
530                 // Get method instance
531                 Method method = this.getMethodFromName(instance, targetClass, methodName);
532
533                 // Get value from field
534                 Boolean value = false;
535
536                 // Try to get the value by invoking the method
537                 value = (Boolean) method.invoke(instance);
538
539                 // Return value
540                 return value;
541         }
542
543         /**
544          * Manager instance
545          *
546          * @param manager the manager instance to set
547          */
548         protected final void setContactManager (final Manageable manager) {
549                 this.manager = manager;
550         }
551
552         /**
553          * Returns any field value from given method name by invoking it
554          *
555          * @param instance The instance to call
556          * @param targetClass Target class to look in
557          * @param methodName Method name to look for
558          * @return Any value from field
559          * @throws java.lang.NoSuchMethodException If the method was not found
560          * @throws java.lang.IllegalAccessException If the method cannot be accessed
561          * @throws java.lang.reflect.InvocationTargetException Some other problems?
562          */
563         protected Object getField (final FrameworkInterface instance, final String targetClass, final String methodName) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
564                 // Trace messahe
565                 this.getLogger().trace(MessageFormat.format("targetClass={0},methodName={1}", targetClass, methodName)); //NOI18N
566                 
567                 // Get method to call
568                 Method method = this.getMethodFromName(instance, targetClass, methodName);
569                 
570                 // Get value from field
571                 Object object = method.invoke(instance);
572
573                 // Return value
574                 return object;
575         }
576
577         /**
578          * Getter for property which must exist
579          *
580          * @param key Key to get
581          * @return Propety value
582          */
583         protected final String getProperty (final String key) {
584                 return BaseFrameworkSystem.properties.getProperty(String.format("org.mxchange.%s", key)); //NOI18N
585         }
586
587         /**
588          * Name of used database table, handled over to backend
589          *
590          * @param tableName the tableName to set
591          */
592         protected final void setTableName (final String tableName) {
593                 this.tableName = tableName;
594         }
595
596         /**
597          * Converts null to empty string or leaves original string.
598          *
599          * @param str Any string
600          * @return Empty string if null or original string
601          */
602         protected Object convertNullToEmpty (final Object str) {
603                 // Trace message
604                 this.getLogger().trace(MessageFormat.format("str={0}", str)); //NOI18N
605                 
606                 // Is it null?
607                 if (str == null) {
608                         // Return empty string
609                         return ""; //NOI18N
610                 }
611
612                 // Trace message
613                 this.getLogger().trace(MessageFormat.format("str={0} - EXIT!", str)); //NOI18N
614                 
615                 // Return it
616                 return str;
617         }
618
619         /**
620          * Creates an iterator from given instance and class name.
621          *
622          * @param instance Instance to run getter calls on
623          * @param className Class name to iterate over
624          * @return An iterator over all object's fields
625          * @throws java.lang.NoSuchMethodException If the called method does not exist
626          */
627         protected Iterator<Map.Entry<Field, Object>> fieldIterator (final FrameworkInterface instance, final String className) throws IllegalArgumentException, NoSuchMethodException {
628                 // Trace message
629                 this.getLogger().trace(MessageFormat.format("instance={0},className={1} - CALLED!", instance, className)); //NOI18N
630
631                 // Get all attributes from given instance
632                 Field[] fields = this.getClassFromTarget(instance, className).getDeclaredFields();
633
634                 // Debug message
635                 this.getLogger().debug(MessageFormat.format("Found {0} fields.", fields.length)); //NOI18N
636
637                 // A simple map with K=fieldName and V=Value is fine
638                 Map<Field, Object> map = new HashMap<>(fields.length);
639
640                 // Walk through all
641                 for (final Field field : fields) {
642                         // Debug log
643                         this.getLogger().debug(MessageFormat.format("field={0}", field.getName())); //NOI18N
644
645                         // Does the field start with "$"?
646                         if (field.getName().startsWith("$")) { //NOI18N
647                                 // Debug message
648                                 this.getLogger().debug(MessageFormat.format("Skipping field={0} as it starts with a dollar character.", field.getName())); //NOI18N
649
650                                 // Skip it silently
651                                 continue;
652                         }
653
654                         // Debug message
655                         this.getLogger().debug(MessageFormat.format("Calling getValueFromColumn({0}) on instance {1} ...", field.getName(), instance));
656
657                         // Get value from it
658                         Object value = instance.getValueFromColumn(field.getName());
659
660                         // Debug message
661                         this.getLogger().debug(MessageFormat.format("Adding field={0},value={1}", field.getName(), value)); //NOI18N
662
663                         // Add it to list
664                         map.put(field, value);
665                 }
666
667                 // Debug message
668                 this.getLogger().debug(MessageFormat.format("Returning iterator for {0} entries ...", map.size())); //NOI18N
669
670                 // Return list iterator
671                 return map.entrySet().iterator();
672         }
673
674         /**
675          * Instance for database backend
676          *
677          * @return the backend
678          */
679         protected final DatabaseBackend getBackend () {
680                 return this.backend;
681         }
682
683         /**
684          * Instance for database backend
685          *
686          * @param backend the backend to set
687          */
688         protected final void setBackend (final DatabaseBackend backend) {
689                 this.backend = backend;
690         }
691
692         /**
693          * Getter for Contact instance
694          *
695          * @return Contact instance
696          */
697         protected final Contact getContact () {
698                 return this.contact;
699         }
700
701         /**
702          * Setter for Contact instance
703          *
704          * @param contact A Contact instance
705          */
706         protected final void setContact (final Contact contact) {
707                 this.contact = contact;
708         }
709
710         /**
711          * Getter for DatabaseFrontend instance
712          *
713          * @return DatabaseFrontend instance
714          */
715         protected final DatabaseFrontend getFrontend () {
716                 return this.wrapper;
717         }
718
719         /**
720          * Setter for wrapper instance
721          *
722          * @param wrapper A DatabaseFrontend instance
723          */
724         protected final void setFrontend (final DatabaseFrontend wrapper) {
725                 this.wrapper = wrapper;
726         }
727
728         /**
729          * Initializes i18n bundles
730          */
731         protected void initBundle () {
732                 // Is the bundle set?
733                 if (bundle instanceof ResourceBundle) {
734                         // Is already set
735                         throw new IllegalStateException("called twice"); //NOI18N
736                 }
737
738                 // Set instance
739                 bundle = ResourceBundle.getBundle(FrameworkInterface.I18N_BUNDLE_FILE); // NOI18N
740         }
741
742         /**
743          * Prepares all properties, the file is written if it is not found
744          * 
745          * @throws java.io.IOException If any IO problem occurs
746          */
747         protected void initProperties () throws IOException {
748                 // Trace message
749                 this.getLogger().trace("CALLED!"); //NOI18N
750
751                 // Debug message
752                 this.getLogger().debug(MessageFormat.format("{0} properties are loaded already.", BaseFrameworkSystem.properties.size())); //NOI18N
753
754                 // Are some properties loaded?
755                 if (!BaseFrameworkSystem.properties.isEmpty()) {
756                         // Some are already loaded, abort here
757                         return;
758                 }
759
760                 try {
761                         // Try to read it
762                         BaseFrameworkSystem.properties.load(new BufferedReader(new InputStreamReader(new FileInputStream(FrameworkInterface.PROPERTIES_CONFIG_FILE))));
763
764                         // Debug message
765                         this.getLogger().debug(MessageFormat.format("{0} properties has been loaded.", BaseFrameworkSystem.properties.size())); //NOI18N
766                 } catch (final FileNotFoundException ex) {
767                         // Debug message
768                         this.getLogger().debug(MessageFormat.format("Properties file {0} not found: {1}", FrameworkInterface.PROPERTIES_CONFIG_FILE, ex)); //NOI18N
769
770                         /*
771                          * The file is not found which is normal for first run, so
772                          * initialize default values.
773                          */
774                         this.initPropertiesWithDefault();
775
776                         // Write file
777                         this.writePropertiesFile();
778                 }
779
780                 // Trace message
781                 this.getLogger().trace("EXIT!"); //NOI18N
782         }
783
784         /**
785          * Checks whether the given field is a boolean field by probing it.
786          *
787          * @param instance Instance to call
788          * @param targetClass Target class
789          * @param columnName Column name to check
790          * @return Whether the given column name represents a boolean field
791          */
792         protected boolean isBooleanField (final FrameworkInterface instance, final String targetClass, final String columnName) {
793                 // Trace message
794                 this.getLogger().trace(MessageFormat.format("instance={0},targetCLass={1},columnName={2} - CALLED!", instance, targetClass, columnName)); //NOI18N
795
796                 // Convert column name to getter name (boolean)
797                 String methodName = this.convertColumnNameToGetterMethod(columnName, true);
798
799                 // Get class instance
800                 Class<? extends FrameworkInterface> c = this.getClassFromTarget(instance, targetClass);
801
802                 // Defauzlt is boolean
803                 boolean isBool = true;
804
805                 try {
806                         // Now try to instance the method
807                         Method method = c.getDeclaredMethod(methodName, new Class<?>[0]);
808                 } catch (final NoSuchMethodException ex) {
809                         // Debug message
810                         this.getLogger().debug(MessageFormat.format("Method {0} does not exist, field {1} cannot be boolean: {2}", methodName, columnName, ex)); //NOI18N
811
812                         // Not found
813                         isBool = false;
814                 }
815
816                 // Trace message
817                 this.getLogger().trace(MessageFormat.format("isBool={0} - EXIT!", isBool)); //NOI18N
818
819                 // Return result
820                 return isBool;
821         }
822
823         /**
824          * Sets value in properties instance.
825          *
826          * @param key Property key (part) to set
827          * @param value Property value to set
828          */
829         protected void setProperty (final String key, final String value) {
830                 // Trace message
831                 this.getLogger().trace(MessageFormat.format("key={0},value={1} - CALLED!", key, value));
832
833                 // Set it
834                 properties.setProperty(String.format("org.mxchange.%s", key), value);
835
836                 // Trace message
837                 this.getLogger().trace("EXIT!");
838         }
839
840         /**
841          * Some getter for properties names (without org.mxchange)
842          *
843          * @return An array with property names
844          */
845         protected String[] getPropertyNames () {
846                 // Init array
847                 String[] names = {
848                         "database.backend.class",
849                         "database.backend.storagepath",
850                         "database.mysql.login",
851                         "database.mysql.host",
852                         "database.mysql.password",
853                         "database.mysql.dbname",
854                 };
855
856                 // Return it
857                 return names;
858         }
859 }