KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > FailComponent


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 Apr 7, 2005
10  *
11  * Author Ben Yu
12  * ZBS
13  */

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

22 final class FailComponent extends Component {
23   private final String JavaDoc msg;
24   
25   FailComponent(final String JavaDoc msg) {
26     this.msg = msg;
27   }
28   public Class JavaDoc getType() {
29     return null;
30   }
31   public boolean isConcrete(){
32     return true;
33   }
34   public Object JavaDoc create(Dependency pp)
35       throws IrresolveableArgumentException, ParameterTypeMismatchException,
36       AmbiguousComponentResolutionException, ComponentInstantiationException,
37       YanException {
38     throw new ComponentResolutionException(msg);
39   }
40
41   public Class JavaDoc verify(Dependency pp)
42       throws IrresolveableArgumentException, ParameterTypeMismatchException,
43       AmbiguousComponentResolutionException, YanException {
44     throw new ComponentResolutionException(msg);
45   }
46   public String JavaDoc toString(){
47     return "fail <" + msg + ">";
48   }
49   
50   public boolean equals(Object JavaDoc obj) {
51     if(obj instanceof FailComponent){
52       final FailComponent other = (FailComponent)obj;
53       return Utils.eq(msg, other.msg);
54     }
55     else return false;
56   }
57   public int hashCode() {
58     return msg==null?0:msg.hashCode();
59   }
60   public boolean isSingleton(){
61     return false;
62   }
63 }
64
Popular Tags