不用spring,hibernate超傻瓜JAVA开发(javabean+数组)
2009-12-30 21:14:35 来源:WEB开发网核心提示:javabean+数组优点:1、简单:java程序中最简单的类莫过于javabean,javabean有一套成熟的规范,不用spring,hibernate超傻瓜JAVA开发(javabean+数组),易于编写2、方便:javabean是数据的载体,既可以通过set和get方式来操作数据,所以没有任何学习曲线示例:vi
javabean+数组优点:
1、简单:java程序中最简单的类莫过于javabean,javabean有一套成熟的规范,易于编写
2、方便:javabean是数据的载体,既可以通过set和get方式来操作数据,又可以象使用数组一样来操作javabean
3、通用:通过下标来操作javabean,你所写的代码将是通用的,可移植的。你所写的功能组件将适用于所有的javabean
4、0配置:通过数组来对javabean进行说明配置,比xml文件更清晰
5、易于修改:程序中不再有任何SQL语句,数据结构发生改变,只要修改javabean即可
6、易于维护:由于第3点的通用性,你只需要维护页面及操作逻辑。
7、傻瓜性:会操作数组就会使用,所以没有任何学习曲线
示例:
view plaincopy to clipboardPRint?
package com.askyear.demo.bean;
import java.util.Date;
import com.askyear.db.ATable;
import com.askyear.db.key.String32Key;
/**
* 用户
*
* @author askyear.com
*
*/
public class User extends ATable {
public static final String USER_session = "user";
private static final long serialVersionUID = -8942196092377147945L;
private String member;
private String name;
private String passWord;
private String email;
private String type;
private Boolean useable;
private Date createTime;
public User() {
this.initSelf();
}
public void buildKeyIfNull() {
if (this.member == null || this.member.length() == 0) {
this.member = String32Key.getKeyValue();
}
if (this.useable == null)
this.useable = true;
if (this.createTime == null)
this.createTime = new Date();
}
public Object getPropertyValue(int index) {
switch (index) {
case 0:
return member;
case 1:
return name;
case 2:
return password;
case 3:
return email;
case 4:
return type;
case 5:
return useable;
case 6:
return createTime;
default:
throw new ArrayIndexOutOfBoundsException("访问越界:" + index);
}
}
public void initSelf() {
this.setTableName("sys_user");
this.setTableChinaName("系统用户");
key = new int[] { 0 };
property = new String[] { "member", "name", "password", "email", "type", "useable", "createTime" };
field = new String[] { "member", "name", "password", "email", "type", "useable", "createTime" };
propertyName = new String[] { "帐号", "昵称", "密码", "邮箱", "类型", "状态", "注册时间" };
}
public void setPropertyValue(int index, Object value) {
switch (index) {
case 0:
this.member = parseString(value);
break;
case 1:
this.name = parseString(value);
break;
case 2:
this.password = parseString(value);
break;
case 3:
this.email = parseString(value);
break;
case 4:
this.type = parseString(value);
break;
case 5:
this.useable = parseBoolean(value);
break;
case 6:
this.createTime = parseDate(value);
break;
default:
throw new ArrayIndexOutOfBoundsException("访问越界:" + index);
}
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMember() {
return member;
}
public void setMember(String member) {
this.member = member;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Boolean getUseable() {
return useable;
}
public void setUseable(Boolean useable) {
this.useable = useable;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}
package com.askyear.demo.bean;
import java.util.Date;
import com.askyear.db.ATable;
import com.askyear.db.key.String32Key;
/**
* 用户
*
* @author askyear.com
*
*/
public class User extends ATable {
public static final String USER_SESSION = "user";
private static final long serialVersionUID = -8942196092377147945L;
private String member;
private String name;
private String password;
private String email;
private String type;
private Boolean useable;
private Date createTime;
public User() {
this.initSelf();
}
public void buildKeyIfNull() {
if (this.member == null || this.member.length() == 0) {
this.member = String32Key.getKeyValue();
}
if (this.useable == null)
this.useable = true;
if (this.createTime == null)
this.createTime = new Date();
}
public Object getPropertyValue(int index) {
switch (index) {
case 0:
return member;
case 1:
return name;
case 2:
return password;
case 3:
return email;
case 4:
return type;
case 5:
return useable;
case 6:
return createTime;
default:
throw new ArrayIndexOutOfBoundsException("访问越界:" + index);
}
}
public void initSelf() {
this.setTableName("sys_user");
this.setTableChinaName("系统用户");
key = new int[] { 0 };
property = new String[] { "member", "name", "password", "email", "type", "useable", "createTime" };
field = new String[] { "member", "name", "password", "email", "type", "useable", "createTime" };
propertyName = new String[] { "帐号", "昵称", "密码", "邮箱", "类型", "状态", "注册时间" };
}
public void setPropertyValue(int index, Object value) {
switch (index) {
case 0:
this.member = parseString(value);
break;
case 1:
this.name = parseString(value);
break;
case 2:
this.password = parseString(value);
break;
case 3:
this.email = parseString(value);
break;
case 4:
this.type = parseString(value);
break;
case 5:
this.useable = parseBoolean(value);
break;
case 6:
this.createTime = parseDate(value);
break;
default:
throw new ArrayIndexOutOfBoundsException("访问越界:" + index);
}
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMember() {
return member;
}
public void setMember(String member) {
this.member = member;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Boolean getUseable() {
return useable;
}
public void setUseable(Boolean useable) {
this.useable = useable;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}
数组property指明了该javabean所具有的属性
property = new String[] { "member", "name", "password", "email", "type", "useable", "createTime" };
数组field指明了属性分别对应的字段
field = new String[] { "member", "name", "password", "email", "type", "useable", "createTime" };
数组propertyName指定了属性的中文名称
propertyName = new String[] { "帐号", "昵称", "密码", "邮箱", "类型", "状态", "注册时间" };
setPropertyValue方法可以对javabean任何一个属性赋值,而且自动进行类型转换,改变程序到处都是类型转换的状况
+ expand sourceview plaincopy to clipboardprint?
public void setPropertyValue(int index, Object value) {
switch (index) {
case 0:
this.member = parseString(value);
break;
case 1:
this.name = parseString(value);
break;
case 2:
this.password = parseString(value);
break;
case 3:
this.email = parseString(value);
break;
case 4:
this.type = parseString(value);
break;
case 5:
this.useable = parseBoolean(value);
break;
case 6:
this.createTime = parseDate(value);
break;
default:
throw new ArrayIndexOutOfBoundsException("访问越界:" + index);
}
}
public void setPropertyValue(int index, Object value) {
switch (index) {
case 0:
this.member = parseString(value);
break;
case 1:
this.name = parseString(value);
break;
case 2:
this.password = parseString(value);
break;
case 3:
this.email = parseString(value);
break;
case 4:
this.type = parseString(value);
break;
case 5:
this.useable = parseBoolean(value);
break;
case 6:
this.createTime = parseDate(value);
break;
default:
throw new ArrayIndexOutOfBoundsException("访问越界:" + index);
}
}
示例下载 :http://www.askyear.com/download.jsp?id=f63bffbfff6b4411b072de66c282a5c5
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/SHSJAVA/archive/2009/12/29/5100309.aspx
1、简单:java程序中最简单的类莫过于javabean,javabean有一套成熟的规范,易于编写
2、方便:javabean是数据的载体,既可以通过set和get方式来操作数据,又可以象使用数组一样来操作javabean
3、通用:通过下标来操作javabean,你所写的代码将是通用的,可移植的。你所写的功能组件将适用于所有的javabean
4、0配置:通过数组来对javabean进行说明配置,比xml文件更清晰
5、易于修改:程序中不再有任何SQL语句,数据结构发生改变,只要修改javabean即可
6、易于维护:由于第3点的通用性,你只需要维护页面及操作逻辑。
7、傻瓜性:会操作数组就会使用,所以没有任何学习曲线
示例:
view plaincopy to clipboardPRint?
package com.askyear.demo.bean;
import java.util.Date;
import com.askyear.db.ATable;
import com.askyear.db.key.String32Key;
/**
* 用户
*
* @author askyear.com
*
*/
public class User extends ATable {
public static final String USER_session = "user";
private static final long serialVersionUID = -8942196092377147945L;
private String member;
private String name;
private String passWord;
private String email;
private String type;
private Boolean useable;
private Date createTime;
public User() {
this.initSelf();
}
public void buildKeyIfNull() {
if (this.member == null || this.member.length() == 0) {
this.member = String32Key.getKeyValue();
}
if (this.useable == null)
this.useable = true;
if (this.createTime == null)
this.createTime = new Date();
}
public Object getPropertyValue(int index) {
switch (index) {
case 0:
return member;
case 1:
return name;
case 2:
return password;
case 3:
return email;
case 4:
return type;
case 5:
return useable;
case 6:
return createTime;
default:
throw new ArrayIndexOutOfBoundsException("访问越界:" + index);
}
}
public void initSelf() {
this.setTableName("sys_user");
this.setTableChinaName("系统用户");
key = new int[] { 0 };
property = new String[] { "member", "name", "password", "email", "type", "useable", "createTime" };
field = new String[] { "member", "name", "password", "email", "type", "useable", "createTime" };
propertyName = new String[] { "帐号", "昵称", "密码", "邮箱", "类型", "状态", "注册时间" };
}
public void setPropertyValue(int index, Object value) {
switch (index) {
case 0:
this.member = parseString(value);
break;
case 1:
this.name = parseString(value);
break;
case 2:
this.password = parseString(value);
break;
case 3:
this.email = parseString(value);
break;
case 4:
this.type = parseString(value);
break;
case 5:
this.useable = parseBoolean(value);
break;
case 6:
this.createTime = parseDate(value);
break;
default:
throw new ArrayIndexOutOfBoundsException("访问越界:" + index);
}
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMember() {
return member;
}
public void setMember(String member) {
this.member = member;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Boolean getUseable() {
return useable;
}
public void setUseable(Boolean useable) {
this.useable = useable;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}
package com.askyear.demo.bean;
import java.util.Date;
import com.askyear.db.ATable;
import com.askyear.db.key.String32Key;
/**
* 用户
*
* @author askyear.com
*
*/
public class User extends ATable {
public static final String USER_SESSION = "user";
private static final long serialVersionUID = -8942196092377147945L;
private String member;
private String name;
private String password;
private String email;
private String type;
private Boolean useable;
private Date createTime;
public User() {
this.initSelf();
}
public void buildKeyIfNull() {
if (this.member == null || this.member.length() == 0) {
this.member = String32Key.getKeyValue();
}
if (this.useable == null)
this.useable = true;
if (this.createTime == null)
this.createTime = new Date();
}
public Object getPropertyValue(int index) {
switch (index) {
case 0:
return member;
case 1:
return name;
case 2:
return password;
case 3:
return email;
case 4:
return type;
case 5:
return useable;
case 6:
return createTime;
default:
throw new ArrayIndexOutOfBoundsException("访问越界:" + index);
}
}
public void initSelf() {
this.setTableName("sys_user");
this.setTableChinaName("系统用户");
key = new int[] { 0 };
property = new String[] { "member", "name", "password", "email", "type", "useable", "createTime" };
field = new String[] { "member", "name", "password", "email", "type", "useable", "createTime" };
propertyName = new String[] { "帐号", "昵称", "密码", "邮箱", "类型", "状态", "注册时间" };
}
public void setPropertyValue(int index, Object value) {
switch (index) {
case 0:
this.member = parseString(value);
break;
case 1:
this.name = parseString(value);
break;
case 2:
this.password = parseString(value);
break;
case 3:
this.email = parseString(value);
break;
case 4:
this.type = parseString(value);
break;
case 5:
this.useable = parseBoolean(value);
break;
case 6:
this.createTime = parseDate(value);
break;
default:
throw new ArrayIndexOutOfBoundsException("访问越界:" + index);
}
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMember() {
return member;
}
public void setMember(String member) {
this.member = member;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Boolean getUseable() {
return useable;
}
public void setUseable(Boolean useable) {
this.useable = useable;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}
数组property指明了该javabean所具有的属性
property = new String[] { "member", "name", "password", "email", "type", "useable", "createTime" };
数组field指明了属性分别对应的字段
field = new String[] { "member", "name", "password", "email", "type", "useable", "createTime" };
数组propertyName指定了属性的中文名称
propertyName = new String[] { "帐号", "昵称", "密码", "邮箱", "类型", "状态", "注册时间" };
setPropertyValue方法可以对javabean任何一个属性赋值,而且自动进行类型转换,改变程序到处都是类型转换的状况
+ expand sourceview plaincopy to clipboardprint?
public void setPropertyValue(int index, Object value) {
switch (index) {
case 0:
this.member = parseString(value);
break;
case 1:
this.name = parseString(value);
break;
case 2:
this.password = parseString(value);
break;
case 3:
this.email = parseString(value);
break;
case 4:
this.type = parseString(value);
break;
case 5:
this.useable = parseBoolean(value);
break;
case 6:
this.createTime = parseDate(value);
break;
default:
throw new ArrayIndexOutOfBoundsException("访问越界:" + index);
}
}
public void setPropertyValue(int index, Object value) {
switch (index) {
case 0:
this.member = parseString(value);
break;
case 1:
this.name = parseString(value);
break;
case 2:
this.password = parseString(value);
break;
case 3:
this.email = parseString(value);
break;
case 4:
this.type = parseString(value);
break;
case 5:
this.useable = parseBoolean(value);
break;
case 6:
this.createTime = parseDate(value);
break;
default:
throw new ArrayIndexOutOfBoundsException("访问越界:" + index);
}
}
示例下载 :http://www.askyear.com/download.jsp?id=f63bffbfff6b4411b072de66c282a5c5
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/SHSJAVA/archive/2009/12/29/5100309.aspx
[]
- ››不用登录也可与好友聊MSN
- ››Spring MVC与JAX-RS比较与分析
- ››Spring 框架的设计理念与设计模式分析
- ››不用蛮力用巧劲——升级本本搞定Win7
- ››Spring Web Flow 2 中流管理的持久化
- ››不用安装 QQ 软件 android 系统手机照样也能用 QQ...
- ››不用组合键 鼠标调用Win 7立体窗口
- ››Spring 事务管理高级应用难点剖析: 第 2 部分
- ››Spring 事务管理高级应用难点剖析: 第 3 部分
- ››Spring 事务管理高级应用难点剖析,第 1 部分
- ››不用无线路由器设置 WIFI 环境 让iphone/ipod tou...
- ››不用重装系统 Windows 7直接开启AHCI
更多精彩
赞助商链接