com.zphinx.spine
Class Universal

java.lang.Object
  extended by com.zphinx.spine.Universal
All Implemented Interfaces:
UniversalConstants

public class Universal
extends Object
implements UniversalConstants

A universal class used for providing base application settings and common tasks.

Version:
$1.0

Copyright ©Zphinx Software Solutions

Author:
David Ladapo

Field Summary
static int SESSION_COUNTER
          The value (in seconds) to renew our UserListBeans within the system
 
Fields inherited from interface com.zphinx.spine.UniversalConstants
ACCOUNT_DETAILS_DEFAULT, ACCOUNT_SECRETS, ACCOUNT_SECRETS_TYPE, CLEAR, CREATE, DELETE, EDIT, RESET, SAVE, SAVE_UPDATE, VIEW, ZONE_ADMIN, ZONE_GROUP, ZONE_PUBLIC, ZONE_USER
 
Method Summary
static String createSQLDate(long date)
          Creates the java.sql string representation of a date in yyyy-mm-dd
static Date createSQLDateFromString(String s)
          Gets a Date object from an sql date string in format yyyy-mm-dd
static String createSQLTime(long time)
          Creates an SQL time in string format.
static int generateHashCode(String s)
          Generates an int useful for hashcodes using a simple numerical replacement of the alphabet eg L = 12
static Date getCalenderDate(String dateString)
          Parses the string returned from a Calender application as a Date, usually of the form DD/MM/YYYY
static String getCalenderDateString(Date date)
          Gets a String that can be displayed to the user by a calender for a date.
static Date getDateFromString(String totalString)
          Gets a date from string values usually of the form YYYY-MM-DD hh:mm:ss
static String getGroupLabel(String gId)
          Gets the label associated with this groupId
static List getGroupsList()
          Gets all the groups in this system.
static String getGroupValue(String gLabel)
          Gets the id of the named group
static org.apache.log4j.Logger getLogger(String instance)
          Gets the log4j logger instance for use by this system
static String getRandom(int size)
          Gets a random character identifier from (A-Z,a-z,0-9)
static String getRealDate(Date date)
          Gets a string to insert for date values
static long getUniqueId()
          Gets a uniqueId which can be used for Ids
static void setGroupsList(List groupsListExt)
          Stores the groups list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SESSION_COUNTER

public static final int SESSION_COUNTER
The value (in seconds) to renew our UserListBeans within the system

See Also:
Constant Field Values
Method Detail

getLogger

public static org.apache.log4j.Logger getLogger(String instance)
Gets the log4j logger instance for use by this system

Parameters:
instance - A string representing the class we are working with
Returns:
The Object which denotes our logger

getUniqueId

public static long getUniqueId()
Gets a uniqueId which can be used for Ids

Returns:
a long number useful for ids

getRandom

public static String getRandom(int size)
Gets a random character identifier from (A-Z,a-z,0-9)

Parameters:
size - The number of random characters to generate
Returns:
A random string of 9 letters (A..Z,a..z,0..9)

generateHashCode

public static int generateHashCode(String s)
Generates an int useful for hashcodes using a simple numerical replacement of the alphabet eg L = 12

Parameters:
s - The string whose int representation is to be generated
Returns:
An int which represents the addition of all the alphabets in the string using the numerical equivalent eg L = 12

getRealDate

public static String getRealDate(Date date)
Gets a string to insert for date values

Parameters:
date - The Date object representing this date
Returns:
The sql string representation of this date

createSQLTime

public static String createSQLTime(long time)
Creates an SQL time in string format. The format is hh:mm:ss

Parameters:
time - The time in milliseconds from the epoch
Returns:
The string in hh:mm:ss format

createSQLDate

public static String createSQLDate(long date)
Creates the java.sql string representation of a date in yyyy-mm-dd

Parameters:
date - The date in milliseconds from the epoch
Returns:
The date in yyyy-mm-dd format

createSQLDateFromString

public static Date createSQLDateFromString(String s)
Gets a Date object from an sql date string in format yyyy-mm-dd

Parameters:
s - The String containing the date usually the type obtained from a db
Returns:
A date object suitable for use by this framework

getDateFromString

public static Date getDateFromString(String totalString)
Gets a date from string values usually of the form YYYY-MM-DD hh:mm:ss

Parameters:
totalString - The full string from an sql database
Returns:
The java.util.Date representation of the input String

getCalenderDateString

public static String getCalenderDateString(Date date)
Gets a String that can be displayed to the user by a calender for a date. The format of this date is DD/MM/YYYY

Parameters:
date - The Date to create a string
Returns:
The date in a format used by a Calender application

getCalenderDate

public static Date getCalenderDate(String dateString)
Parses the string returned from a Calender application as a Date, usually of the form DD/MM/YYYY

Parameters:
dateString - The string returned from widget
Returns:
The Date represented by this dateString

getGroupsList

public static List getGroupsList()
Gets all the groups in this system. This must be initialized at startup by a suitable configuration object

Returns:
An ArrayList StringAttributeBeans of group names

setGroupsList

public static void setGroupsList(List groupsListExt)
Stores the groups list

Parameters:
groupsListExt - an ArrayList of StringAttributeBeans representing the names of individual groups

getGroupLabel

public static String getGroupLabel(String gId)
Gets the label associated with this groupId

Parameters:
gId - A String representing the id of individual group
Returns:
An appropriate label for the group

getGroupValue

public static String getGroupValue(String gLabel)
Gets the id of the named group

Parameters:
gLabel - A String representing the name of individual group
Returns:
An id for the group