soot
Class SootClass

java.lang.Object
  |
  +--soot.tagkit.AbstractHost
        |
        +--soot.SootClass
All Implemented Interfaces:
Host

public class SootClass
extends AbstractHost

Soot representation of a Java class. They are usually created by a Scene, but can also be constructed manually through the given constructors.


Constructor Summary
SootClass(java.lang.String name)
          Constructs an empty SootClass with the given name and no modifiers.
SootClass(java.lang.String name, int modifiers)
          Constructs an empty SootClass with the given name and modifiers.
 
Method Summary
 void addField(SootField f)
          Adds the given field to this class.
 void addInterface(SootClass interfaceClass)
          Add the given class to the list of interfaces which are directly implemented by this class.
 void addMethod(SootMethod m)
          Adds the given method to this class.
 boolean declaresField(java.lang.String subsignature)
          Does this class declare a field with the given subsignature?
 boolean declaresField(java.lang.String name, Type type)
          Does this class declare a field with the given name and type.
 boolean declaresFieldByName(java.lang.String name)
          Does this class declare a field with the given name?
 boolean declaresMethod(java.lang.String subsignature)
          Does this class declare a method with the given subsignature?
 boolean declaresMethod(java.lang.String name, java.util.List parameterTypes)
          Does this class declare a method with the given name and parameter types?
 boolean declaresMethod(java.lang.String name, java.util.List parameterTypes, Type returnType)
          Does this class declare a method with the given name, parameter types, and return type?
 boolean declaresMethodByName(java.lang.String name)
          Does this class declare a method with the given name?
 SootField getField(java.lang.String subsignature)
           
 SootField getField(java.lang.String name, Type type)
          Returns the field of this class with the given name and type.
 SootField getFieldByName(java.lang.String name)
          Returns the field of this class with the given name.
 int getFieldCount()
          Returns the number of fields in this class.
 Chain getFields()
          Returns a backed Chain of fields.
 int getInterfaceCount()
          Returns the number of interfaces being directly implemented by this class.
 Chain getInterfaces()
          Returns a backed Chain of the interfaces that are directly implemented by this class.
 SootMethod getMethod(java.lang.String subsignature)
           
 SootMethod getMethod(java.lang.String name, java.util.List parameterTypes)
          Attempts to retrieve the method with the given name and parameters.
 SootMethod getMethod(java.lang.String name, java.util.List parameterTypes, Type returnType)
          Attempts to retrieve the method with the given name, parameters and return type.
 SootMethod getMethodByName(java.lang.String name)
          Attempts to retrieve the method with the given name.
 int getMethodCount()
          Returns the number of methods in this class.
 Chain getMethods()
          Returns a backed Chain of methods.
 int getModifiers()
          Returns the modifiers of this class.
 java.lang.String getName()
          Returns the name of this class.
 java.lang.String getPackageName()
          Returns the package name of this class.
 SootClass getSuperclass()
          Returns the superclass of this class.
 RefType getType()
          Returns the RefType corresponding to this class.
 boolean hasSuperclass()
          Does this class have a superclass? False implies that this is the java.lang.Object class.
 boolean implementsInterface(java.lang.String name)
          Does this class directly implement the given interface? (see getInterfaceCount())
 boolean isApplicationClass()
          Convenience method returning true if this class is an application class.
 boolean isContextClass()
          Convenience method returning true if this class is a context class.
 boolean isInScene()
          Returns true if this class is being managed by a Scene.
 boolean isInterface()
          Convenience method; returns true if this class is an interface.
 boolean isLibraryClass()
          Convenience method returning true if this class is a library class.
 boolean isPhantom()
          Convenience method returning true if this class is phantom.
 boolean isPhantomClass()
          Convenience method returning true if this class is a phantom class.
 boolean isPublic()
          Convenience method; returns true if this class is public.
 void printJimpleStyleTo(java.io.PrintWriter out, int printBodyOptions)
           
 void printTo(java.io.PrintWriter out)
          Prints this SootClass to the given PrintWriter, including active bodies of methods.
 void printTo(java.io.PrintWriter out, int printBodyOptions)
           
 void removeField(SootField f)
          Removes the given field from this class.
 void removeInterface(SootClass interfaceClass)
          Removes the given class from the list of interfaces which are direclty implemented by this class.
 void removeMethod(SootMethod m)
          Removes the given method from this class.
 void renameFieldsAndMethods(boolean privateOnly)
           
 void setApplicationClass()
          Makes this class an application class.
 void setContextClass()
          Makes this class a context class.
 void setInScene(boolean isInScene)
          Tells this class if it is being managed by a Scene.
 void setLibraryClass()
          Makes this class a library class.
 void setModifiers(int modifiers)
          Sets the modifiers for this class.
 void setName(java.lang.String name)
          Sets the name of this class.
 void setPhantom(boolean value)
          Marks this class as phantom, without notifying the Scene.
 void setPhantomClass()
          Makes this class a phantom class.
 void setSuperclass(SootClass c)
          Sets the superclass of this class.
 java.lang.String toString()
          Returns the name of this class.
 void write()
          Writes the class out to a file.
 void write(java.lang.String outputDir)
          Writes the class out to a file.
 
