KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > deployment > config > DDLeafBean


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 package org.netbeans.modules.j2ee.deployment.config;
22
23 import org.netbeans.modules.j2ee.deployment.plugins.api.*;
24 import org.netbeans.modules.schema2beans.*;
25
26 import java.util.Collection JavaDoc;
27 import java.util.LinkedList JavaDoc;
28
29 public class DDLeafBean extends DDCommon {
30
31     BaseProperty prop;
32     int index;
33     boolean indexed;
34
35     DDLeafBean(BaseProperty prop, int index, ModuleDeploymentSupport support) {
36         this(prop.getParent(),support,prop.getDtdName());
37         this.prop = prop;
38         indexed = index != -1;
39         this.index = index;
40     }
41     
42     DDLeafBean(BaseProperty prop, ModuleDeploymentSupport support) {
43         this(prop.getParent(),support,prop.getDtdName());
44         this.prop = prop;
45         indexed = false;
46         index = -1;
47     }
48     
49     private DDLeafBean(BaseBean bean, ModuleDeploymentSupport support, String JavaDoc dtdName) {
50         super(support.getBean(bean).proxy,bean, support, dtdName);
51     }
52     
53     Collection JavaDoc search(String JavaDoc xpath, boolean addCurrent) {
54         Collection JavaDoc ret = new LinkedList JavaDoc();
55         if(addCurrent && (xpath.equals("") || xpath.equals("."))) // NOI18N
56
ret.add(container);
57         return ret;
58     }
59     
60     public String JavaDoc getText() {
61         Object JavaDoc ret;
62         // System.out.println("Getting text for " + prop.getName() + " with index " + index);
63
if (indexed)
64             ret = prop.getParent().getValue(prop.getName(),index);
65         else
66             ret = prop.getParent().getValue(prop.getName());
67         if (ret == null)
68             return null;
69         return ret.toString();
70     }
71     
72     public boolean equals(Object JavaDoc o) {
73         if(o instanceof DDLeafBean) {
74             DDLeafBean d = (DDLeafBean) o;
75             return d.prop == prop;
76         }
77         return false;
78     }
79     
80 }
81
82
Popular Tags