当前位置: 首页>>代码示例>>Java>>正文


Java WPBAdminFieldKey类代码示例

本文整理汇总了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) ;
}
 
开发者ID:webpagebytes,项目名称:general-cms-plugins,代码行数:39,代码来源:WPBSQLDataStoreDao.java

示例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()) ;
}
 
开发者ID:webpagebytes,项目名称:general-cms-plugins,代码行数:30,代码来源:WPBSQLDataStoreDao.java


注:本文中的com.webpagebytes.cms.cmsdata.WPBAdminFieldKey类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。