Methods inherited from class soot.tagkit.AbstractHost
addTag, getTag, getTags, hasTag, removeTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SootClass

public SootClass(java.lang.String name,
                 int modifiers)
Constructs an empty SootClass with the given name and modifiers.

SootClass

public SootClass(java.lang.String name)
Constructs an empty SootClass with the given name and no modifiers.
Method Detail

isInScene

public boolean isInScene()
Returns true if this class is being managed by a Scene. A class may be unmanaged while it is being constructed.

setInScene

public void setInScene(boolean isInScene)
Tells this class if it is being managed by a Scene.

getFieldCount

public int getFieldCount()
Returns the number of fields in this class.

getFields

public Chain getFields()
Returns a backed Chain of fields.

addField

public void addField(SootField f)
Adds the given field to this class.

removeField

public void removeField(SootField f)
Removes the given field from this class.

getField

public SootField getField(java.lang.String name,
                          Type type)
Returns the field of this class with the given name and type.

getFieldByName

public SootField getFieldByName(java.lang.String name)
Returns the field of this class with the given name. Throws a RuntimeException if there are more than one.

getField

public SootField getField(java.lang.String subsignature)

declaresField

public boolean declaresField(java.lang.String subsignature)
Does this class declare a field with the given subsignature?

getMethod

public SootMethod getMethod(java.lang.String subsignature)

declaresMethod

public boolean declaresMethod(java.lang.String subsignature)
Does this class declare a method with the given subsignature?

declaresFieldByName

public boolean declaresFieldByName(java.lang.String name)
Does this class declare a field with the given name?

declaresField

public boolean declaresField(java.lang.String name,
                             Type type)
Does this class declare a field with the given name and type.

getMethodCount

public int getMethodCount()
Returns the number of methods in this class.

getMethods

public Chain getMethods()
Returns a backed Chain of methods.

getMethod

public SootMethod getMethod(java.lang.String name,
                            java.util.List parameterTypes,
                            Type returnType)
Attempts to retrieve the method with the given name, parameters and return type.

getMethod

public SootMethod getMethod(java.lang.String name,
                            java.util.List parameterTypes)
Attempts to retrieve the method with the given name and parameters. This method may throw an AmbiguousMethodException if there is more than one method with the given name and parameter.

getMethodByName

public SootMethod getMethodByName(java.lang.String name)
Attempts to retrieve the method with the given name. This method may throw an AmbiguousMethodException if there are more than one method with the given name.

declaresMethod

public boolean declaresMethod(java.lang.String name,
                              java.util.List parameterTypes)
Does this class declare a method with the given name and parameter types?

declaresMethod

