1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.env;
13 public class NameEnvironmentAnswer {
15 // only one of the three can be set
16 IBinaryType binaryType;
17 ICompilationUnit compilationUnit;
18 ISourceType[] sourceTypes;
19 AccessRestriction accessRestriction;
21 public NameEnvironmentAnswer(IBinaryType binaryType, AccessRestriction accessRestriction) {
22 this.binaryType = binaryType;
23 this.accessRestriction = accessRestriction;
26 public NameEnvironmentAnswer(ICompilationUnit compilationUnit, AccessRestriction accessRestriction) {
27 this.compilationUnit = compilationUnit;
28 this.accessRestriction = accessRestriction;
31 public NameEnvironmentAnswer(ISourceType[] sourceTypes, AccessRestriction accessRestriction) {
32 this.sourceTypes = sourceTypes;
33 this.accessRestriction = accessRestriction;
36 * Returns the associated access restriction, or null if none.
38 public AccessRestriction getAccessRestriction() {
39 return this.accessRestriction;
42 * Answer the resolved binary form for the type or null if the
43 * receiver represents a compilation unit or source type.
45 public IBinaryType getBinaryType() {
46 return this.binaryType;
50 * Answer the compilation unit or null if the
51 * receiver represents a binary or source type.
53 public ICompilationUnit getCompilationUnit() {
54 return this.compilationUnit;
58 * Answer the unresolved source forms for the type or null if the
59 * receiver represents a compilation unit or binary type.
61 * Multiple source forms can be answered in case the originating compilation unit did contain
62 * several type at once. Then the first type is guaranteed to be the requested type.
64 public ISourceType[] getSourceTypes() {
65 return this.sourceTypes;
69 * Answer whether the receiver contains the resolved binary form of the type.
71 public boolean isBinaryType() {
72 return this.binaryType != null;
76 * Answer whether the receiver contains the compilation unit which defines the type.
78 public boolean isCompilationUnit() {
79 return this.compilationUnit != null;
83 * Answer whether the receiver contains the unresolved source form of the type.
85 public boolean isSourceType() {
86 return this.sourceTypes != null;