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.XNumber; 26import com.sun.org.apache.xpath.internal.objects.XObject; 27 28/** 29 * The 'number()' operation expression executer. 30 */ 31public class Number extends UnaryOperation 32{ 33 static final long serialVersionUID = 7196954482871619765L; 34 35 /** 36 * Apply the operation to two operands, and return the result. 37 * 38 * 39 * @param right non-null reference to the evaluated right operand. 40 * 41 * @return non-null reference to the XObject that represents the result of the operation. 42 * 43 * @throws javax.xml.transform.TransformerException 44 */ 45 public XObject operate(XObject right) throws javax.xml.transform.TransformerException 46 { 47 48 if (XObject.CLASS_NUMBER == right.getType()) 49 return right; 50 else 51 return new XNumber(right.num()); 52 } 53 54 /** 55 * Evaluate this operation directly to a double. 56 * 57 * @param xctxt The runtime execution context. 58 * 59 * @return The result of the operation as a double. 60 * 61 * @throws javax.xml.transform.TransformerException 62 */ 63 public double num(XPathContext xctxt) 64 throws javax.xml.transform.TransformerException 65 { 66 67 return m_right.num(xctxt); 68 } 69 70} 71