KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > util > VerificationInfo


1 /*******************************************************************************
2  * Copyright (c) 2004, 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.core.util;
12
13 import org.eclipse.jdt.core.util.ClassFormatException;
14 import org.eclipse.jdt.core.util.IConstantPool;
15 import org.eclipse.jdt.core.util.IConstantPoolConstant;
16 import org.eclipse.jdt.core.util.IConstantPoolEntry;
17 import org.eclipse.jdt.core.util.IVerificationTypeInfo;
18
19 public class VerificationInfo extends ClassFileStruct implements IVerificationTypeInfo {
20     
21     private int tag;
22     private int offset;
23     private int constantPoolIndex;
24     private char[] classTypeName;
25     private int readOffset;
26
27     public VerificationInfo(
28             byte[] classFileBytes,
29             IConstantPool constantPool,
30             int offset) throws ClassFormatException {
31         final int t = u1At(classFileBytes, 0, offset);
32         this.tag = t;
33         this.readOffset = 1;
34         switch(t) {
35             case IVerificationTypeInfo.ITEM_OBJECT :
36                 final int constantIndex = u2At(classFileBytes, 1, offset);
37                 this.constantPoolIndex = constantIndex;
38                 if (constantIndex != 0) {
39                     IConstantPoolEntry constantPoolEntry = constantPool.decodeEntry(constantIndex);
40                     if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
41                         throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
42                     }
43                     this.classTypeName = constantPoolEntry.getClassInfoName();
44                 }
45                 this.readOffset += 2;
46                 break;
47             case IVerificationTypeInfo.ITEM_UNINITIALIZED :
48                 this.offset = u2At(classFileBytes, 1, offset);
49                 this.readOffset += 2;
50         }
51     }
52     
53     public int getTag() {
54         return this.tag;
55     }
56
57     public int getOffset() {
58         return this.offset;
59     }
60
61     public int getConstantPoolIndex() {
62         return this.constantPoolIndex;
63     }
64
65     public char[] getClassTypeName() {
66         return this.classTypeName;
67     }
68     
69     public int sizeInBytes() {
70         return this.readOffset;
71     }
72 }
73
Popular Tags