|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object serp.bytecode.Project
public class Project
The Project represents a working set of classes. It caches parsed bytecode and is responsible for bytecode class creation. Currently changes made in one class are not reflected in other classes, though this will be an option in the future.
Bytecode that has been parsed is held in a cache so that retrieving
a class with the same name multiple times always returns the same
BCClass
instance.
A future goal is to eventually have facilities for traversing jars or directory structures to find classes that meet a given criteria (such as implementing a given interface, etc) and to perform operations on entire projects, similar to aspect-oriented programming.
Constructor Summary | |
---|---|
Project()
Default constructor. |
|
Project(String name)
Construct a named project. |
Method Summary | |
---|---|
void |
acceptVisit(BCVisitor visit)
Accept a visit from a BCVisitor , calling the appropriate methods
to notify the visitor that it has entered this entity, and
to provide it with the proper callbacks for each sub-entity owned
by this one. |
void |
clear()
Clears all classes from this project. |
boolean |
containsClass(BCClass type)
Return true if the project already contains the given class. |
boolean |
containsClass(Class type)
Return true if the project already contains the given class. |
boolean |
containsClass(String type)
Return true if the project already contains the given class. |
BCClass[] |
getClasses()
Return all loaded classes in the project. |
String |
getName()
Return the project name, or null if unset. |
NameCache |
getNameCache()
Return the name cache, which includes utilities for converting names from internal to external form and vice versa. |
BCClass |
loadClass(BCClass bc)
Import the given bytecode from another project. |
BCClass |
loadClass(Class type)
Load the bytecode for the given class. |
BCClass |
loadClass(File classFile)
Load the bytecode from the given class file. |
BCClass |
loadClass(File classFile,
ClassLoader loader)
Load the bytecode from the given class file. |
BCClass |
loadClass(InputStream in)
Load the bytecode from the given stream. |
BCClass |
loadClass(InputStream in,
ClassLoader loader)
Load the bytecode from the given stream. |
BCClass |
loadClass(String name)
Load a class with the given name. |
BCClass |
loadClass(String name,
ClassLoader loader)
Load the bytecode for the class with the given name. |
boolean |
removeClass(BCClass type)
Remove a class from this project. |
boolean |
removeClass(Class type)
Remove a class from this project. |
boolean |
removeClass(String type)
Remove a class from this project. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Project()
public Project(String name)
Method Detail |
---|
public String getName()
public NameCache getNameCache()
public BCClass loadClass(String name)
loadClass(String,ClassLoader)
public BCClass loadClass(String name, ClassLoader loader)
BCClass
with the given name already exists in this project,
it will be returned. Otherwise, a new BCClass
will be created
with the given name and returned. If the name represents an existing
type, the returned instance will contain the parsed bytecode for
that type. If the name is of a primitive or array type, the returned
instance will act accordingly.
name
- the name of the class, including packageloader
- the class loader to use to search for an existing
class with the given name; if null defaults to the
context loader of the current thread
RuntimeException
- on parse errorpublic BCClass loadClass(Class type)
BCClass
with the name of the given class already exists in
this project, it will be returned. Otherwise, the bytecode of the given
class will be parsed and returned as a new BCClass
. If the
given class is an array or primitive type, the returned instance will
act accordingly.
type
- the class to parse
RuntimeException
- on parse errorpublic BCClass loadClass(File classFile)
BCClass
will be created from the
given bytecode.
RuntimeException
- on parse errorpublic BCClass loadClass(File classFile, ClassLoader loader)
BCClass
will be created from the
given bytecode.
RuntimeException
- on parse errorpublic BCClass loadClass(InputStream in)
BCClass
will be created
from the given bytecode.
RuntimeException
- on parse errorpublic BCClass loadClass(InputStream in, ClassLoader loader)
BCClass
will be created
from the given bytecode.
RuntimeException
- on parse errorpublic BCClass loadClass(BCClass bc)
BCClass
with the same name already exists in this project, it will be returned.
Otherwise, a new BCClass
will be created from the
information in the given class.
public void clear()
public boolean removeClass(String type)
public boolean removeClass(Class type)
public boolean removeClass(BCClass type)
public BCClass[] getClasses()
public boolean containsClass(String type)
public boolean containsClass(Class type)
public boolean containsClass(BCClass type)
public void acceptVisit(BCVisitor visit)
VisitAcceptor
BCVisitor
, calling the appropriate methods
to notify the visitor that it has entered this entity, and
to provide it with the proper callbacks for each sub-entity owned
by this one.
acceptVisit
in interface VisitAcceptor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |