rebuilding in java some common functionalities