286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 1999-2004 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A/*
286N/A * $Id: Or.java,v 1.2.4.1 2005/09/14 21:31:41 jeffsuttor Exp $
286N/A */
286N/Apackage com.sun.org.apache.xpath.internal.operations;
286N/A
286N/Aimport com.sun.org.apache.xpath.internal.XPathContext;
286N/Aimport com.sun.org.apache.xpath.internal.objects.XBoolean;
286N/Aimport com.sun.org.apache.xpath.internal.objects.XObject;
286N/A
286N/A/**
286N/A * The 'or' operation expression executer.
286N/A */
286N/Apublic class Or extends Operation
286N/A{
286N/A static final long serialVersionUID = -644107191353853079L;
286N/A
286N/A /**
286N/A * OR two expressions and return the boolean result. Override
286N/A * superclass method for optimization purposes.
286N/A *
286N/A * @param xctxt The runtime execution context.
286N/A *
286N/A * @return {@link com.sun.org.apache.xpath.internal.objects.XBoolean#S_TRUE} or
286N/A * {@link com.sun.org.apache.xpath.internal.objects.XBoolean#S_FALSE}.
286N/A *
286N/A * @throws javax.xml.transform.TransformerException
286N/A */
286N/A public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
286N/A {
286N/A
286N/A XObject expr1 = m_left.execute(xctxt);
286N/A
286N/A if (!expr1.bool())
286N/A {
286N/A XObject expr2 = m_right.execute(xctxt);
286N/A
286N/A return expr2.bool() ? XBoolean.S_TRUE : XBoolean.S_FALSE;
286N/A }
286N/A else
286N/A return XBoolean.S_TRUE;
286N/A }
286N/A
286N/A /**
286N/A * Evaluate this operation directly to a boolean.
286N/A *
286N/A * @param xctxt The runtime execution context.
286N/A *
286N/A * @return The result of the operation as a boolean.
286N/A *
286N/A * @throws javax.xml.transform.TransformerException
286N/A */
286N/A public boolean bool(XPathContext xctxt)
286N/A throws javax.xml.transform.TransformerException
286N/A {
286N/A return (m_left.bool(xctxt) || m_right.bool(xctxt));
286N/A }
286N/A
286N/A}