KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > explorer > core > dnd > lib > BasicDnDDescription


1 /*====================================================================
2
3 Objectweb Explorer Framework
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Moroy, Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 package org.objectweb.util.explorer.core.dnd.lib;
27
28 import org.objectweb.util.explorer.ExplorerUtils;
29 import org.objectweb.util.explorer.core.code.api.CodeDescription;
30 import org.objectweb.util.explorer.core.common.api.Description;
31 import org.objectweb.util.explorer.core.dnd.api.DnDDescription;
32
33 /**
34  *
35  *
36  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jérôme Moroy</a>,
37  * <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>.
38  *
39  * @version 0.1
40  */

41 public class BasicDnDDescription
42   implements DnDDescription
43 {
44
45     //==================================================================
46
//
47
// Internal States.
48
//
49
// ==================================================================
50

51     /** The type of the action (MOVE, COPY or LINK). */
52     protected String JavaDoc actionType_;
53     
54     /** The label of the action. */
55     protected String JavaDoc label_;
56     
57     /** The code of the action. */
58     protected CodeDescription codeDesc_;
59     
60     // ==================================================================
61
//
62
// Constructors.
63
//
64
// ==================================================================
65

66     // ==================================================================
67
//
68
// Internal methods.
69
//
70
// ==================================================================
71

72     /**
73      * Two BasicDnDDescription are considered as equals if and only if
74      * they have the same label and the same CodeDescription.
75      */

76     protected boolean equals(BasicDnDDescription dndDesc){
77         return ExplorerUtils.compareObjects(label_, dndDesc.label_)
78             && ExplorerUtils.compareObjects(codeDesc_, dndDesc.codeDesc_);
79     }
80     
81     // ==================================================================
82
//
83
// Public methods for Description interface.
84
//
85
// ==================================================================
86

87     /* (non-Javadoc)
88      * @see org.objectweb.util.explorer.core.common.api.Description#getDescriptionType()
89      */

90     public String JavaDoc getDescriptionType() {
91         return Description.DND_DESCRIPTION;
92     }
93
94     /* (non-Javadoc)
95      * @see org.objectweb.util.explorer.core.common.api.Description#isEmpty()
96      */

97     public boolean isEmpty() {
98         return label_==null || label_.equals("") || codeDesc_==null || codeDesc_.isEmpty();
99     }
100         
101     // ==================================================================
102
//
103
// Public methods for DnDDescription interface.
104
//
105
// ==================================================================
106

107     /* (non-Javadoc)
108      * @see org.objectweb.util.explorer.core.dnd.api.DnDDescription#setType(int)
109      */

110     public void setType(String JavaDoc actionType) {
111         actionType_ = actionType;
112     }
113
114     /* (non-Javadoc)
115      * @see org.objectweb.util.explorer.core.dnd.api.DnDDescription#getType()
116      */

117     public String JavaDoc getType() {
118         return actionType_;
119     }
120
121     /* (non-Javadoc)
122      * @see org.objectweb.util.explorer.core.dnd.api.DnDDescription#setLabel(java.lang.String)
123      */

124     public void setLabel(String JavaDoc label) {
125         label_ = label;
126     }
127
128     /* (non-Javadoc)
129      * @see org.objectweb.util.explorer.core.dnd.api.DnDDescription#getLabel()
130      */

131     public String JavaDoc getLabel() {
132         return label_;
133     }
134
135     /* (non-Javadoc)
136      * @see org.objectweb.util.explorer.core.dnd.api.DnDDescription#setCodeDescription(org.objectweb.util.explorer.core.code.api.CodeDescription)
137      */

138     public void setCodeDescription(CodeDescription codeDesc) {
139         codeDesc_ = codeDesc;
140     }
141
142     /* (non-Javadoc)
143      * @see org.objectweb.util.explorer.core.dnd.api.DnDDescription#getCodeDescription()
144      */

145     public CodeDescription getCodeDescription() {
146         return codeDesc_;
147     }
148    
149     // ==================================================================
150
//
151
// Public methods surcharging Object class.
152
//
153
// ==================================================================
154

155     /**
156      * Surcharging the Object.equals method.
157      * @see DefaultKey#equals(DefaultKey)
158      */

159     public boolean equals(Object JavaDoc o){
160         if(o!=null && o instanceof BasicDnDDescription)
161             return equals((BasicDnDDescription)o);
162         return false;
163     }
164     
165     /**
166      * Return a String representation of a BasicItemDescription
167      */

168     public String JavaDoc toString(){
169         return "BasicDnDDescription[" +
170                 "type=" + actionType_ +
171                 ", label=" + ExplorerUtils.toString(label_) +
172                 ", codeDesc=" + ExplorerUtils.toString(codeDesc_) +
173                 "]";
174     }
175
176 }
177
Popular Tags