< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/FilterExpr.java

Print this page


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


  58 
  59     public FilterExpr(Expression primary, List<Expression> predicates) {
  60         _primary = primary;
  61         _predicates = predicates;
  62         primary.setParent(this);
  63     }
  64 
  65     protected Expression getExpr() {
  66         if (_primary instanceof CastExpr)
  67             return ((CastExpr)_primary).getExpr();
  68         else
  69             return _primary;
  70     }
  71 
  72     public void setParser(Parser parser) {
  73         super.setParser(parser);
  74         _primary.setParser(parser);
  75         if (_predicates != null) {
  76             final int n = _predicates.size();
  77             for (int i = 0; i < n; i++) {
  78                 final Expression exp = (Expression)_predicates.get(i);
  79                 exp.setParser(parser);
  80                 exp.setParent(this);
  81             }
  82         }
  83     }
  84 
  85     public String toString() {
  86         return "filter-expr(" + _primary + ", " + _predicates + ")";
  87     }
  88 
  89     /**
  90      * Type check a FilterParentPath. If the filter is not a node-set add a
  91      * cast to node-set only if it is of reference type. This type coercion
  92      * is needed for expressions like $x where $x is a parameter reference.
  93      * All optimizations are turned off before type checking underlying
  94      * predicates.
  95      */
  96     public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  97         Type ptype = _primary.typeCheck(stable);
  98         boolean canOptimize = _primary instanceof KeyCall;


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


  58 
  59     public FilterExpr(Expression primary, List<Expression> predicates) {
  60         _primary = primary;
  61         _predicates = predicates;
  62         primary.setParent(this);
  63     }
  64 
  65     protected Expression getExpr() {
  66         if (_primary instanceof CastExpr)
  67             return ((CastExpr)_primary).getExpr();
  68         else
  69             return _primary;
  70     }
  71 
  72     public void setParser(Parser parser) {
  73         super.setParser(parser);
  74         _primary.setParser(parser);
  75         if (_predicates != null) {
  76             final int n = _predicates.size();
  77             for (int i = 0; i < n; i++) {
  78                 final Expression exp = _predicates.get(i);
  79                 exp.setParser(parser);
  80                 exp.setParent(this);
  81             }
  82         }
  83     }
  84 
  85     public String toString() {
  86         return "filter-expr(" + _primary + ", " + _predicates + ")";
  87     }
  88 
  89     /**
  90      * Type check a FilterParentPath. If the filter is not a node-set add a
  91      * cast to node-set only if it is of reference type. This type coercion
  92      * is needed for expressions like $x where $x is a parameter reference.
  93      * All optimizations are turned off before type checking underlying
  94      * predicates.
  95      */
  96     public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  97         Type ptype = _primary.typeCheck(stable);
  98         boolean canOptimize = _primary instanceof KeyCall;


< prev index next >