001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.commons.el;
018    
019    import javax.servlet.jsp.el.ELException;
020    import javax.servlet.jsp.el.FunctionMapper;
021    import javax.servlet.jsp.el.VariableResolver;
022    
023    /**
024     *
025     * <p>Represents an operator that obtains the value of another value's
026     * property.  This is a specialization of ArraySuffix - a.b is
027     * equivalent to a["b"]
028     * 
029     * @author Nathan Abramson - Art Technology Group
030     * @author Shawn Bayern
031     * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: bayard $
032     **/
033    
034    public class PropertySuffix
035      extends ArraySuffix
036    {
037      //-------------------------------------
038      // Properties
039      //-------------------------------------
040      // property name
041    
042      String mName;
043      public String getName ()
044      { return mName; }
045      public void setName (String pName)
046      { mName = pName; }
047    
048      //-------------------------------------
049      /**
050       *
051       * Constructor
052       **/
053      public PropertySuffix (String pName)
054      {
055        super (null);
056        mName = pName;
057      }
058    
059      //-------------------------------------
060      /**
061       *
062       * Gets the value of the index
063       **/
064      Object evaluateIndex (VariableResolver pResolver, FunctionMapper functions)
065        throws ELException
066      {
067        return mName;
068      }
069    
070      //-------------------------------------
071      /**
072       *
073       * Returns the operator symbol
074       **/
075      String getOperatorSymbol ()
076      {
077        return ".";
078      }
079    
080      //-------------------------------------
081      // ValueSuffix methods
082      //-------------------------------------
083      /**
084       *
085       * Returns the expression in the expression language syntax
086       **/
087      public String getExpressionString ()
088      {
089        return "." + StringLiteral.toIdentifierToken (mName);
090      }
091    
092      //-------------------------------------
093    }