📄 messagevo.java
字号:
package com.jdon.jivejdon.model.message;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableProperty;
import com.jdon.jivejdon.model.ForumMessage;
import com.jdon.jivejdon.model.Property;
import com.jdon.util.StringUtil;
/**
* ForumMessage's value object
* @author gateway
*
*/
@Searchable(root = false)
public class MessageVO implements Serializable, Cloneable{
private ForumMessage entityMessage;
@SearchableProperty
protected String subject;
@SearchableProperty
protected String body;
@SearchableProperty
private String[] tagTitle;
private int rewardPoints;
public Collection propertys;
public final static String PROPERTY_MASKED = "MASKED";
public final static String PROPERTY_IP = "IP";
public MessageVO(ForumMessage message){
this();
this.entityMessage = message;
}
public MessageVO(){
propertys = new ArrayList();
}
/**
* @return Returns the subject.
*/
public String getSubject() {
return subject;
}
/**
* @return Returns the body.
*/
public String getBody() {
return body;
}
/**
* @param body
* The body to set.
*/
public void setBody(String body) {
this.body = body;
}
/**
* @param subject
* The subject to set.
*/
public void setSubject(String subject) {
this.subject = subject;
}
/**
* @return Returns the rewardPoints.
*/
public int getRewardPoints() {
return rewardPoints;
}
/**
* @param rewardPoints
* The rewardPoints to set.
*/
public void setRewardPoints(int rewardPoints) {
this.rewardPoints = rewardPoints;
}
public String[] getTagTitle() {
return tagTitle;
}
public void setTagTitle(String[] tagTitle) {
this.tagTitle = tagTitle;
}
public ForumMessage getEntityMessage() {
return entityMessage;
}
public void setEntityMessage(ForumMessage entityMessage) {
this.entityMessage = entityMessage;
}
public String getShortBody(int length) {
if (getBody() != null)
return StringUtil.shorten(getBody(), length);
else
return "";
}
public String getPostip() {
String ipaddress = "";
if (propertys == null)
return "not yet load propertys from persistence";
Iterator iter = propertys.iterator();
while (iter.hasNext()) {
Property property = (Property) iter.next();
if (property.getName().equals(MessageVO.PROPERTY_IP)) {
ipaddress = property.getValue();
break;
}
}
return ipaddress;
}
/**
* this mesages is masked by admin
*
* @param forumMessage TODO
* @return boolean
*/
public boolean isMasked() {
if (getPropertyValue(MessageVO.PROPERTY_MASKED) != null)
return true;
else
return false;
}
public void setMasked(boolean masked) {
if (masked)
addProperty(MessageVO.PROPERTY_MASKED, MessageVO.PROPERTY_MASKED);
else
removeProperty(MessageVO.PROPERTY_MASKED);
}
/**
* @return Returns the propertys.
*/
public Collection getPropertys() {
return propertys;
}
/**
* @param propertys
* The propertys to set.
*/
public void setPropertys(Collection propertys) {
this.propertys = propertys;
}
/**
* add property to propertys;
*
* @param propName
* @param propValue
*/
public void addProperty(String propName, String propValue) {
Property property = new Property();
property.setName(propName);
property.setValue(propValue);
propertys.add(property);
}
public String getPropertyValue(String propName) {
Iterator iter = propertys.iterator();
while (iter.hasNext()) {
Property property = (Property) iter.next();
if (property.getName().equalsIgnoreCase(propName)) {
return property.getValue();
}
}
return null;
}
public void removeProperty(String propName) {
Iterator iter = propertys.iterator();
Property removePorp = null;
while (iter.hasNext()) {
Property property = (Property) iter.next();
if (property.getName().equalsIgnoreCase(propName)) {
removePorp = property;
break;
}
}
propertys.remove(removePorp);
}
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -