01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdi.internal;
11:
12: import com.sun.jdi.PrimitiveType;
13:
14: /**
15: * this class implements the corresponding interfaces
16: * declared by the JDI specification. See the com.sun.jdi package
17: * for more information.
18: *
19: */
20: public abstract class PrimitiveTypeImpl extends TypeImpl implements
21: PrimitiveType {
22: /**
23: * Creates new instance.
24: */
25: public PrimitiveTypeImpl(String description,
26: VirtualMachineImpl vmImpl, String name, String 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,
34: String signature) {
35: // Notice that Primitive Types are not stored or cached because they don't 'remember' any information.
36:
37: // See JNI 1.1 Specification, Table 3-2 Java VM Type Signatures.
38: switch (signature.charAt(0)) {
39: case 'Z':
40: return new BooleanTypeImpl(vmImpl);
41: case 'B':
42: return new ByteTypeImpl(vmImpl);
43: case 'C':
44: return new CharTypeImpl(vmImpl);
45: case 'S':
46: return new ShortTypeImpl(vmImpl);
47: case 'I':
48: return new IntegerTypeImpl(vmImpl);
49: case 'J':
50: return new LongTypeImpl(vmImpl);
51: case 'F':
52: return new FloatTypeImpl(vmImpl);
53: case 'D':
54: return new DoubleTypeImpl(vmImpl);
55: }
56: throw new InternalError(
57: JDIMessages.PrimitiveTypeImpl_Invalid_primitive_signature____1
58: + signature + JDIMessages.PrimitiveTypeImpl___2); //
59: }
60:
61: /**
62: * @returns primitive type tag.
63: */
64: public abstract byte tag();
65:
66: /**
67: * @return Returns modifier bits.
68: */
69: public int modifiers() {
70: throw new InternalError(
71: JDIMessages.PrimitiveTypeImpl_A_PrimitiveType_does_not_have_modifiers_3);
72: }
73:
74: /* (non-Javadoc)
75: * @see java.lang.Object#equals(java.lang.Object)
76: */
77: public boolean equals(Object obj) {
78: return obj instanceof PrimitiveTypeImpl
79: && tag() == ((PrimitiveTypeImpl) obj).tag()
80: && virtualMachine().equals(
81: ((PrimitiveTypeImpl) obj).virtualMachine());
82: }
83: }
|