View Javadoc

1   /*
2    * $Id: ForwardMethodExpression.java,v 1.1 2007/09/07 15:33:02 oeuillot Exp $
3    * 
4    */
5   package org.rcfaces.core.internal.util;
6   
7   import javax.el.ELContext;
8   import javax.el.ELException;
9   import javax.el.MethodExpression;
10  import javax.el.MethodInfo;
11  import javax.el.MethodNotFoundException;
12  import javax.el.PropertyNotFoundException;
13  import javax.faces.component.StateHolder;
14  import javax.faces.context.FacesContext;
15  
16  /**
17   * @author Olivier Oeuillot (latest modification by $Author: oeuillot $)
18   * @version $Revision: 1.1 $ $Date: 2007/09/07 15:33:02 $
19   */
20  public class ForwardMethodExpression extends MethodExpression implements
21          StateHolder {
22  
23      private static final String REVISION = "$Revision: 1.1 $";
24  
25      private static final long serialVersionUID = 1L;
26  
27      private String forward = null;
28  
29      public ForwardMethodExpression() {
30      }
31  
32      public ForwardMethodExpression(String forward) {
33          this.forward = forward;
34      }
35  
36      public MethodInfo getMethodInfo(ELContext context)
37              throws NullPointerException, PropertyNotFoundException,
38              MethodNotFoundException, ELException {
39          return new MethodInfo("execute", String.class, new Class[0]);
40      }
41  
42      public Object invoke(ELContext arg0, Object[] arg1) {
43          return forward;
44      }
45  
46      public String getExpressionString() {
47          return forward;
48      }
49  
50      public boolean isLiteralText() {
51          return true;
52      }
53  
54      public int hashCode() {
55          final int prime = 31;
56          int result = 1;
57          result = prime * result + ((forward == null) ? 0 : forward.hashCode());
58          return result;
59      }
60  
61      public boolean equals(Object obj) {
62          if (this == obj)
63              return true;
64          if (obj == null)
65              return false;
66          if (getClass() != obj.getClass())
67              return false;
68          final ForwardMethodExpression other = (ForwardMethodExpression) obj;
69          if (forward == null) {
70              if (other.forward != null)
71                  return false;
72          } else if (!forward.equals(other.forward))
73              return false;
74          return true;
75      }
76  
77      // ----------------------------------------------------- StateHolder Methods
78  
79      public Object saveState(FacesContext context) {
80          return forward;
81      }
82  
83      public void restoreState(FacesContext context, Object state) {
84          forward = (String) state;
85      }
86  
87      private boolean transientFlag = false;
88  
89      public boolean isTransient() {
90          return (this.transientFlag);
91      }
92  
93      public void setTransient(boolean transientFlag) {
94          this.transientFlag = transientFlag;
95      }
96  }