KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > search > TypeNameMatch


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.*;
14
15 /**
16  * A match collected while {@link SearchEngine searching} for
17  * all type names methods using a {@link TypeNameRequestor requestor}.
18  * <p>
19  * The type of this match is available from {@link #getType()}.
20  * </p>
21  * <p>
22  * This class is not intended to be overridden by clients.
23  * </p>
24  *
25  * @see TypeNameMatchRequestor
26  * @see SearchEngine#searchAllTypeNames(char[], int, char[], int, int, IJavaSearchScope, TypeNameMatchRequestor, int, org.eclipse.core.runtime.IProgressMonitor)
27  * @see SearchEngine#searchAllTypeNames(char[][], char[][], IJavaSearchScope, TypeNameMatchRequestor, int, org.eclipse.core.runtime.IProgressMonitor)
28  * @since 3.3
29  */

30 public abstract class TypeNameMatch {
31
32 /**
33  * Returns the matched type's fully qualified name using '.' character
34  * as separator (e.g. package name + '.' enclosing type names + '.' simple name).
35  *
36  * @see #getType()
37  * @see IType#getFullyQualifiedName(char)
38  *
39  * @throws NullPointerException if matched type is <code> null</code>
40  * @return Fully qualified type name of the type
41  */

42 public String JavaDoc getFullyQualifiedName() {
43     return getType().getFullyQualifiedName('.');
44 }
45
46 /**
47  * Returns the modifiers of the matched type.
48  * <p>
49  * This is a handle-only method as neither Java Model nor classpath
50  * initialization is done while calling this method.
51  *
52  * @return the type modifiers
53  */

54 public abstract int getModifiers();
55
56 /**
57  * Returns the package fragment root of the stored type.
58  * Package fragment root cannot be null and <strong>does</strong> exist.
59  *
60  * @see #getType()
61  * @see IJavaElement#getAncestor(int)
62  *
63  * @throws NullPointerException if matched type is <code> null</code>
64  * @return the existing java model package fragment root (ie. cannot be <code>null</code>
65  * and will return <code>true</code> to <code>exists()</code> message).
66  */

67 public IPackageFragmentRoot getPackageFragmentRoot() {
68     return (IPackageFragmentRoot) getType().getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
69 }
70
71 /**
72  * Returns the package name of the stored type.
73  *
74  * @see #getType()
75  * @see IType#getPackageFragment()
76  *
77  * @throws NullPointerException if matched type is <code> null</code>
78  * @return the package name
79  */

80 public String JavaDoc getPackageName() {
81     return getType().getPackageFragment().getElementName();
82 }
83
84 /**
85  * Returns the name of the stored type.
86  *
87  * @see #getType()
88  * @see IJavaElement#getElementName()
89  *
90  * @throws NullPointerException if matched type is <code> null</code>
91  * @return the type name
92  */

93 public String JavaDoc getSimpleTypeName() {
94     return getType().getElementName();
95 }
96
97 /**
98  * Returns a java model type handle.
99  * This handle may exist or not, but is not supposed to be <code>null</code>.
100  * <p>
101  * This is a handle-only method as neither Java Model nor classpath
102  * initializations are done while calling this method.
103  *
104  * @see IType
105  * @return the non-null handle on matched java model type.
106  */

107 public abstract IType getType();
108
109 /**
110  * Name of the type container using '.' character
111  * as separator (e.g. package name + '.' + enclosing type names).
112  *
113  * @see #getType()
114  * @see IMember#getDeclaringType()
115  *
116  * @throws NullPointerException if matched type is <code> null</code>
117  * @return name of the type container
118  */

119 public String JavaDoc getTypeContainerName() {
120     IType outerType = getType().getDeclaringType();
121     if (outerType != null) {
122         return outerType.getFullyQualifiedName('.');
123     } else {
124         return getType().getPackageFragment().getElementName();
125     }
126 }
127
128 /**
129  * Returns the matched type's type qualified name using '.' character
130  * as separator (e.g. enclosing type names + '.' + simple name).
131  *
132  * @see #getType()
133  * @see IType#getTypeQualifiedName(char)
134  *
135  * @throws NullPointerException if matched type is <code> null</code>
136  * @return fully qualified type name of the type
137  */

138 public String JavaDoc getTypeQualifiedName() {
139     return getType().getTypeQualifiedName('.');
140 }
141 }
142
Popular Tags