added -J option to preserve unmodified files in preexisting jarfile
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / env / NameEnvironmentAnswer.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.env;
12
13 public class NameEnvironmentAnswer {
14         
15         // only one of the three can be set
16         IBinaryType binaryType;
17         ICompilationUnit compilationUnit;
18         ISourceType[] sourceTypes;
19         AccessRestriction accessRestriction;
20         
21         public NameEnvironmentAnswer(IBinaryType binaryType, AccessRestriction accessRestriction) {
22                 this.binaryType = binaryType;
23                 this.accessRestriction = accessRestriction;
24         }
25
26         public NameEnvironmentAnswer(ICompilationUnit compilationUnit, AccessRestriction accessRestriction) {
27                 this.compilationUnit = compilationUnit;
28                 this.accessRestriction = accessRestriction;
29         }
30
31         public NameEnvironmentAnswer(ISourceType[] sourceTypes, AccessRestriction accessRestriction) {
32                 this.sourceTypes = sourceTypes;
33                 this.accessRestriction = accessRestriction;
34         }
35         /**
36          * Returns the associated access restriction, or null if none.
37          */
38         public AccessRestriction getAccessRestriction() {
39                 return this.accessRestriction;
40         }
41         /**
42          * Answer the resolved binary form for the type or null if the
43          * receiver represents a compilation unit or source type.
44          */
45         public IBinaryType getBinaryType() {
46                 return this.binaryType;
47         }
48
49         /**
50          * Answer the compilation unit or null if the
51          * receiver represents a binary or source type.
52          */
53         public ICompilationUnit getCompilationUnit() {
54                 return this.compilationUnit;
55         }
56
57         /**
58          * Answer the unresolved source forms for the type or null if the
59          * receiver represents a compilation unit or binary type.
60          * 
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.
63          */
64         public ISourceType[] getSourceTypes() {
65                 return this.sourceTypes;
66         }
67
68         /**
69          * Answer whether the receiver contains the resolved binary form of the type.
70          */
71         public boolean isBinaryType() {
72                 return this.binaryType != null;
73         }
74
75         /**
76          * Answer whether the receiver contains the compilation unit which defines the type.
77          */
78         public boolean isCompilationUnit() {
79                 return this.compilationUnit != null;
80         }
81
82         /**
83          * Answer whether the receiver contains the unresolved source form of the type.
84          */
85         public boolean isSourceType() {
86                 return this.sourceTypes != null;
87         }
88 }