View Javadoc
1   /**
2    * Copyright By Grandsoft Company Limited.  
3    * 2013-1-5 下午06:31:15
4    */
5   package gboat2.base.core.model;
6   
7   import gboat2.base.core.util.ActionUtil;
8   
9   import java.util.Arrays;
10  
11  import org.apache.commons.lang3.StringUtils;
12  
13  /**
14   * 首选项描述
15   * @author tanxw
16   * @since jdk1.6
17   * @date 2013-1-5
18   *  
19   */
20  
21  public class PreferenceDefinition {
22  	
23  	/**首选项的全名,以'/'为分隔符,按层次分开*/
24  	private String fullname;
25  	
26  	/**首选项的action所在的bundle*/
27  	private String bundle;
28  	
29  	/**首选项对应的action*/
30  	private String actionClass;
31  	
32  	/**首选项对应的方法*/
33  	private String method;
34  	
35  	/**
36  	 * @return 首选项节点的名称
37  	 */
38  	public String getShortName() {
39  		String[] nodes = fullname.split("/");
40  		return nodes[nodes.length - 1];
41  	}
42  	
43  	/**
44  	 * @return 首选项节点的祖辈节点名称数组,数组下标0表示最顶层节点
45  	 */
46  	public String[] getAncestors() {
47  		String[] nodes = fullname.split("/");
48  		if (nodes.length > 1) {
49  			return Arrays.copyOfRange(nodes, 0, nodes.length - 1);
50  		}
51  		return null;
52  	}
53  	
54  	/**
55  	 * @return 节点的
56  	 */
57  	public String getUri() {
58  		if (StringUtils.isEmpty(method)) {
59  			return ActionUtil.getUri(actionClass);
60  		}
61  		return ActionUtil.getUri(actionClass, method);
62  	}
63  	
64  	public String getFullname() {
65  		return fullname;
66  	}
67  	
68  	public void setFullname(String fullname) {
69  		this.fullname = StringUtils.strip(fullname, "/");
70  	}
71  	
72  	public String getBundle() {
73  		return bundle;
74  	}
75  	
76  	public void setBundle(String bundle) {
77  		this.bundle = bundle;
78  	}
79  	
80  	public String getActionClass() {
81  		return actionClass;
82  	}
83  	
84  	public void setActionClass(String actionClass) {
85  		this.actionClass = actionClass;
86  	}
87  	
88  	public String getMethod() {
89  		return method;
90  	}
91  	
92  	public void setMethod(String method) {
93  		this.method = method;
94  	}
95  }