Added
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2006 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
7 |
* |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.core.search; |
12 |
|
13 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
14 |
import org.eclipse.jdt.core.IType; |
15 |
|
16 |
public class NoTypeNameMatch extends TypeNameMatch { |
17 |
|
18 |
private int modifiers = -1; // store modifiers to avoid java model population |
19 |
private char[] packageName; |
20 |
private char[] simpleTypeName; |
21 |
private char[][] enclosingTypeNames; |
22 |
|
23 |
/** |
24 |
* Specific type name match with no type. |
25 |
*/ |
26 |
public NoTypeNameMatch(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames) { |
27 |
this.modifiers = modifiers; |
28 |
this.packageName = packageName; |
29 |
this.simpleTypeName = simpleTypeName; |
30 |
this.enclosingTypeNames = enclosingTypeNames; |
31 |
} |
32 |
|
33 |
/* (non-Javadoc) |
34 |
* @see org.eclipse.jdt.core.search.TypeNameMatch#getFullyQualifiedName() |
35 |
*/ |
36 |
public String getFullyQualifiedName() { |
37 |
StringBuffer buffer = new StringBuffer(getTypeContainerName()); |
38 |
if (buffer.length() > 0) buffer.append('.'); |
39 |
buffer.append(this.simpleTypeName); |
40 |
return buffer.toString(); |
41 |
} |
42 |
|
43 |
/* (non-Javadoc) |
44 |
* @see org.eclipse.jdt.core.search.TypeNameMatch#getModifiers() |
45 |
*/ |
46 |
public int getModifiers() { |
47 |
return this.modifiers; |
48 |
} |
49 |
|
50 |
/* (non-Javadoc) |
51 |
* @see org.eclipse.jdt.core.search.TypeNameMatch#getPackageFragmentRoot() |
52 |
*/ |
53 |
public IPackageFragmentRoot getPackageFragmentRoot() { |
54 |
return null; |
55 |
} |
56 |
|
57 |
/* (non-Javadoc) |
58 |
* @see org.eclipse.jdt.core.search.TypeNameMatch#getPackageName() |
59 |
*/ |
60 |
public String getPackageName() { |
61 |
if (this.packageName == null) return null; |
62 |
return new String(this.packageName); |
63 |
} |
64 |
|
65 |
/* (non-Javadoc) |
66 |
* @see org.eclipse.jdt.core.search.TypeNameMatch#getSimpleTypeName() |
67 |
*/ |
68 |
public String getSimpleTypeName() { |
69 |
if (this.simpleTypeName == null) return null; |
70 |
return new String(this.simpleTypeName); |
71 |
} |
72 |
|
73 |
/* (non-Javadoc) |
74 |
* @see org.eclipse.jdt.core.search.TypeNameMatch#getType() |
75 |
*/ |
76 |
public IType getType() { |
77 |
return null; |
78 |
} |
79 |
|
80 |
/* (non-Javadoc) |
81 |
* @see org.eclipse.jdt.core.search.TypeNameMatch#getTypeContainerName() |
82 |
*/ |
83 |
public String getTypeContainerName() { |
84 |
StringBuffer buffer = new StringBuffer(); |
85 |
if (this.packageName != null && this.packageName.length > 0) { |
86 |
buffer.append(packageName); |
87 |
} |
88 |
if (this.enclosingTypeNames != null) { |
89 |
int length = this.enclosingTypeNames.length; |
90 |
for (int i=0; i<length; i++) { |
91 |
if (buffer.length() > 0) buffer.append('.'); |
92 |
buffer.append(this.enclosingTypeNames[i]); |
93 |
} |
94 |
} |
95 |
return buffer.toString(); |
96 |
} |
97 |
|
98 |
/* (non-Javadoc) |
99 |
* @see org.eclipse.jdt.core.search.TypeNameMatch#getTypeQualifiedName() |
100 |
*/ |
101 |
public String getTypeQualifiedName() { |
102 |
StringBuffer buffer = new StringBuffer(); |
103 |
if (this.enclosingTypeNames != null) { |
104 |
int length = this.enclosingTypeNames.length; |
105 |
for (int i=0; i<length; i++) { |
106 |
if (i>0) buffer.append('.'); |
107 |
buffer.append(this.enclosingTypeNames[i]); |
108 |
} |
109 |
} |
110 |
if (this.simpleTypeName != null && this.simpleTypeName.length > 0) { |
111 |
if (buffer.length() > 0) buffer.append('.'); |
112 |
buffer.append(this.simpleTypeName); |
113 |
} |
114 |
return buffer.toString(); |
115 |
} |
116 |
|
117 |
/* (non-Javadoc) |
118 |
* Returns the string of the matched type. |
119 |
* @see java.lang.Object#toString() |
120 |
*/ |
121 |
public String toString() { |
122 |
return getFullyQualifiedName(); |
123 |
} |
124 |
|
125 |
} |