gu.sql2java.Constant Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sql2java-base Show documentation
Show all versions of sql2java-base Show documentation
sql2java common class package
package gu.sql2java;
import java.util.concurrent.TimeUnit;
/**
* constant declare
* @author guyadong
*/
public interface Constant {
public static final int STATE_BIT_NUM = 32;
public static final int STATE_BIT_SHIFT = 5;
public static final int STATE_BIT_MASK = 0x1f;
public static final String SQL_LIKE_WILDCARD = "%";
/** set =QUERY for loadUsingTemplate */
public static final int SEARCH_EXACT = 0;
/** set %QUERY% for loadLikeTemplate */
public static final int SEARCH_LIKE = 1;
/** set %QUERY for loadLikeTemplate */
public static final int SEARCH_STARTING_LIKE = 2;
/** set QUERY% for loadLikeTemplate */
public static final int SEARCH_ENDING_LIKE = 3;
/** JDBC property name definition */
public static enum JdbcProperty{
/** debug status */DEBUG("isDebug"),
/** JDBC driver class name */JDBC_DRIVER("jdbc.driver"),
/** JDBC connection url */JDBC_URL("jdbc.url"),
/** JDBC user name */JDBC_USERNAME("jdbc.username"),
/** JDBC password */JDBC_PASSWORD("jdbc.password"),
/** Retrieval type of auto generated key:auto,before,after */GENERATEDKEY_RETRIEVE("generatedkey.retrieve"),
/** Retrieval statement of auto generated key */GENERATEDKEY_STATEMENT("generatedkey.statement"),
/** data source type, c3p0 supported only now */DATASOURCE("datasource"),
/** c3p0 property */C3P0_MINPOOLSIZE("c3p0.minPoolSize"),
/** c3p0 property */C3P0_MAXPOOLSIZE("c3p0.maxPoolSize"),
/** c3p0 property */C3P0_MAXIDLETIME("c3p0.maxIdleTime"),
/** c3p0 property */C3P0_IDLECONNECTIONTESTPERIOD("c3p0.idleConnectionTestPeriod");
/** JDBC property name */
public final String key;
JdbcProperty(String key){
this.key = key;
}
/** return {@link #key} with {@code prefix} */
public String withPrefix(String prefix){
return new StringBuffer().append(prefix).append(key).toString();
}
/**
* cast {@code key} to {@link JdbcProperty} instance if {@link #key} field equal the argument {@code key},
* otherwise return {@code null}
* @param key JDBC property name
*/
public static final JdbcProperty fromKey(String key){
for(JdbcProperty p: values()){
if(p.key.equals(key)){
return p;
}
}
return null;
}
}
/**
* Update strategy for cache
*/
enum UpdateStrategy{
/** update no matter whether key exists */
always,
/** update only if key exists */
replace,
/** remove key */
remove,
/** reload data form database if key exists,and update */
refresh
}
/** 默认缓存更新策略 */
UpdateStrategy DEFAULT_STRATEGY = UpdateStrategy.always;
/** 默认缓存最大缓存容量 */
long DEFAULT_CACHE_MAXIMUMSIZE = 10000;
/** 默认缓存失败时间 */
long DEFAULT_DURATION = 10;
/** 默认缓存失败时间单位 */
TimeUnit DEFAULT_TIME_UNIT = TimeUnit.MINUTES;
public static final String RETRIEVE_SUFFIX = "generatedkey.retrieve";
public static final String STATEMENT_SUFFIX = "generatedkey.statement";
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy