KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > containers > SeqComponentTransformer


1 /*****************************************************************************
2  * Copyright (C) Codehaus.org. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  *****************************************************************************/

8 /*
9  * Created on Mar 9, 2005
10  *
11  * Author Ben Yu
12  * ZBS
13  */

14 package jfun.yan.containers;
15
16 import jfun.yan.Component;
17
18 /**
19  * Codehaus.org.
20  *
21  * @author Ben Yu
22  *
23  */

24 final class SeqComponentTransformer
25 extends ComponentTransformer{
26   private final ComponentTransformer t1;
27   private final ComponentTransformer t2;
28
29
30   SeqComponentTransformer(final ComponentTransformer t1,
31       final ComponentTransformer t2) {
32     this.t1 = t1;
33     this.t2 = t2;
34   }
35   
36   ComponentTransformer getTransformer1() {
37     return t1;
38   }
39   ComponentTransformer getTransformer2() {
40     return t2;
41   }
42   
43   public Component transform(Component cc) {
44     return t2.transform(t1.transform(cc));
45   }
46   public Component transform(Object JavaDoc key, Component cc) {
47     return t2.transform(key, t1.transform(key, cc));
48   }
49   public boolean equals(Object JavaDoc other) {
50     if(other instanceof SeqComponentTransformer){
51       final SeqComponentTransformer s2 = (SeqComponentTransformer)other;
52       return t1.equals(s2.t1) && t2.equals(s2.t2);
53     }
54     return false;
55   }
56   public int hashCode() {
57     return t1.hashCode()*31 + t2.hashCode();
58   }
59   public String JavaDoc toString() {
60     return t1.toString() + "*" + t2.toString();
61   }
62 }
63
Popular Tags