~ubuntu-branches/ubuntu/quantal/netbeans/quantal

« back to all changes in this revision

Viewing changes to form/src/org/netbeans/modules/form/BindingDescriptor.java

  • Committer: Bazaar Package Importer
  • Author(s): Marek Slama
  • Date: 2008-01-29 14:11:22 UTC
  • Revision ID: james.westby@ubuntu.com-20080129141122-fnzjbo11ntghxfu7
Tags: upstream-6.0.1
ImportĀ upstreamĀ versionĀ 6.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
3
 *
 
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
 
5
 *
 
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]"
 
23
 *
 
24
 * Contributor(s):
 
25
 *
 
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.
 
29
 *
 
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.
 
40
 */
 
41
 
 
42
package org.netbeans.modules.form;
 
43
 
 
44
import java.lang.reflect.*;
 
45
import java.util.*;
 
46
import org.netbeans.modules.form.FormUtils.TypeHelper;
 
47
 
 
48
/**
 
49
 * Descriptor of binding property/one segment in the binding path.
 
50
 *
 
51
 * @author Jan Stola, Tomas Pavek.
 
52
 */
 
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. */
 
59
    private String path;
 
60
 
 
61
    /** Display name of this binding. */
 
62
    private String propertyDisplayName;
 
63
    /** Short description of this binding. */
 
64
    private String propertyShortDescription;
 
65
 
 
66
    /**
 
67
     * Creates new <code>BindingDescriptor</code>.
 
68
     *
 
69
     * @param path name of the binding property/path segment.
 
70
     * @param genericValueType value type of the binding. 
 
71
     */
 
72
    public BindingDescriptor(String path, Type genericValueType) {
 
73
        this(path, new TypeHelper(genericValueType));
 
74
    }
 
75
 
 
76
    /**
 
77
     * Creates new <code>BindingDescriptor</code>.
 
78
     *
 
79
     * @param path name of the binding property/path segment.
 
80
     * @param genericValueType value type of the binding. 
 
81
     */    
 
82
    public BindingDescriptor(String path, TypeHelper genericValueType) {
 
83
        this.path = path;
 
84
        this.valueType = FormUtils.typeToClass(genericValueType);
 
85
        this.genericValueType = genericValueType;
 
86
    }
 
87
 
 
88
    /**
 
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.
 
92
     *
 
93
     * @return generified value type of the binding or <code>null</code>.
 
94
     */
 
95
    public TypeHelper getGenericValueType() {
 
96
        return genericValueType;
 
97
    }
 
98
 
 
99
    /**
 
100
     * Returns value type of the binding.
 
101
     *
 
102
     * @return value type of the binding.
 
103
     */
 
104
    public Class getValueType() {
 
105
        return valueType;
 
106
    }
 
107
 
 
108
    /**
 
109
     * Returns name of the binding property/path segment.
 
110
     *
 
111
     * @return name of the binding property/path segment.
 
112
     */
 
113
    public String getPath() {
 
114
        return path;
 
115
    }
 
116
 
 
117
    /**
 
118
     * Returns display name of this binding.
 
119
     *
 
120
     * @return display name of this binding.
 
121
     */
 
122
    public String getDisplayName() {
 
123
        return propertyDisplayName;
 
124
    }
 
125
 
 
126
    /**
 
127
     * Sets the display name of the binding.
 
128
     *
 
129
     * @param displayName display name of the binding.
 
130
     */
 
131
    public void setDisplayName(String displayName) {
 
132
        propertyDisplayName = displayName;
 
133
    }
 
134
 
 
135
    /**
 
136
     * Returns description of the binding.
 
137
     *
 
138
     * @return description of the binding.
 
139
     */
 
140
    public String getShortDescription() {
 
141
        return propertyShortDescription;
 
142
    }
 
143
 
 
144
    /**
 
145
     * Sets the description of the binding.
 
146
     *
 
147
     * @param description description of the binding.
 
148
     */
 
149
    public void setShortDescription(String description) {
 
150
        propertyShortDescription = description;
 
151
    }
 
152
 
 
153
    /**
 
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.
 
157
     */
 
158
    void markTypeAsRelative() {
 
159
        genericValueType = null;
 
160
    }
 
161
 
 
162
    /**
 
163
     * Determines whether the value type of this binding depends on the context
 
164
     * and should be determined using <code>BindingDesignSupport.determineType()</code> method.
 
165
     * 
 
166
     * @return <code>true</code> if the value type is relative,
 
167
     * returns <code>false</code> otherwise.
 
168
     */
 
169
    boolean isValueTypeRelative() {
 
170
        return (genericValueType == null);
 
171
    }
 
172
 
 
173
}