001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements. See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership. The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the  "License");
007     * you may not use this file except in compliance with the License.
008     * You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    /*
019     * $Id: XUnresolvedVariableSimple.java 468643 2006-10-28 06:56:03Z minchau $
020     */
021    package org.apache.xalan.templates;
022    
023    import org.apache.xpath.Expression;
024    import org.apache.xpath.XPathContext;
025    import org.apache.xpath.objects.XObject;
026    
027    
028    /**
029     * This is the same as XUnresolvedVariable, but it assumes that the 
030     * context is already set up.  For use with psuedo variables.
031     * Also, it holds an Expression object, instead of an ElemVariable.
032     * It must only hold static context, since a single copy will be 
033     * held in the template.
034     */
035    public class XUnresolvedVariableSimple extends XObject
036    {
037        static final long serialVersionUID = -1224413807443958985L;
038      public XUnresolvedVariableSimple(ElemVariable obj)
039      {
040        super(obj);
041      }
042        
043            
044      /**
045       * For support of literal objects in xpaths.
046       *
047       * @param xctxt The XPath execution context.
048       *
049       * @return This object.
050       *
051       * @throws javax.xml.transform.TransformerException
052       */
053      public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
054      {
055            Expression expr = ((ElemVariable)m_obj).getSelect().getExpression();
056        XObject xobj = expr.execute(xctxt);
057        xobj.allowDetachToRelease(false);
058        return xobj;
059      }
060      
061      /**
062       * Tell what kind of class this is.
063       *
064       * @return CLASS_UNRESOLVEDVARIABLE
065       */
066      public int getType()
067      {
068        return CLASS_UNRESOLVEDVARIABLE;
069      }
070      
071      /**
072       * Given a request type, return the equivalent string.
073       * For diagnostic purposes.
074       *
075       * @return An informational string.
076       */
077      public String getTypeString()
078      {
079        return "XUnresolvedVariableSimple (" + object().getClass().getName() + ")";
080      }
081    
082    
083    }
084