View Javadoc

1   package org.sourceforge.jemm.weaver.analysis;
2   
3   import javassist.CtClass;
4   
5   import org.sourceforge.jemm.weaver.transformation.Transformation;
6   import org.sourceforge.jemm.weaver.transformation.TransformationException;
7   
8   /**
9    * A number of transformations that are run in order.
10   * 
11   * @See DependencyManager
12   * 
13   * @author Paul Keeble
14   *
15   */
16  public class TransformationChain implements Transformation {
17  	Transformation[] transforms;
18  	
19  	/**
20  	 * Creates a chain where the transforms will be run in the order
21  	 * of the array passed.
22  	 * 
23  	 * @param transforms The transformations to use
24  	 */
25  	public TransformationChain(Transformation[] transforms) {
26  		this.transforms = transforms;
27  	}
28  	
29  	/**
30  	 * Returns an array containing the transformations.
31  	 * 
32  	 * @return The transformations underpinning this chain
33  	 */
34  	public Transformation[] getTransforms() {
35  		return transforms.clone();
36  	}
37  
38  	/**
39  	 * Always returns a zero length array.
40  	 */
41  	@Override
42  	public String[] dependentTransforms() {
43  		return new String[0];
44  	}
45  
46  	/**
47  	 * Always returns chain.
48  	 */
49  	@Override
50  	public String getTransformationName() {
51  		return "chain";
52  	}
53  
54  	/**
55  	 * Executes all transformations in order one after the other.
56  	 */
57  	@Override
58  	public void transform(CtClass clazz) throws TransformationException {
59  		for(Transformation t : transforms) {
60  			t.transform(clazz);
61  		}
62  	}
63  
64  }