View Javadoc

1   package net.sf.jour.processor;
2   
3   import java.io.ByteArrayInputStream;
4   import java.io.IOException;
5   import java.io.InputStream;
6   
7   import javassist.CannotCompileException;
8   import javassist.CtClass;
9   
10  public class InstrumentedCreatedEntry implements Entry {
11  
12  	private Entry orig; 
13  
14  	//private CtClass origClass;
15  	
16  	private CtClass ctClass;
17  	
18  	public InstrumentedCreatedEntry(Entry orig, CtClass origClass, CtClass ctClass) {
19  		this.orig = orig;
20  		//this.origClass = origClass;
21  		this.ctClass = ctClass;
22  	}
23  
24  	public InputStream getInputStream() throws IOException {
25  		try {
26  			return new ByteArrayInputStream(ctClass.toBytecode());
27  		} catch (CannotCompileException e) {
28  			throw new CompileIOException(e);
29  		}
30  	}
31  	
32  	public Entry getOrigin() {
33  		return orig;
34  	}
35  
36  	public String getName() {
37  		return "/" + ctClass.getName().replace('.', '/') + ".class";
38  	}
39  
40  	public long getSize() {
41  		return -1;
42  	}
43  
44  	public long getTime() {
45  		return this.orig.getTime();
46  	}
47  
48  	public boolean isClass() {
49  		return true;
50  	}
51  
52  	public boolean isDirectory() {
53  		return false;
54  	}
55  
56  }