KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdi > internal > PrimitiveTypeImpl


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.jdi.internal;
12
13
14 import com.sun.jdi.PrimitiveType;
15
16 /**
17  * this class implements the corresponding interfaces
18  * declared by the JDI specification. See the com.sun.jdi package
19  * for more information.
20  *
21  */

22 public abstract class PrimitiveTypeImpl extends TypeImpl implements PrimitiveType {
23     /**
24      * Creates new instance.
25      */

26     public PrimitiveTypeImpl(String JavaDoc description, VirtualMachineImpl vmImpl, String JavaDoc name, String JavaDoc signature) {
27         super(description, vmImpl, name, signature);
28     }
29     
30     /**
31      * Creates new instance based on primitive signature.
32      */

33     public static PrimitiveTypeImpl create(VirtualMachineImpl vmImpl, String JavaDoc signature) {
34         // Notice that Primitive Types are not stored or cached because they don't 'remember' any information.
35

36         // See JNI 1.1 Specification, Table 3-2 Java VM Type Signatures.
37
switch (signature.charAt(0)) {
38             case 'Z': return new BooleanTypeImpl(vmImpl);
39             case 'B': return new ByteTypeImpl(vmImpl);
40             case 'C': return new CharTypeImpl(vmImpl);
41             case 'S': return new ShortTypeImpl(vmImpl);
42             case 'I': return new IntegerTypeImpl(vmImpl);
43             case 'J': return new LongTypeImpl(vmImpl);
44             case 'F': return new FloatTypeImpl(vmImpl);
45             case 'D': return new DoubleTypeImpl(vmImpl);
46         }
47         throw new InternalError JavaDoc(JDIMessages.PrimitiveTypeImpl_Invalid_primitive_signature____1 + signature + JDIMessages.PrimitiveTypeImpl___2); //
48
}
49     
50     /**
51      * @returns primitive type tag.
52      */

53     public abstract byte tag();
54
55     /**
56      * @return Returns modifier bits.
57      */

58     public int modifiers() {
59         throw new InternalError JavaDoc(JDIMessages.PrimitiveTypeImpl_A_PrimitiveType_does_not_have_modifiers_3);
60     }
61     
62     /* (non-Javadoc)
63      * @see java.lang.Object#equals(java.lang.Object)
64      */

65     public boolean equals(Object JavaDoc obj) {
66         return obj instanceof PrimitiveTypeImpl
67           && tag() == ((PrimitiveTypeImpl)obj).tag()
68           && virtualMachine().equals(((PrimitiveTypeImpl)obj).virtualMachine());
69     }
70 }
71
Popular Tags