首页>代码>Struts2.3.5+Hibernate3+Spring3.1基于注解实现的多文件上传,下载>/FileUploadDownLoad/FileUploadDownLoad/src/cn/gov/csdn/base/model/BaseEntity.java
package cn.gov.csdn.base.model;

import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Date;

import cn.gov.csdn.base.exception.BaseException;
/**
* File:    BaseEntity.java
* Author:  admin
* Version: 1.0
* Date:    2014/01/02 15:33
* Modify:
* Description:用于继承
* Copyright csdn
*/
public abstract class BaseEntity implements Serializable{
	

	public abstract Integer getId();
	
	public abstract void  setId(Integer id);
	
	//重写所有所有bewan的toString,
	//以达到在GenericLogger中显示所有字段信息的功能
	@SuppressWarnings("rawtypes")
	public String toString() {
		Class clazz = this.getClass();
		String className = clazz.getSimpleName();
		StringBuffer buffer = new StringBuffer();
		buffer.append(className + "{");
		try {
			//
			Field[] fs = clazz.getDeclaredFields();
			Class ftype = null ;
			String fname = null ;
			Object fvalue = null ;
			for(Field f :fs){
				f.setAccessible(true);
				ftype = f.getType();
				fname = f.getName();
				fvalue = f.get(this);
				if((ftype.isPrimitive()
						|| ftype == String.class
						|| ftype == Integer.class
						|| ftype == Long.class
						|| ftype == Date.class)
						&& !Modifier.isStatic(f.getModifiers())){
					buffer.append(fname + ":" + fvalue + ",");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new BaseException();
		}
		buffer.append("}");
		return buffer.toString();
	}
}
最近下载更多
597117933  LV8 2020年12月17日
17704627276  LV17 2020年10月19日
annazhang  LV29 2020年7月19日
lwp011  LV27 2020年7月7日
1404002391  LV12 2020年5月20日
912299793  LV21 2020年5月15日
angujj  LV1 2020年3月23日
13148918399  LV9 2019年12月10日
592381035  LV1 2019年12月5日
hzhsh0223  LV18 2019年9月18日
最近浏览更多
WBelong  LV7 2023年12月11日
似鹤不是鹤似鹤不是鹤  LV1 2023年5月5日
彩色天空  LV5 2023年4月8日
and123456  LV11 2022年3月16日
mafangnu  LV8 2021年12月26日
i967967  LV2 2021年12月14日
yema2986  LV2 2021年11月18日
Echo  LV1 2021年10月8日
铁血战士  LV1 2021年6月2日
ssy961021  LV7 2021年5月20日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友