Adroit
The Adroit project is a collection of utility classes, specially used in Demeter project. Some of important classes are as follows:
- CalendarUtil: Handling date conversion between
GregorianandJalali (Persian)calendar, using icu4j library. - ExcelExporter: Converting a list of data to an Excel file.
- ObjectBuilder: A wrapper class around classes using
method chainingto add/modify elements easily. - ConfigUil: A utility class to get application configuration from
config.propertiesfile located in the root of classpath. TheIConfigKeyinterface, used inConfigUtil, is provided to be implemented by an enum class where its literals are used as config keys. - NamedParameterStatement: Like Java's prepared statement, except using named parameters instead of
?- Using a plugin architecture to alter default behavior and modify query
- FilterPlugin: replace
%FILTER%value in the query string with appropriate sequentialandclauses based on a passedMapobject as filter - PaginationPlugin: alter query for proper pagination clause for HSQLDB, MySQL, and Oracle databases
- SchemaPlugin: alter query and prepend tables with the passed schema name
- StringEncryptorUtil: A utility class providing
encryption/decryption,encoding/decodingandhashingfunctions of strings - ObjectUtil: A utility class providing
bean introspectionand other general operation regarding objects - AdroitXStream: A subclass of
XStreamwith two features- Using CDATA for tag with string body
- A boolean converter which ignores false value.
- LRUCache: Using
LinkedHashMapas its core for caching objects with more utilities. - SQL Helper Classes:
ExportImportHelperandSqlHelperclasses are wrapper aroundNamedParameterStatement- ExportImportHelper: a class to export/import SQL result to/from XML
- SqlHelp: it uses an XML file based on
XQueryclass as the SQL queries reference (it is hard to embed SQL queries) in Java code and lots of other helper methods for result conversion to List, Map, or List of Beans
Some samples are provided in the test class, TestAdroit. For testing NamedParameterStatement, the sample schema is provided in the test/resources/init_hsql.sql file for HSQLDB database and imported on test startup using InitDB class.