KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > ioc > depend > DependencyPack


1 /* JFox, the OpenSource J2EE Application Server
2  *
3  * Distributable under GNU LGPL license by gun.org
4  * more details please visit http://www.huihoo.org/jfox
5  */

6 package org.jfox.ioc.depend;
7
8
9
10 /**
11  * ParameterPack 表示一个组件 setter 参数,它主要由 setter 的字段名称和一个参数组成
12  *
13  * @see Dependency
14  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
15  */

16
17 public class DependencyPack {
18     /**
19      * 属性名称,
20      */

21     private String JavaDoc name;
22     /**
23      * setter 的参数
24      */

25     private Dependency param;
26     /**
27      * 对setter的描述
28      */

29     private String JavaDoc description = "";
30
31     public static DependencyPack[] EMPTY_PARAMETER_PACKS = new DependencyPack[]{};
32
33     public DependencyPack(String JavaDoc name, Dependency param) {
34         this(name,param,null);
35     }
36
37     public DependencyPack(String JavaDoc name, Dependency param, String JavaDoc description) {
38         if(name == null || name.trim().equals("")) {
39             throw new IllegalArgumentException JavaDoc("setter name should not be null or empty.");
40         }
41         this.name = name;
42         this.param = param;
43         this.description = description;
44     }
45
46     /**
47      * 得到方法名称
48      */

49     public String JavaDoc getName() {
50         return "set" + name.substring(0, 1).toUpperCase() + name.substring(1);
51     }
52
53     /**
54      * 得到参数
55      * @return
56      */

57     public Dependency getParameter() {
58         return param;
59     }
60
61     /**
62      * 得到描述
63      * @return
64      */

65     public String JavaDoc getDescription() {
66         if(description == null) {
67             description = getName();
68         }
69         return description;
70     }
71
72     public void setDescription(String JavaDoc description) {
73         this.description = description;
74     }
75
76     public String JavaDoc toString() {
77         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("PropertyParameterPack[");
78         if(param != null) sb.append(param.toString());
79         sb.append("]");
80         return sb.toString();
81
82     }
83
84     public static void main(String JavaDoc[] args) {
85
86     }
87 }
88
Popular Tags