javassist
Class ByteArrayClassPath

java.lang.Object
  extended by javassist.ByteArrayClassPath
All Implemented Interfaces:
ClassPath

public class ByteArrayClassPath
extends java.lang.Object
implements ClassPath

A ByteArrayClassPath contains bytes that is served as a class file to a ClassPool. It is useful to convert a byte array to a CtClass object.

For example, if you want to convert a byte array b into a CtClass object representing the class with a name classname, then do as following:

The ClassPool object cp uses the created ByteArrayClassPath object as the source of the class file.

A ByteArrayClassPath must be instantiated for every class. It contains only a single class file.

See Also:
ClassPath, ClassPool.insertClassPath(ClassPath), ClassPool.appendClassPath(ClassPath), ClassPool.makeClass(InputStream)

Constructor Summary
ByteArrayClassPath(java.lang.String name, byte[] classfile)
           
 
Method Summary
 void close()
          Closes this class path.
 java.net.URL find(java.lang.String classname)
          Obtains the URL.
 java.io.InputStream openClassfile(java.lang.String classname)
          Opens the class file.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ByteArrayClassPath

public ByteArrayClassPath(java.lang.String name,
                          byte[] classfile)
Method Detail

close

public void close()
Closes this class path.

Specified by:
close in interface ClassPath

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

openClassfile

public java.io.InputStream openClassfile(java.lang.String classname)
Opens the class file.

Specified by:
openClassfile in interface ClassPath
Parameters:
classname - a fully-qualified class name
Returns:
the input stream for reading a class file
See Also:
Translator

find

public java.net.URL find(java.lang.String classname)
Obtains the URL.

Specified by:
find in interface ClassPath
Parameters:
classname - a fully-qualified class name.
Returns:
null if the specified class file could not be found.


Javassist, a Java-bytecode translator toolkit.
Copyright (C) 1999-2008 Shigeru Chiba. All Rights Reserved.