ch.elca.dependency.core.classinfo
Class Reader

java.lang.Object
  |
  +--ch.elca.dependency.core.classinfo.Reader

public class Reader
extends java.lang.Object

This class is used to read the dependency informations out of the .class files. That means all the classes and packages that are needed for compiling a java source file. All the informations in a java class file are read in the diverse helper clases and they are stored in the attributes of this class. In this manner all the stuff contained in a class file is accessible by the getter methods of this class.

Version:
1.0-beta
Author:
Christoph Trutmann
See Also:
AttributeInfo, ConstantPoolInfo, MethodInfo, FieldInfo, ClassInfo, InvalidClassFileException

Field Summary
static int ACC_ABSTRACT
           
static int ACC_FINAL
           
static int ACC_INTERFACE
           
static int ACC_NATIVE
           
static int ACC_PRIVATE
           
static int ACC_PROTECTED
           
static int ACC_PUBLIC
           
static int ACC_STATIC
           
static int ACC_SYNCHRONIZED
           
static int ACC_THREADSAFE
           
static int ACC_TRANSIENT
           
 boolean dumpConstants
           
 
Constructor Summary
Reader()
           
 
Method Summary
static java.lang.String accessString(short flags)
          Returns a string that represents what the access flags are set for.
 ClassInfo getClassInfo()
          Creates a ClassInfo object, fills in the required information and returns it.
 java.lang.String getClassName()
          Get the name of the class.
 java.util.HashSet getImplementedInterfaces()
          Get the implemented interfaces by this class.
 java.lang.String getSuperClass()
          Get super class.
static java.lang.String nextSig(java.lang.String sig)
          Returns the next signature from a string of concatenated signatures.
 boolean read(java.io.InputStream in)
          Read a class from InputStream in.
 java.lang.String toString()
          The boring version of display().
static java.lang.String typeString(java.lang.String typeString, java.lang.String varName)
          Takes a type signature and a string representing a variable name and returns a declaration for that variable name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dumpConstants

public boolean dumpConstants

ACC_PUBLIC

public static final int ACC_PUBLIC
See Also:
Constant Field Values

ACC_PRIVATE

public static final int ACC_PRIVATE
See Also:
Constant Field Values

ACC_PROTECTED

public static final int ACC_PROTECTED
See Also:
Constant Field Values

ACC_STATIC

public static final int ACC_STATIC
See Also:
Constant Field Values

ACC_FINAL

public static final int ACC_FINAL
See Also:
Constant Field Values

ACC_SYNCHRONIZED

public static final int ACC_SYNCHRONIZED
See Also:
Constant Field Values

ACC_THREADSAFE

public static final int ACC_THREADSAFE
See Also:
Constant Field Values

ACC_TRANSIENT

public static final int ACC_TRANSIENT
See Also:
Constant Field Values

ACC_NATIVE

public static final int ACC_NATIVE
See Also:
Constant Field Values

ACC_INTERFACE

public static final int ACC_INTERFACE
See Also:
Constant Field Values

ACC_ABSTRACT

public static final int ACC_ABSTRACT
See Also:
Constant Field Values
Constructor Detail

Reader

public Reader()
Method Detail

read

public boolean read(java.io.InputStream in)
             throws java.io.IOException
Read a class from InputStream in.

Parameters:
in - InputStream for reading the content of the specified .class file.
Returns:
a boolean value indicating, whether the input were valid bytecodes.
Throws:
java.io.IOException - if an error occurs

getClassInfo

public ClassInfo getClassInfo()
                       throws java.lang.IllegalArgumentException,
                              InvalidClassFileException
Creates a ClassInfo object, fills in the required information and returns it.

Returns:
ClassInfo object with the dependency informations.
Throws:
java.lang.IllegalArgumentException - If the constructor of the ClassInfo object has wrong arguments.
InvalidClassFileException - If the there is something wrong with the .class file.

typeString

public static java.lang.String typeString(java.lang.String typeString,
                                          java.lang.String varName)
Takes a type signature and a string representing a variable name and returns a declaration for that variable name. For example, passing this the strings "[B" and "myArray" will return the string "byte myArray[]"

Parameters:
typeString - String representing the type.
varName - String representing the variable name.

accessString

public static java.lang.String accessString(short flags)
Returns a string that represents what the access flags are set for. So 0x14 returns "public final "


nextSig

public static java.lang.String nextSig(java.lang.String sig)
Returns the next signature from a string of concatenated signatures. For example if the signature was "[BII", this method would return "II"


getClassName

public java.lang.String getClassName()
Get the name of the class.

Returns:
String representing the class name.

toString

public java.lang.String toString()
The boring version of display().

Overrides:
toString in class java.lang.Object
Returns:
String representing the Reader object.

getSuperClass

public java.lang.String getSuperClass()
Get super class. If nothing explicit is extented in this class 'java.lang.Object' is returned.

Returns:
Super class in the full qualified class name.

getImplementedInterfaces

public java.util.HashSet getImplementedInterfaces()
Get the implemented interfaces by this class.

Returns:
HashSet with all the implemented interfaces in the full qualified class name. Null if there is no interface implemented in this class.


Copyright © 2003 ELCA Informatique SA. All Rights Reserved.