public boolean declaresMethod(java.lang.String name,
                              java.util.List parameterTypes,
                              Type returnType)
Does this class declare a method with the given name, parameter types, and return type?

declaresMethodByName

public boolean declaresMethodByName(java.lang.String name)
Does this class declare a method with the given name?

addMethod

public void addMethod(SootMethod m)
Adds the given method to this class.

removeMethod

public void removeMethod(SootMethod m)
Removes the given method from this class.

getModifiers

public int getModifiers()
Returns the modifiers of this class.

setModifiers

public void setModifiers(int modifiers)
Sets the modifiers for this class.

getInterfaceCount

public int getInterfaceCount()
Returns the number of interfaces being directly implemented by this class. Note that direct implementation corresponds to an "implements" keyword in the Java class file and that this class may still be implementing additional interfaces in the usual sense by being a subclass of a class which directly implements some interfaces.

getInterfaces

public Chain getInterfaces()
Returns a backed Chain of the interfaces that are directly implemented by this class. (see getInterfaceCount())

implementsInterface

public boolean implementsInterface(java.lang.String name)
Does this class directly implement the given interface? (see getInterfaceCount())

addInterface

public void addInterface(SootClass interfaceClass)
Add the given class to the list of interfaces which are directly implemented by this class.

removeInterface

public void removeInterface(SootClass interfaceClass)
Removes the given class from the list of interfaces which are direclty implemented by this class.

hasSuperclass

public boolean hasSuperclass()
Does this class have a superclass? False implies that this is the java.lang.Object class. Note that interfaces are subclasses of the java.lang.Object class.

getSuperclass

public SootClass getSuperclass()
Returns the superclass of this class. (see hasSuperclass())

setSuperclass

public void setSuperclass(SootClass c)
Sets the superclass of this class. Note that passing a null will cause the class to have no superclass.

getName

public java.lang.String getName()
Returns the name of this class.

getPackageName

public java.lang.String getPackageName()
Returns the package name of this class.

setName

public void setName(java.lang.String name)
Sets the name of this class.

isInterface

public boolean isInterface()
Convenience method; returns true if this class is an interface.

isPublic

public boolean isPublic()
Convenience method; returns true if this class is public.

printTo

public void printTo(java.io.PrintWriter out)
Prints this SootClass to the given PrintWriter, including active bodies of methods.

printJimpleStyleTo

public void printJimpleStyleTo(java.io.PrintWriter out,
                               int printBodyOptions)

printTo

public void printTo(java.io.PrintWriter out,
                    int printBodyOptions)

write

public void write()
Writes the class out to a file.

write

public void write(java.lang.String outputDir)
Writes the class out to a file.

getType

public RefType getType()
Returns the RefType corresponding to this class.

toString

public java.lang.String toString()
Returns the name of this class.
Overrides:
toString in class java.lang.Object

renameFieldsAndMethods

public void renameFieldsAndMethods(boolean privateOnly)

isApplicationClass

public boolean isApplicationClass()
Convenience method returning true if this class is an application class.
See Also:
Scene.getApplicationClasses()

setApplicationClass

public void setApplicationClass()
Makes this class an application class.

isLibraryClass

public boolean isLibraryClass()
Convenience method returning true if this class is a library class.
See Also:
Scene.getLibraryClasses()

setLibraryClass

public void setLibraryClass()
Makes this class a library class.

isContextClass

public boolean isContextClass()
Convenience method returning true if this class is a context class.
See Also:
Scene.getContextClasses()

setContextClass

public void setContextClass()
Makes this class a context class.

isPhantomClass

public boolean isPhantomClass()
Convenience method returning true if this class is a phantom class.
See Also:
Scene.getPhantomClasses()

setPhantomClass

public void setPhantomClass()
Makes this class a phantom class.

isPhantom

public boolean isPhantom()
Convenience method returning true if this class is phantom.

setPhantom

public void setPhantom(boolean value)
Marks this class as phantom, without notifying the Scene.