package com.aggrepoint.winlet.spring.def;
import java.util.HashSet;
import java.util.StringTokenizer;
import com.aggrepoint.winlet.spring.annotation.Return;
/**
*
* @author Jiangming Yang (yangjm@gmail.com)
*/
public class ReturnDef {
private String value;
private String rule;
private String update;
private String target;
private boolean isDialog = false;
private boolean cache = false;
private String log;
private String msg;
private HashSet<String> logExclude;
private String title;
private String viewName;
void setNull() {
if (rule != null && "".equals(rule))
rule = null;
if (update != null && "".equals(update))
update = null;
if (target != null && "".equals(target))
target = null;
if (log != null && "".equals(log))
log = null;
if (title != null && "".equals(title))
title = null;
if (Return.NOT_SPECIFIED.equals(viewName))
viewName = null;
}
private void setLogExclude(String str) {
logExclude = null;
if (str == null || "".equals(str))
return;
logExclude = new HashSet<String>();
StringTokenizer st = new StringTokenizer(str, ", ");
while (st.hasMoreTokens())
logExclude.add(st.nextToken());
}
public ReturnDef(Return ret) {
this.value = ret.value();
rule = ret.rule();
update = ret.update();
target = ret.target();
isDialog = ret.dialog();
cache = ret.cache();
log = ret.log();
msg = ret.msg();
title = ret.title();
viewName = ret.view();
setLogExclude(ret.logexclude());
setNull();
}
public boolean hasValue() {
return !"".equals(value) || update != null || target != null || log != null
|| title != null || viewName != null || isDialog;
}
public String getValue() {
return value;
}
public String getRule() {
return rule;
}
public String getUpdate() {
return update;
}
public String getTarget() {
return target;
}
public boolean isDialog() {
return isDialog;
}
public boolean cache() {
return cache;
}
public String getLog() {
return log;
}
public String getMsg() {
return msg;
}
public String getTitle() {
return title;
}
public String getViewName() {
return viewName;
}
public HashSet<String> getLogExclude() {
return logExclude;
}
}