1 5 6 package org.infohazard.maverick.flow; 7 8 import java.io.IOException ; 9 import javax.servlet.ServletException ; 10 11 15 class ViewWithTransforms implements View 16 { 17 18 protected View decorated; 19 20 21 protected Transform[] transforms; 22 23 27 public ViewWithTransforms(View decorate, Transform[] trans) 28 { 29 if (trans == null || trans.length == 0) 30 throw new IllegalArgumentException ("Don't use this decorator without transforms"); 31 32 if (decorate instanceof ViewWithTransforms) 33 { 34 final ViewWithTransforms other = (ViewWithTransforms)decorate; 35 final Transform[] transforms = new Transform[trans.length + other.transforms.length]; 36 System.arraycopy(other.transforms, 0, transforms, 0, other.transforms.length); 37 System.arraycopy(trans, 0, transforms, other.transforms.length, trans.length); 38 this.transforms = transforms; 39 this.decorated = other.decorated; 40 } 41 else 42 { 43 this.decorated = decorate; 44 this.transforms = trans; 45 } 46 } 47 48 53 public void go(ViewContext vctx) throws IOException , ServletException 54 { 55 ((MaverickContext)vctx).setTransforms(this.transforms); 56 57 this.decorated.go(vctx); 58 } 59 } | Popular Tags |