KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > j2ee > blueprints > catalog > validator > ConstantMethodBinding


1 /* Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
2 $Id: ConstantMethodBinding.java,v 1.2 2005/03/23 14:49:22 jenniferb Exp $ */

3
4 package com.sun.j2ee.blueprints.catalog.validator;
5
6 import javax.faces.component.StateHolder;
7 import javax.faces.context.FacesContext;
8 import javax.faces.el.MethodBinding;
9
10 /**
11  * This class provides method binding and state holding functionality
12  * used by other classes.
13  */

14
15 public class ConstantMethodBinding extends MethodBinding
16     implements StateHolder {
17
18     private String JavaDoc outcome = null;
19
20     /**
21      * Constructs a <code>ConstantMethodBinding</code> object.
22      */

23      public ConstantMethodBinding() {
24
25     }
26
27     /**
28      * Constructs a <code>ConstantMethodBinding</code> object.
29      */

30     public ConstantMethodBinding(String JavaDoc yourOutcome) {
31         outcome = yourOutcome;
32     }
33
34     /**
35      * Returns the return value resulting from a call to the method identified by
36      * this method binding expression, passing it the specified parameters, relative
37      * to the specified <code>FacesContext</code>.
38      */

39     public Object JavaDoc invoke(FacesContext context, Object JavaDoc params[]) {
40         return outcome;
41     }
42
43     /**
44      * Returns the Java class respresenting the return type from the method
45      * identified by this method binding expression.
46      */

47     public Class JavaDoc getType(FacesContext context) {
48         return String JavaDoc.class;
49     }
50
51     // ----------------------------------------------------- StateHolder Methods
52

53
54     /**
55      * Gets the state of the instance as a serializable object.
56      */

57     public Object JavaDoc saveState(FacesContext context) {
58         return outcome;
59     }
60
61     /**
62      * Performs any processing required to restore the state from the entries
63      * in the <code>state</code> object.
64      */

65     public void restoreState(FacesContext context, Object JavaDoc state) {
66         outcome = (String JavaDoc) state;
67     }
68
69     private boolean transientFlag = false;
70
71     /**
72      * Returns true if the object implementing this interface must not
73      * participate in saving and restoring state.
74      */

75     public boolean isTransient() {
76         return (this.transientFlag);
77     }
78
79     /**
80      * Denotes whether or not the object implementing this interface must not
81      * participate in state saving or restoring.
82      */

83     public void setTransient(boolean transientFlag) {
84         this.transientFlag = transientFlag;
85     }
86
87 }
88
89
Popular Tags