Home | History | Annotate | Download | only in templates
      1 /*
      2  * Licensed to the Apache Software Foundation (ASF) under one
      3  * or more contributor license agreements. See the NOTICE file
      4  * distributed with this work for additional information
      5  * regarding copyright ownership. The ASF licenses this file
      6  * to you under the Apache License, Version 2.0 (the  "License");
      7  * you may not use this file except in compliance with the License.
      8  * You may obtain a copy of the License at
      9  *
     10  *     http://www.apache.org/licenses/LICENSE-2.0
     11  *
     12  * Unless required by applicable law or agreed to in writing, software
     13  * distributed under the License is distributed on an "AS IS" BASIS,
     14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15  * See the License for the specific language governing permissions and
     16  * limitations under the License.
     17  */
     18 /*
     19  * $Id: XUnresolvedVariableSimple.java 468643 2006-10-28 06:56:03Z minchau $
     20  */
     21 package org.apache.xalan.templates;
     22 
     23 import org.apache.xpath.Expression;
     24 import org.apache.xpath.XPathContext;
     25 import org.apache.xpath.objects.XObject;
     26 
     27 
     28 /**
     29  * This is the same as XUnresolvedVariable, but it assumes that the
     30  * context is already set up.  For use with psuedo variables.
     31  * Also, it holds an Expression object, instead of an ElemVariable.
     32  * It must only hold static context, since a single copy will be
     33  * held in the template.
     34  */
     35 public class XUnresolvedVariableSimple extends XObject
     36 {
     37     static final long serialVersionUID = -1224413807443958985L;
     38   public XUnresolvedVariableSimple(ElemVariable obj)
     39   {
     40     super(obj);
     41   }
     42 
     43 
     44   /**
     45    * For support of literal objects in xpaths.
     46    *
     47    * @param xctxt The XPath execution context.
     48    *
     49    * @return This object.
     50    *
     51    * @throws javax.xml.transform.TransformerException
     52    */
     53   public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
     54   {
     55   	Expression expr = ((ElemVariable)m_obj).getSelect().getExpression();
     56     XObject xobj = expr.execute(xctxt);
     57     xobj.allowDetachToRelease(false);
     58     return xobj;
     59   }
     60 
     61   /**
     62    * Tell what kind of class this is.
     63    *
     64    * @return CLASS_UNRESOLVEDVARIABLE
     65    */
     66   public int getType()
     67   {
     68     return CLASS_UNRESOLVEDVARIABLE;
     69   }
     70 
     71   /**
     72    * Given a request type, return the equivalent string.
     73    * For diagnostic purposes.
     74    *
     75    * @return An informational string.
     76    */
     77   public String getTypeString()
     78   {
     79     return "XUnresolvedVariableSimple (" + object().getClass().getName() + ")";
     80   }
     81 
     82 
     83 }
     84 
     85