< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xpath/internal/XPathContext.java

Print this page


   1 /*
   2  * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
   3  */
   4 /*
   5  * Licensed to the Apache Software Foundation (ASF) under one or more
   6  * contributor license agreements.  See the NOTICE file distributed with
   7  * this work for additional information regarding copyright ownership.
   8  * The ASF licenses this file to You under the Apache License, Version 2.0
   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xpath.internal;
  22 


  32 import com.sun.org.apache.xml.internal.utils.IntStack;
  33 import com.sun.org.apache.xml.internal.utils.NodeVector;
  34 import com.sun.org.apache.xml.internal.utils.ObjectStack;
  35 import com.sun.org.apache.xml.internal.utils.PrefixResolver;
  36 import com.sun.org.apache.xml.internal.utils.XMLString;
  37 import com.sun.org.apache.xpath.internal.axes.SubContextList;
  38 import com.sun.org.apache.xpath.internal.objects.DTMXRTreeFrag;
  39 import com.sun.org.apache.xpath.internal.objects.XObject;
  40 import com.sun.org.apache.xpath.internal.objects.XString;
  41 import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
  42 import java.lang.reflect.Method;
  43 import java.util.ArrayList;
  44 import java.util.HashMap;
  45 import java.util.Iterator;
  46 import java.util.List;
  47 import java.util.Map;
  48 import java.util.Stack;
  49 import javax.xml.transform.ErrorListener;
  50 import javax.xml.transform.SourceLocator;
  51 import javax.xml.transform.URIResolver;
  52 import jdk.xml.internal.JdkXmlUtils;
  53 import org.xml.sax.XMLReader;
  54 
  55 /**
  56  * Default class for the runtime execution context for XPath.
  57  *
  58  * <p>This class extends DTMManager but does not directly implement it.</p>
  59  * @xsl.usage advanced
  60  * @LastModified: Oct 2017
  61  */
  62 public class XPathContext extends DTMManager // implements ExpressionContext
  63 {
  64         IntStack m_last_pushed_rtfdtm=new IntStack();
  65   /**
  66    * Stack of cached "reusable" DTMs for Result Tree Fragments.
  67    * This is a kluge to handle the problem of starting an RTF before
  68    * the old one is complete.
  69    *
  70    * %REVIEW% I'm using a Vector rather than Stack so we can reuse
  71    * the DTMs if the problem occurs multiple times. I'm not sure that's
  72    * really a net win versus discarding the DTM and starting a new one...
  73    * but the retained RTF DTM will have been tail-pruned so should be small.
  74    */
  75   private List<DTM> m_rtfdtm_stack=null;
  76   /** Index of currently active RTF DTM in m_rtfdtm_stack */
  77   private int m_which_rtfdtm=-1;
  78 
  79  /**
  80    * Most recent "reusable" DTM for Global Result Tree Fragments. No stack is


 464   /**
 465    * Get the variable stack, which is in charge of variables and
 466    * parameters.
 467    *
 468    * @return the variable stack, which should not be null.
 469    */
 470   public final VariableStack getVarStack()
 471   {
 472     return m_variableStacks;
 473   }
 474 
 475   /**
 476    * Get the variable stack, which is in charge of variables and
 477    * parameters.
 478    *
 479    * @param varStack non-null reference to the variable stack.
 480    */
 481   public final void setVarStack(VariableStack varStack)
 482   {
 483     m_variableStacks = varStack;
 484   }
 485 
 486   // ================ SourceTreeManager ===================
 487 
 488   /** The source tree manager, which associates Source objects to source
 489    *  tree nodes. */
 490   private SourceTreeManager m_sourceTreeManager = new SourceTreeManager();
 491 
 492   /**
 493    * Get the SourceTreeManager associated with this execution context.
 494    *
 495    * @return the SourceTreeManager associated with this execution context.
 496    */
 497   public final SourceTreeManager getSourceTreeManager()
 498   {
 499     return m_sourceTreeManager;
 500   }
 501 
 502   /**
 503    * Set the SourceTreeManager associated with this execution context.
 504    *
 505    * @param mgr the SourceTreeManager to be associated with this
 506    *        execution context.
 507    */
 508   public void setSourceTreeManager(SourceTreeManager mgr)
 509   {
 510     m_sourceTreeManager = mgr;
 511   }
 512 
 513   // =================================================
 514 
 515   /** The ErrorListener where errors and warnings are to be reported.   */
 516   private ErrorListener m_errorListener;
 517 
 518   /** A default ErrorListener in case our m_errorListener was not specified and our
 519    *  owner either does not have an ErrorListener or has a null one.
 520    */
 521   private ErrorListener m_defaultErrorListener;
 522 
 523   /**
 524    * Get the ErrorListener where errors and warnings are to be reported.
 525    *
 526    * @return A non-null ErrorListener reference.
 527    */
 528   public final ErrorListener getErrorListener()
 529   {
 530 


   1 /*
   2  * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
   3  */
   4 /*
   5  * Licensed to the Apache Software Foundation (ASF) under one or more
   6  * contributor license agreements.  See the NOTICE file distributed with
   7  * this work for additional information regarding copyright ownership.
   8  * The ASF licenses this file to You under the Apache License, Version 2.0
   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xpath.internal;
  22 


  32 import com.sun.org.apache.xml.internal.utils.IntStack;
  33 import com.sun.org.apache.xml.internal.utils.NodeVector;
  34 import com.sun.org.apache.xml.internal.utils.ObjectStack;
  35 import com.sun.org.apache.xml.internal.utils.PrefixResolver;
  36 import com.sun.org.apache.xml.internal.utils.XMLString;
  37 import com.sun.org.apache.xpath.internal.axes.SubContextList;
  38 import com.sun.org.apache.xpath.internal.objects.DTMXRTreeFrag;
  39 import com.sun.org.apache.xpath.internal.objects.XObject;
  40 import com.sun.org.apache.xpath.internal.objects.XString;
  41 import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
  42 import java.lang.reflect.Method;
  43 import java.util.ArrayList;
  44 import java.util.HashMap;
  45 import java.util.Iterator;
  46 import java.util.List;
  47 import java.util.Map;
  48 import java.util.Stack;
  49 import javax.xml.transform.ErrorListener;
  50 import javax.xml.transform.SourceLocator;
  51 import javax.xml.transform.URIResolver;

  52 import org.xml.sax.XMLReader;
  53 
  54 /**
  55  * Default class for the runtime execution context for XPath.
  56  *
  57  * <p>This class extends DTMManager but does not directly implement it.</p>
  58  * @xsl.usage advanced
  59  * @LastModified: Jan 2019
  60  */
  61 public class XPathContext extends DTMManager // implements ExpressionContext
  62 {
  63         IntStack m_last_pushed_rtfdtm=new IntStack();
  64   /**
  65    * Stack of cached "reusable" DTMs for Result Tree Fragments.
  66    * This is a kluge to handle the problem of starting an RTF before
  67    * the old one is complete.
  68    *
  69    * %REVIEW% I'm using a Vector rather than Stack so we can reuse
  70    * the DTMs if the problem occurs multiple times. I'm not sure that's
  71    * really a net win versus discarding the DTM and starting a new one...
  72    * but the retained RTF DTM will have been tail-pruned so should be small.
  73    */
  74   private List<DTM> m_rtfdtm_stack=null;
  75   /** Index of currently active RTF DTM in m_rtfdtm_stack */
  76   private int m_which_rtfdtm=-1;
  77 
  78  /**
  79    * Most recent "reusable" DTM for Global Result Tree Fragments. No stack is


 463   /**
 464    * Get the variable stack, which is in charge of variables and
 465    * parameters.
 466    *
 467    * @return the variable stack, which should not be null.
 468    */
 469   public final VariableStack getVarStack()
 470   {
 471     return m_variableStacks;
 472   }
 473 
 474   /**
 475    * Get the variable stack, which is in charge of variables and
 476    * parameters.
 477    *
 478    * @param varStack non-null reference to the variable stack.
 479    */
 480   public final void setVarStack(VariableStack varStack)
 481   {
 482     m_variableStacks = varStack;



























 483   }
 484 
 485   // =================================================
 486 
 487   /** The ErrorListener where errors and warnings are to be reported.   */
 488   private ErrorListener m_errorListener;
 489 
 490   /** A default ErrorListener in case our m_errorListener was not specified and our
 491    *  owner either does not have an ErrorListener or has a null one.
 492    */
 493   private ErrorListener m_defaultErrorListener;
 494 
 495   /**
 496    * Get the ErrorListener where errors and warnings are to be reported.
 497    *
 498    * @return A non-null ErrorListener reference.
 499    */
 500   public final ErrorListener getErrorListener()
 501   {
 502 


< prev index next >