KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > refactoring > typeconstraints > TypeVariable


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.internal.corext.refactoring.typeconstraints;
12
13 import org.eclipse.core.runtime.Assert;
14
15 import org.eclipse.jdt.core.ICompilationUnit;
16 import org.eclipse.jdt.core.dom.ITypeBinding;
17 import org.eclipse.jdt.core.dom.Type;
18
19 import org.eclipse.jdt.internal.corext.dom.ASTNodes;
20
21 public final class TypeVariable extends ConstraintVariable {
22
23     private final String JavaDoc fSource;
24     private final CompilationUnitRange fTypeRange;
25     
26     public TypeVariable(Type type){
27         super(type.resolveBinding());
28         fSource= type.toString();
29         ICompilationUnit cu= ASTCreator.getCu(type);
30         Assert.isNotNull(cu);
31         fTypeRange= new CompilationUnitRange(cu, ASTNodes.getElementType(type));
32     }
33
34     public TypeVariable(ITypeBinding binding, String JavaDoc source, CompilationUnitRange range){
35         super(binding);
36         fSource= source;
37         fTypeRange= range;
38     }
39     
40     /* (non-Javadoc)
41      * @see java.lang.Object#toString()
42      */

43     public String JavaDoc toString() {
44         return fSource;
45     }
46
47     public CompilationUnitRange getCompilationUnitRange() {
48         return fTypeRange;
49     }
50 }
51
Popular Tags