KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > standard > lang > jstl > NamedValue


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.taglibs.standard.lang.jstl;
18
19 import java.util.Map JavaDoc;
20
21 /**
22  *
23  * <p>Represents a name that can be used as the first element of a
24  * value.
25  *
26  * @author Nathan Abramson - Art Technology Group
27  * @author Shawn Bayern
28  * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: pierred $
29  **/

30
31 public class NamedValue
32   extends Expression
33 {
34   //-------------------------------------
35
// Constants
36
//-------------------------------------
37

38   //-------------------------------------
39
// Properties
40
//-------------------------------------
41
// property name
42

43   String JavaDoc mName;
44   public String JavaDoc getName ()
45   { return mName; }
46
47   //-------------------------------------
48
/**
49    *
50    * Constructor
51    **/

52   public NamedValue (String JavaDoc pName)
53   {
54     mName = pName;
55   }
56
57   //-------------------------------------
58
// Expression methods
59
//-------------------------------------
60
/**
61    *
62    * Returns the expression in the expression language syntax
63    **/

64   public String JavaDoc getExpressionString ()
65   {
66     return StringLiteral.toIdentifierToken (mName);
67   }
68
69   //-------------------------------------
70
/**
71    *
72    * Evaluates by looking up the name in the VariableResolver
73    **/

74   public Object JavaDoc evaluate (Object JavaDoc pContext,
75               VariableResolver pResolver,
76               Map JavaDoc functions,
77               String JavaDoc defaultPrefix,
78               Logger pLogger)
79     throws ELException
80   {
81     if (pResolver == null) {
82       return null;
83     }
84     else {
85       return pResolver.resolveVariable (mName, pContext);
86     }
87   }
88
89   //-------------------------------------
90
}
91
Popular Tags