Refactored auxiliar functions

This commit is contained in:
Juan Miguel Boyero Corral 2011-04-21 21:46:36 +02:00
parent 1ec391aa7c
commit 26c0fba891

View File

@ -44,6 +44,10 @@ public class Global {
* Request code for Notifications module.
*/
public static final int NOTIFICATIONS_REQUEST_CODE = 3;
/**
* Request code for Tests module.
*/
public static final int TESTS_REQUEST_CODE = 4;
/**
* Class Module's tag name for Logcat
*/
@ -72,10 +76,26 @@ public class Global {
* Table name for test's questions
*/
public static final String DB_TABLE_TEST_QUESTIONS = "tst_questions";
/**
* Table name for test's tags
*/
public static final String DB_TABLE_TEST_TAGS = "tst_tags";
/**
* Table name for test's configuration
*/
public static final String DB_TABLE_TEST_CONFIG = "tst_config";
/**
* Table name for relationship between test's questions and tags
*/
public static final String DB_TABLE_TEST_QUESTION_TAGS = "tst_question_tags";
/**
* Table name for relationship between test's questions and courses
*/
public static final String DB_TABLE_TEST_QUESTIONS_COURSES = "tst_questions_courses";
public static final String DB_TABLE_TEST_QUESTIONS_COURSE = "tst_questions_course";
/**
* Table name for relationship between test's questions and answers
*/
public static final String DB_TABLE_TEST_QUESTION_ANSWERS = "tst_question_answers";
/**
* Gets the SWAD application key
@ -98,4 +118,40 @@ public class Global {
public static void setLogged(boolean logged) {
Global.logged = logged;
}
/**
* Function to parse from Integer to Boolean
* @param n Integer to be parsed
* @return true if n==0, false in other case
*/
public static boolean parseIntBool(int n) {
return n==0 ? true : false;
}
/**
* Function to parse from String to Boolean
* @param s String to be parsed
* @return true if s equals "Y", false in other case
*/
public static boolean parseStringBool(String s) {
return s.equals("Y") ? true : false;
}
/**
* Function to parse from Boolean to Integer
* @param b Boolean to be parsed
* @return 1 if b==true, 0 in other case
*/
public static int parseBoolInt(boolean b) {
return b ? 1 : 0;
}
/**
* Function to parse from Boolean to String
* @param b Boolean to be parsed
* @return "Y" if b==true, "N" in other case
*/
public static String parseBoolString(boolean b) {
return b ? "Y" : "N";
}
}