KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > el > lang > VariableMapperImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  *
21  * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
22  */
package com.sun.el.lang;
23
24 import java.io.Externalizable JavaDoc;
25 import java.io.IOException JavaDoc;
26 import java.io.ObjectInput JavaDoc;
27 import java.io.ObjectOutput JavaDoc;
28 import java.util.HashMap JavaDoc;
29 import java.util.Map JavaDoc;
30
31 import javax.el.ValueExpression;
32 import javax.el.VariableMapper;
33
34 public class VariableMapperImpl extends VariableMapper implements Externalizable JavaDoc {
35
36     private static final long serialVersionUID = 1L;
37     
38     private Map JavaDoc vars = new HashMap JavaDoc();
39     
40     public VariableMapperImpl() {
41         super();
42     }
43
44     public ValueExpression resolveVariable(String JavaDoc variable) {
45         return (ValueExpression) this.vars.get(variable);
46     }
47
48     public ValueExpression setVariable(String JavaDoc variable,
49             ValueExpression expression) {
50         return (ValueExpression) this.vars.put(variable, expression);
51     }
52
53     public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc, ClassNotFoundException JavaDoc {
54         this.vars = (Map JavaDoc) in.readObject();
55     }
56
57     public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc {
58         out.writeObject(this.vars);
59     }
60 }
61
Popular Tags