KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > axi > impl > AttributeProxy


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.axi.impl;
21
22 import org.netbeans.modules.xml.axi.AXIComponent;
23 import org.netbeans.modules.xml.axi.AXIComponent.ComponentType;
24 import org.netbeans.modules.xml.axi.AXIModel;
25 import org.netbeans.modules.xml.axi.AXIType;
26 import org.netbeans.modules.xml.axi.Attribute;
27 import org.netbeans.modules.xml.schema.model.Attribute.Use;
28 import org.netbeans.modules.xml.schema.model.Form;
29
30 /**
31  * Proxy attribute, acts on behalf of an Attribute.
32  * Delegates all calls to the original attribute.
33  *
34  * @author Samaresh (Samaresh.Panda@Sun.Com)
35  */

36 public class AttributeProxy extends Attribute implements AXIComponentProxy {
37    
38     /**
39      * Creates a new instance of AttributeProxy
40      */

41     public AttributeProxy(AXIModel model, AXIComponent sharedComponent) {
42         super(model, sharedComponent);
43     }
44     
45     private Attribute getShared() {
46         return (Attribute)getSharedComponent();
47     }
48     
49     /**
50      * Returns the type of this component,
51      * may be local, shared, proxy or reference.
52      * @see ComponentType.
53      */

54     public ComponentType getComponentType() {
55         return ComponentType.PROXY;
56     }
57     
58     /**
59      * Returns true if it is a reference, false otherwise.
60      */

61     public boolean isReference() {
62         return getShared().isReference();
63     }
64     
65     /**
66      * Returns the referent if isReference() is true.
67      */

68     public Attribute getReferent() {
69         return getShared().getReferent();
70     }
71     
72     /**
73      * Returns the name.
74      */

75     public String JavaDoc getName() {
76         return getShared().getName();
77     }
78     
79     /**
80      * Sets the name.
81      */

82     public void setName(String JavaDoc name) {
83         getShared().setName(name);
84     }
85         
86     /**
87      * Returns the type. This is expensive, since it uses a visitor
88      * to traverse to obtain the type information.
89      */

90     public AXIType getType() {
91         return getShared().getType();
92     }
93     
94     /**
95      * Sets the type.
96      */

97     public void setType(AXIType datatype) {
98         getShared().setType(datatype);
99     }
100         
101     /**
102      * Returns the form.
103      */

104     public Form getForm() {
105         return getShared().getForm();
106     }
107     
108     /**
109      * Sets the form.
110      */

111     public void setForm(Form form) {
112         getShared().setForm(form);
113     }
114     
115     /**
116      * Returns the fixed value.
117      */

118     public String JavaDoc getFixed() {
119         return getShared().getFixed();
120     }
121     
122     /**
123      * Sets the fixed value.
124      */

125     public void setFixed(String JavaDoc value) {
126         getShared().setFixed(value);
127     }
128     
129     /**
130      * Returns the default value.
131      */

132     public String JavaDoc getDefault() {
133         return getShared().getDefault();
134     }
135     
136     /**
137      * Sets the default value.
138      */

139     public void setDefault(String JavaDoc value) {
140         getShared().setDefault(value);
141     }
142     
143     /**
144      * Returns the use.
145      */

146     public Use getUse() {
147         return getShared().getUse();
148     }
149     
150     /**
151      * Sets the use.
152      */

153     public void setUse(Use value) {
154         getShared().setUse(value);
155     }
156     
157     /**
158      * Proxy doesn't get refreshed in the UI. We must notify.
159      */

160     void forceFireEvent() {
161         firePropertyChangeEvent(Attribute.PROP_NAME, null, getName());
162     }
163 }
164
Popular Tags