2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
42
package org.netbeans.modules.form;
44
import java.lang.reflect.*;
46
import org.netbeans.modules.form.FormUtils.TypeHelper;
49
* Descriptor of binding property/one segment in the binding path.
51
* @author Jan Stola, Tomas Pavek.
53
public class BindingDescriptor {
54
/** Generified value type of the binding. */
55
private TypeHelper genericValueType;
56
/** Value type of the binding. */
57
private Class valueType;
58
/** Name of the binding property/path segment. */
61
/** Display name of this binding. */
62
private String propertyDisplayName;
63
/** Short description of this binding. */
64
private String propertyShortDescription;
67
* Creates new <code>BindingDescriptor</code>.
69
* @param path name of the binding property/path segment.
70
* @param genericValueType value type of the binding.
72
public BindingDescriptor(String path, Type genericValueType) {
73
this(path, new TypeHelper(genericValueType));
77
* Creates new <code>BindingDescriptor</code>.
79
* @param path name of the binding property/path segment.
80
* @param genericValueType value type of the binding.
82
public BindingDescriptor(String path, TypeHelper genericValueType) {
84
this.valueType = FormUtils.typeToClass(genericValueType);
85
this.genericValueType = genericValueType;
89
* Returns generified value type of the binding. May return <code>null</code>
90
* if the type of the binding depends on the context. In such a case the
91
* type should be determined using BindingDesignSupport.determineType() method.
93
* @return generified value type of the binding or <code>null</code>.
95
public TypeHelper getGenericValueType() {
96
return genericValueType;
100
* Returns value type of the binding.
102
* @return value type of the binding.
104
public Class getValueType() {
109
* Returns name of the binding property/path segment.
111
* @return name of the binding property/path segment.
113
public String getPath() {
118
* Returns display name of this binding.
120
* @return display name of this binding.
122
public String getDisplayName() {
123
return propertyDisplayName;
127
* Sets the display name of the binding.
129
* @param displayName display name of the binding.
131
public void setDisplayName(String displayName) {
132
propertyDisplayName = displayName;
136
* Returns description of the binding.
138
* @return description of the binding.
140
public String getShortDescription() {
141
return propertyShortDescription;
145
* Sets the description of the binding.
147
* @param description description of the binding.
149
public void setShortDescription(String description) {
150
propertyShortDescription = description;
154
* Marks the value type of this binding as relative. Type of such a binding
155
* may depend on the context and should be determined using
156
* <code>BindingDesignSupport.determineType()</code> method.
158
void markTypeAsRelative() {
159
genericValueType = null;
163
* Determines whether the value type of this binding depends on the context
164
* and should be determined using <code>BindingDesignSupport.determineType()</code> method.
166
* @return <code>true</code> if the value type is relative,
167
* returns <code>false</code> otherwise.
169
boolean isValueTypeRelative() {
170
return (genericValueType == null);