Line 0
Link Here
|
|
|
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* Copyright 2008 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 |
* If you wish your version of this file to be governed by only the CDDL |
25 |
* or only the GPL Version 2, indicate your decision by adding |
26 |
* "[Contributor] elects to include this software in this distribution |
27 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a |
28 |
* single choice of license, a recipient has the option to distribute |
29 |
* your version of this file under either the CDDL, the GPL Version 2 or |
30 |
* to extend the choice of license to its licensees as provided above. |
31 |
* However, if you add GPL Version 2 code and therefore, elected the GPL |
32 |
* Version 2 license, then the option applies only if the new code is |
33 |
* made subject to such option by the copyright holder. |
34 |
* |
35 |
* Contributor(s): |
36 |
* |
37 |
* Portions Copyrighted 2008 Sun Microsystems, Inc. |
38 |
*/ |
39 |
|
40 |
package org.netbeans.spi.project; |
41 |
|
42 |
import org.openide.filesystems.FileObject; |
43 |
|
44 |
/** |
45 |
* Structure representing an identification of a single method/function |
46 |
* in a file. |
47 |
* |
48 |
* @since 1.19 |
49 |
*/ |
50 |
public final class SingleMethod { |
51 |
|
52 |
private FileObject file; |
53 |
private String methodName; |
54 |
|
55 |
/** |
56 |
* Creates a new instance holding the specified identification |
57 |
* of a method/function in a file. |
58 |
* |
59 |
* @param file file to be kept in the object |
60 |
* @param methodName name of a method inside the file |
61 |
* @exception java.lang.IllegalArgumentException |
62 |
* if the file or method name is {@code null} |
63 |
* @since 1.19 |
64 |
*/ |
65 |
public SingleMethod(FileObject file, String methodName) { |
66 |
super(); |
67 |
if (file == null) { |
68 |
throw new IllegalArgumentException("file is <null>"); |
69 |
} |
70 |
if (methodName == null) { |
71 |
throw new IllegalArgumentException("methodName is <null>"); |
72 |
} |
73 |
this.file = file; |
74 |
this.methodName = methodName; |
75 |
} |
76 |
|
77 |
/** |
78 |
* Returns the file identification. |
79 |
* |
80 |
* @return file held by this object |
81 |
* @since 1.19 |
82 |
*/ |
83 |
public FileObject getFile() { |
84 |
return file; |
85 |
} |
86 |
|
87 |
/** |
88 |
* Returns name of a method/function within the file. |
89 |
* |
90 |
* @return method/function name held by this object |
91 |
* @since 1.19 |
92 |
*/ |
93 |
public String getMethodName() { |
94 |
return methodName; |
95 |
} |
96 |
|
97 |
/** |
98 |
* Standard command for running single method/function |
99 |
* |
100 |
* @since 1.19 |
101 |
*/ |
102 |
public static final String COMMAND_RUN_SINGLE_METHOD = "run.single.method"; |
103 |
|
104 |
/** |
105 |
* Standard command for running single method/function in debugger |
106 |
* |
107 |
* @since 1.19 |
108 |
*/ |
109 |
public static final String COMMAND_DEBUG_SINGLE_METHOD = "debug.single.method"; |
110 |
|
111 |
@Override |
112 |
public boolean equals(Object obj) { |
113 |
if ((obj == null) || (obj.getClass() != SingleMethod.class)) { |
114 |
return false; |
115 |
} |
116 |
SingleMethod other = (SingleMethod) obj; |
117 |
return other.file.equals(file) && other.methodName.equals(methodName); |
118 |
} |
119 |
|
120 |
@Override |
121 |
public int hashCode() { |
122 |
int hash = 7; |
123 |
hash = 29 * hash + this.file.hashCode(); |
124 |
hash = 29 * hash + this.methodName.hashCode(); |
125 |
return hash; |
126 |
} |
127 |
} |