Menu

g-common

G-Common

Home


Installation

See home page, Installation section, to add maven repositories.

Add in your pom.xml the dependency artifacts.

<dependency>
        <groupId>net.sf.gee</groupId>
        <artifactId>g-common</artifactId>
        <version>${g-common.version}</version>
</dependency>

Documentation

Site

FInd the site generation of Maven with all informations about project and code, including Javadocs. Please see the Files section and choose your version and download site archive.

Site archive file has name as <libraryname>-<library_version>-SITE.tar.bz2

Exception handling

It is a good practive spend more times about error handling with Exception classes inside g-common.

  • GBaseException, is an abstrac class that extends java.lang.Exception that use a similar structure of UNIX int code of process return. Indeed the enum ExceptionSignal has the list of common errors and associate them an integer number. So this class can manage the error handling using:

  • integer number,

  • integer number plus a message
  • integer number plus a message and plus an other exception

ExceptionSignal, is an Enumeration that contains the following errors with associated error code:

CONNECTION_ERROR(1),
CONNECTION_TIMEOUT_ERROR(2),
CONNECTION_TRASMISSION_ERROR(3),
DATABASE_ERROR(4),
PERSISTENCE_ERROR(5),
SERVICE_ERROR(6),
BUSINESS_SERVICE_ERROR(7),
XML_GENERIC_ERROR(8),
XML_PARSE_ERROR(9),
XML_RENDER_ERROR(10),
INPUT_DATA_GENERIC_ERROR(11),
INPUT_DATA_SYNTAX_ERROR(12),
INPUT_DATA_SEMANTIC_ERROR(13)

Examples

Please check the javadocs inside site archive. Below there are only some examples to show the usage of this library.

Wihtout StringUtil

if(someString != null && !"".equals(someString)) {
  // do something
}

With StringUtil

if(!StringUtil.isEmpty(someString)) {
  // do something
}

Without NumericUtil

SecureRandom sr = new SecureRandom();

int range = end - start + 1;

int randomIntWithRange = (sr.nextInt(range) + start);

With NumericUtil

int randomIntWithRange = NumericUtil.generateRandom(min, max);

Home