893N/A/*
3261N/A * reserved comment block
893N/A * DO NOT REMOVE OR ALTER!
893N/A */
893N/A/*
893N/A * Copyright 1999-2004 The Apache Software Foundation.
893N/A *
893N/A * Licensed under the Apache License, Version 2.0 (the "License");
893N/A * you may not use this file except in compliance with the License.
893N/A * You may obtain a copy of the License at
893N/A *
893N/A * http://www.apache.org/licenses/LICENSE-2.0
893N/A *
893N/A * Unless required by applicable law or agreed to in writing, software
893N/A * distributed under the License is distributed on an "AS IS" BASIS,
893N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
893N/A * See the License for the specific language governing permissions and
893N/A * limitations under the License.
2362N/A */
2362N/A/*
2362N/A * $Id: Bool.java,v 1.2.4.1 2005/09/14 21:31:43 jeffsuttor Exp $
893N/A */
893N/Apackage com.sun.org.apache.xpath.internal.operations;
893N/A
1580N/Aimport com.sun.org.apache.xpath.internal.XPathContext;
893N/Aimport com.sun.org.apache.xpath.internal.objects.XBoolean;
893N/Aimport com.sun.org.apache.xpath.internal.objects.XObject;
893N/A
893N/A/**
893N/A * The 'boolean()' operation expression executer.
893N/A */
2546N/Apublic class Bool extends UnaryOperation
893N/A{
893N/A static final long serialVersionUID = 44705375321914635L;
893N/A
893N/A /**
893N/A * Apply the operation to two operands, and return the result.
893N/A *
893N/A *
893N/A * @param right non-null reference to the evaluated right operand.
893N/A *
893N/A * @return non-null reference to the XObject that represents the result of the operation.
893N/A *
893N/A * @throws javax.xml.transform.TransformerException
893N/A */
893N/A public XObject operate(XObject right) throws javax.xml.transform.TransformerException
893N/A {
2546N/A
1434N/A if (XObject.CLASS_BOOLEAN == right.getType())
893N/A return right;
2546N/A else
2546N/A return right.bool() ? XBoolean.S_TRUE : XBoolean.S_FALSE;
2546N/A }
1434N/A
893N/A /**
893N/A * Evaluate this operation directly to a boolean.
893N/A *
893N/A * @param xctxt The runtime execution context.
893N/A *
893N/A * @return The result of the operation as a boolean.
893N/A *
893N/A * @throws javax.xml.transform.TransformerException
893N/A */
893N/A public boolean bool(XPathContext xctxt)
893N/A throws javax.xml.transform.TransformerException
2546N/A {
2546N/A return m_right.bool(xctxt);
2546N/A }
2546N/A
2546N/A}
2546N/A