1/* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 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 22package com.sun.org.apache.xpath.internal.operations; 23 24import com.sun.org.apache.xpath.internal.XPathContext; 25import com.sun.org.apache.xpath.internal.objects.XBoolean; 26import com.sun.org.apache.xpath.internal.objects.XObject; 27 28/** 29 * The 'and' operation expression executer. 30 */ 31public class And extends Operation 32{ 33 static final long serialVersionUID = 392330077126534022L; 34 35 /** 36 * AND two expressions and return the boolean result. Override 37 * superclass method for optimization purposes. 38 * 39 * @param xctxt The runtime execution context. 40 * 41 * @return {@link com.sun.org.apache.xpath.internal.objects.XBoolean#S_TRUE} or 42 * {@link com.sun.org.apache.xpath.internal.objects.XBoolean#S_FALSE}. 43 * 44 * @throws javax.xml.transform.TransformerException 45 */ 46 public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException 47 { 48 49 XObject expr1 = m_left.execute(xctxt); 50 51 if (expr1.bool()) 52 { 53 XObject expr2 = m_right.execute(xctxt); 54 55 return expr2.bool() ? XBoolean.S_TRUE : XBoolean.S_FALSE; 56 } 57 else 58 return XBoolean.S_FALSE; 59 } 60 61 /** 62 * Evaluate this operation directly to a boolean. 63 * 64 * @param xctxt The runtime execution context. 65 * 66 * @return The result of the operation as a boolean. 67 * 68 * @throws javax.xml.transform.TransformerException 69 */ 70 public boolean bool(XPathContext xctxt) 71 throws javax.xml.transform.TransformerException 72 { 73 return (m_left.bool(xctxt) && m_right.bool(xctxt)); 74 } 75 76} 77