KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ws7 > serverresources > wizards > ResourceConfigHelper


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * ResourceConfigHelper.java
22  */

23
24 package org.netbeans.modules.j2ee.sun.ws7.serverresources.wizards;
25
26
27 /**
28  *
29  * Code reused from Appserver common API module
30  */

31 public class ResourceConfigHelper {
32
33     private ResourceConfigData datas[] = null;
34     private int index;
35     private boolean forEdit = false;
36
37     /** Creates a new instance of ResourceConfigHelper */
38     public ResourceConfigHelper(int size) {
39         this(size, 0);
40     }
41
42     public ResourceConfigHelper(int size, int index) {
43         datas = new ResourceConfigData[size];
44         this.index = index;
45     }
46     
47     public ResourceConfigHelper(ResourceConfigData data, int size, int index) {
48         this(size, index);
49         datas[index] = data;
50     }
51     
52     public ResourceConfigHelper(ResourceConfigData data) {
53         this(data, 1, 0);
54     }
55     
56     public int getIndex() {
57         return index;
58     }
59     
60     public void setIndex(int index) {
61         this.index = index;
62     }
63     
64     public boolean getForEdit() {
65         return forEdit;
66     }
67     
68     public ResourceConfigHelper setForEdit(boolean forEdit) {
69         this.forEdit = forEdit;
70         return this;
71     }
72         
73     public ResourceConfigData getData() {
74         ResourceConfigData data = datas[index];
75         if (data == null) {
76             data = new ResourceConfigData();
77             datas[index] = data;
78         }
79         return data;
80     }
81     
82     public String JavaDoc toString() {
83         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
84         str.append("index is " + index + "\n"); //NOI18N
85
for (int i = 0; i < datas.length; i++) {
86             if (datas[i] == null)
87                 str.append("datas[ " + i + " ] is null"); //NOI18N
88
else
89                 str.append("datas[ " + i + " ] is:\n" + datas[i].toString()); //NOI18N
90
}
91         return str.toString();
92     }
93            
94 }
95
Popular Tags