本文整理汇总了Java中com.webpagebytes.cms.cmsdata.WPBAdminFieldKey类的典型用法代码示例。如果您正苦于以下问题:Java WPBAdminFieldKey类的具体用法?Java WPBAdminFieldKey怎么用?Java WPBAdminFieldKey使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WPBAdminFieldKey类属于com.webpagebytes.cms.cmsdata包,在下文中一共展示了WPBAdminFieldKey类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSQLStringForInsert
import com.webpagebytes.cms.cmsdata.WPBAdminFieldKey; //导入依赖的package包/类
private<T> String getSQLStringForInsert(T obj, Set<String> fieldsToIgnore)
{
String sqlTemplate = "INSERT INTO %s (%s) values (%s)";
Class<? extends Object> kind = obj.getClass();
String tableName = kind.getSimpleName();
String listColumns = "";
String listParams = "";
Field[] fields = kind.getDeclaredFields();
for(Field field: fields)
{
boolean storeField = (field.getAnnotation(WPBAdminFieldKey.class) != null) ||
(field.getAnnotation(WPBAdminFieldStore.class) != null) ||
(field.getAnnotation(WPBAdminFieldTextStore.class) != null);
if (storeField)
{
String fieldName = field.getName();
String fieldNameUpperCase = field.getName().toUpperCase();
if (fieldsToIgnore!=null && fieldsToIgnore.contains(fieldName))
{
continue;
}
listColumns = listColumns.concat(fieldNameUpperCase).concat(",");
listParams = listParams.concat("?,");
}
}
if (listColumns.endsWith(","))
{
listColumns = listColumns.substring(0, listColumns.length()-1);
}
if (listParams.endsWith(","))
{
listParams = listParams.substring(0, listParams.length()-1);
}
return String.format(sqlTemplate, tableName, listColumns, listParams) ;
}
示例2: getSQLStringForUpdate
import com.webpagebytes.cms.cmsdata.WPBAdminFieldKey; //导入依赖的package包/类
private String getSQLStringForUpdate(Object object, String keyFieldName) throws WPBSerializerException
{
String sqlTemplate = "UPDATE %s SET %s WHERE %s=?";
Class<? extends Object> kind = object.getClass();
String tableName = kind.getSimpleName();
String listColumns = "";
Field[] fields = kind.getDeclaredFields();
for(Field field: fields)
{
if (field.getAnnotation(WPBAdminFieldKey.class) != null)
{
continue;
}
boolean storeField = (field.getAnnotation(WPBAdminFieldKey.class) != null) ||
(field.getAnnotation(WPBAdminFieldStore.class) != null) ||
(field.getAnnotation(WPBAdminFieldTextStore.class) != null);
if (storeField)
{
String fieldNameUpperCase = field.getName().toUpperCase();
listColumns = listColumns.concat(fieldNameUpperCase).concat("=?,");
}
}
if (listColumns.endsWith(","))
{
listColumns = listColumns.substring(0, listColumns.length()-1);
}
return String.format(sqlTemplate, tableName, listColumns, keyFieldName.toUpperCase()) ;
}