If you think the Android project storm-gen listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.turbomanage.storm.apt;
//www.java2s.compublicclass SqlUtil {
privatestatic String reservedWords = "ABORT,ACTION,ADD,AFTER,ALL,ALTER,ANALYZE,AND,AS,ASC,ATTACH,AUTOINCREMENT,BEFORE,BEGIN,BETWEEN,BY,CASCADE,CASE,CAST,CHECK,COLLATE,COLUMN,COMMIT,CONFLICT,CONSTRAINT,CREATE,CROSS,CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,DATABASE,DEFAULT,DEFERRABLE,DEFERRED,DELETE,DESC,DETACH,DISTINCT,DROP,EACH,ELSE,END,ESCAPE,EXCEPT,EXCLUSIVE,EXISTS,EXPLAIN,FAIL,FOR,FOREIGN,FROM,FULL,GLOB,GROUP,HAVING,IF,IGNORE,IMMEDIATE,IN,INDEX,INDEXED,INITIALLY,INNER,INSERT,INSTEAD,INTERSECT,INTO,IS,ISNULL,JOIN,KEY,LEFT,LIKE,LIMIT,MATCH,NATURAL,NO,NOT,NOTNULL,NULL,OF,OFFSET,ON,OR,ORDER,OUTER,PLAN,PRAGMA,PRIMARY,QUERY,RAISE,REFERENCES,REGEXP,REINDEX,RELEASE,RENAME,REPLACE,RESTRICT,RIGHT,ROLLBACK,ROW,SAVEPOINT,SELECT,SET,TABLE,TEMP,TEMPORARY,THEN,TO,TRANSACTION,TRIGGER,UNION,UNIQUE,UPDATE,USING,VACUUM,VALUES,VIEW,VIRTUAL,WHEN,WHERE";
publicstaticboolean isValidIdentifier(String id) {
// valid Java identifier in brackets may include SQL reserved words
if (id.matches("^\\[[_a-zA-z][_a-zA-Z0-9]*\\]$"))
return true;
// Allow only valid Java identifiers since a table name is
// also used as the name of the corresponding TableHelper class
if (!isValidJavaIdentifier(id))
return false;
if (isReservedWord(id))
return false;
return true;
}
privatestaticboolean isReservedWord(String id) {
String[] words = reservedWords.split(",");
for (String word : words){
if(word.equals(id.toUpperCase())) return true;
}
return false;
}
publicstaticboolean isValidJavaIdentifier(String id) {
return id.matches("^[_a-zA-z][_a-zA-Z0-9]*$");
}
}