KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > util > ClassFileBytesDisassembler


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.jdt.core.util;
12
13 /**
14  * This class is intended to be subclassed to disassemble
15  * classfile bytes onto a String using the proper line separator.
16  *
17  * @since 2.1
18  */

19 public abstract class ClassFileBytesDisassembler {
20     
21     /**
22      * The mode is the detailed mode to disassemble IClassFileReader. It returns the magic
23      * numbers, the version numbers and field and method descriptors.
24      */

25     public final static int DETAILED = 1;
26     
27     /**
28      * The mode is the default mode to disassemble IClassFileReader.
29      */

30     public final static int DEFAULT = 2;
31     
32     /**
33      * This mode corresponds to the detailed mode plus the constant pool contents and
34      * any further information that would be useful for debugging purpose.
35      * @since 3.1
36      */

37     public final static int SYSTEM = 4;
38     
39     /**
40      * This mode is used to compact the class name to a simple name instead of a qualified name.
41      * @since 3.1
42      */

43     public final static int COMPACT = 8;
44
45     /**
46      * This mode is used to retrive a pseudo code for working copy purpose.
47      * @since 3.2
48      */

49     public final static int WORKING_COPY = 16;
50
51     /**
52      * Answers back the disassembled string of the classfile bytes using the default
53      * mode.
54      * This is an output quite similar to the javap tool, using DEFAULT mode.
55      *
56      * @param classFileBytes The bytes of the classfile
57      * @param lineSeparator the line separator to use.
58      *
59      * @return the disassembled string of the IClassFileReader using the default mode.
60      * @exception ClassFormatException if the classfile bytes are ill-formed
61      */

62     public abstract String JavaDoc disassemble(byte[] classFileBytes, String JavaDoc lineSeparator) throws ClassFormatException;
63
64     /**
65      * Answers back the disassembled string of the classfile bytes according to the
66      * mode.
67      * This is an output quite similar to the javap tool.
68      *
69      * @param classFileBytes The bytes of the classfile
70      * @param lineSeparator the line separator to use.
71      * @param mode the mode used to disassemble the IClassFileReader
72      *
73      * @return the disassembled string of the IClassFileReader according to the mode
74      * @exception ClassFormatException if the classfile bytes are ill-formed
75      */

76     public abstract String JavaDoc disassemble(byte[] classFileBytes, String JavaDoc lineSeparator, int mode) throws ClassFormatException;
77
78     /**
79      * Answers a readable short description of this disassembler
80      *
81      * @return String - a string description of the disassembler
82      */

83     public abstract String JavaDoc getDescription();
84 }
85
Popular Tags