麻烦对下面的java代码进行每段注释,关键有用的语句给点中文注释说明,这是个聊天室程序的一部分,详见下 20
聊天信息的持久化类:packagecom.test.bean;//defaultpackageimportjava.sql.Timestamp;/***Messentit...
聊天信息的持久化类:
package com.test.bean;
// default package
import java.sql.Timestamp;
/**
* Mess entity. @author MyEclipse Persistence Tools
*/public class Mess implements java.io.Serializable {
// Fields
private Integer messageId;
private String roomName;
private String sendName;
private String context;
private Timestamp messDate;
// Constructors
/** default constructor */
public Mess() { }
/** minimal constructor */
public Mess(Timestamp messdate) {this.messDate = messdate; }
/** full constructor */
public Mess(String roomName, String sendName, String context, Timestamp messdate) {
this.roomName = roomName;
this.sendName = sendName;
this.context = context;
this.messDate = messdate;
}
// Property accessors
public Integer getMessageId() {
return this.messageId;
}
public void setMessageId(Integer messageId) { this.messageId = messageId; }
public String getRoomName() { return this.roomName;
}
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public String getSendName() { return this.sendName; }
public void setSendName(String sendName) {this.sendName = sendName; }
public String getContext() {return this.context;}
public void setContext(String context) {this.context = context;}
public Timestamp getMessDate() {
return messDate;
}
public void setMessDate(Timestamp messDate) {this.messDate = messDate; } 展开
package com.test.bean;
// default package
import java.sql.Timestamp;
/**
* Mess entity. @author MyEclipse Persistence Tools
*/public class Mess implements java.io.Serializable {
// Fields
private Integer messageId;
private String roomName;
private String sendName;
private String context;
private Timestamp messDate;
// Constructors
/** default constructor */
public Mess() { }
/** minimal constructor */
public Mess(Timestamp messdate) {this.messDate = messdate; }
/** full constructor */
public Mess(String roomName, String sendName, String context, Timestamp messdate) {
this.roomName = roomName;
this.sendName = sendName;
this.context = context;
this.messDate = messdate;
}
// Property accessors
public Integer getMessageId() {
return this.messageId;
}
public void setMessageId(Integer messageId) { this.messageId = messageId; }
public String getRoomName() { return this.roomName;
}
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public String getSendName() { return this.sendName; }
public void setSendName(String sendName) {this.sendName = sendName; }
public String getContext() {return this.context;}
public void setContext(String context) {this.context = context;}
public Timestamp getMessDate() {
return messDate;
}
public void setMessDate(Timestamp messDate) {this.messDate = messDate; } 展开
4个回答
展开全部
首先,我想说,这个类其实什么都没干,就是定义了一些变量和这样变量相应的set。get方法,当然还有这个类的构造函数。以下是解释:
package com.test.bean; //说明你的类所在的包
// default package
import java.sql.Timestamp; //导入所需要的类。
/**
* Mess entity. @author MyEclipse Persistence Tools //注释。不用管
*/
public class Mess implements java.io.Serializable {//定义类,实现了java.io.Serializable 接口
// 以下5句定义了5个私有变量
private Integer messageId;
private String roomName;
private String sendName;
private String context;
private Timestamp messDate;
// Constructors
/** default constructor */
//以下是构造函数,就是所有Mess()函数,函数有几个,但参数不一样,这个是函数的重载。
public Mess() { }
/** minimal constructor */
public Mess(Timestamp messdate) {this.messDate = messdate; }
/** full constructor */
public Mess(String roomName, String sendName, String context, Timestamp messdate) {
this.roomName = roomName;
this.sendName = sendName;
this.context = context;
this.messDate = messdate;
}
// Property accessors
//以下是上面定义的变量的set和get方法,java给类里的变量赋值和得到类里的变量值都是用get,set方法的。
public Integer getMessageId() {
return this.messageId;
}
public void setMessageId(Integer messageId) { this.messageId = messageId; }
public String getRoomName() { return this.roomName;
}
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public String getSendName() { return this.sendName; }
public void setSendName(String sendName) {this.sendName = sendName; }
public String getContext() {return this.context;}
public void setContext(String context) {this.context = context;}
public Timestamp getMessDate() {
return messDate;
}
public void setMessDate(Timestamp messDate) {this.messDate = messDate; }
然后就没了。。。真的里面什么内容都没有,就是构造函数重载了,需要看看,下面的set,get方法直接无视,eclipse都可以自动生成。
package com.test.bean; //说明你的类所在的包
// default package
import java.sql.Timestamp; //导入所需要的类。
/**
* Mess entity. @author MyEclipse Persistence Tools //注释。不用管
*/
public class Mess implements java.io.Serializable {//定义类,实现了java.io.Serializable 接口
// 以下5句定义了5个私有变量
private Integer messageId;
private String roomName;
private String sendName;
private String context;
private Timestamp messDate;
// Constructors
/** default constructor */
//以下是构造函数,就是所有Mess()函数,函数有几个,但参数不一样,这个是函数的重载。
public Mess() { }
/** minimal constructor */
public Mess(Timestamp messdate) {this.messDate = messdate; }
/** full constructor */
public Mess(String roomName, String sendName, String context, Timestamp messdate) {
this.roomName = roomName;
this.sendName = sendName;
this.context = context;
this.messDate = messdate;
}
// Property accessors
//以下是上面定义的变量的set和get方法,java给类里的变量赋值和得到类里的变量值都是用get,set方法的。
public Integer getMessageId() {
return this.messageId;
}
public void setMessageId(Integer messageId) { this.messageId = messageId; }
public String getRoomName() { return this.roomName;
}
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public String getSendName() { return this.sendName; }
public void setSendName(String sendName) {this.sendName = sendName; }
public String getContext() {return this.context;}
public void setContext(String context) {this.context = context;}
public Timestamp getMessDate() {
return messDate;
}
public void setMessDate(Timestamp messDate) {this.messDate = messDate; }
然后就没了。。。真的里面什么内容都没有,就是构造函数重载了,需要看看,下面的set,get方法直接无视,eclipse都可以自动生成。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
package com.test.bean;
// default package
import java.sql.Timestamp;
/**
* Mess entity. @author MyEclipse Persistence Tools
*/public class Mess implements java.io.Serializable {
// Fields //各种字段。下边四个类似于消息id,房间名,发送名,时间戳
private Integer messageId;
private String roomName;
private String sendName;
private String context;
private Timestamp messDate;
// Constructors
/** default constructor */
public Mess() { }//无参构造函数
/** minimal constructor */
public Mess(Timestamp messdate) {this.messDate = messdate; }//有参构造函数
/** full constructor */
public Mess(String roomName, String sendName, String context, Timestamp messdate) {//重载的有参构造函数
this.roomName = roomName;
this.sendName = sendName;
this.context = context;
this.messDate = messdate;
}
// Property accessors//一下是对4个字段的封装
public Integer getMessageId() {
return this.messageId;
}
public void setMessageId(Integer messageId) { this.messageId = messageId; }
public String getRoomName() { return this.roomName;
}
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public String getSendName() { return this.sendName; }
public void setSendName(String sendName) {this.sendName = sendName; }
public String getContext() {return this.context;}
public void setContext(String context) {this.context = context;}
public Timestamp getMessDate() {
return messDate;
}
public void setMessDate(Timestamp messDate) {this.messDate = messDate; }
// default package
import java.sql.Timestamp;
/**
* Mess entity. @author MyEclipse Persistence Tools
*/public class Mess implements java.io.Serializable {
// Fields //各种字段。下边四个类似于消息id,房间名,发送名,时间戳
private Integer messageId;
private String roomName;
private String sendName;
private String context;
private Timestamp messDate;
// Constructors
/** default constructor */
public Mess() { }//无参构造函数
/** minimal constructor */
public Mess(Timestamp messdate) {this.messDate = messdate; }//有参构造函数
/** full constructor */
public Mess(String roomName, String sendName, String context, Timestamp messdate) {//重载的有参构造函数
this.roomName = roomName;
this.sendName = sendName;
this.context = context;
this.messDate = messdate;
}
// Property accessors//一下是对4个字段的封装
public Integer getMessageId() {
return this.messageId;
}
public void setMessageId(Integer messageId) { this.messageId = messageId; }
public String getRoomName() { return this.roomName;
}
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public String getSendName() { return this.sendName; }
public void setSendName(String sendName) {this.sendName = sendName; }
public String getContext() {return this.context;}
public void setContext(String context) {this.context = context;}
public Timestamp getMessDate() {
return messDate;
}
public void setMessDate(Timestamp messDate) {this.messDate = messDate; }
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个就是存储一些数据(messageId,roomName,sendName,context,messDate),存储的时候就要先设置,然后再获取吧,因此就有一大堆的set(设置函数)和一堆的get(获取值函数)。
另外该类实现了java.io.Serializable 接口,是为了传递。
另外该类实现了java.io.Serializable 接口,是为了传递。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼主还说多看看java基础,这些都是很基础的东西
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询