001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.commons.el;
018    
019    import java.math.BigDecimal;
020    import java.math.BigInteger;
021    
022    /**
023     *
024     * <p>The implementation of the multiply operator
025     * 
026     * @author Nathan Abramson - Art Technology Group
027     * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: bayard $
028     **/
029    
030    public class MultiplyOperator
031      extends ArithmeticOperator
032    {
033      //-------------------------------------
034      // Singleton
035      //-------------------------------------
036    
037      public static final MultiplyOperator SINGLETON =
038        new MultiplyOperator ();
039    
040      //-------------------------------------
041      /**
042       *
043       * Constructor
044       **/
045      public MultiplyOperator ()
046      {
047      }
048    
049      //-------------------------------------
050      // Expression methods
051      //-------------------------------------
052      /**
053       *
054       * Returns the symbol representing the operator
055       **/
056      public String getOperatorSymbol ()
057      {
058        return "*";
059      }
060    
061      //-------------------------------------
062      /**
063       *
064       * Applies the operator to the given double values, returning a double
065       **/
066      public double apply (double pLeft,
067                           double pRight
068                           )
069      {
070        return pLeft * pRight;
071      }
072      
073      //-------------------------------------
074      /**
075       *
076       * Applies the operator to the given double values, returning a double
077       **/
078      public long apply (long pLeft,
079                         long pRight
080                         )
081      {
082        return pLeft * pRight;
083      }
084      
085      //-------------------------------------
086    
087        /**
088         *
089         * Applies the operator to the given BigDecimal values, returning a BigDecimal.
090         **/
091        public BigDecimal apply(BigDecimal pLeft,
092                                BigDecimal pRight
093                                ) {
094            return pLeft.multiply(pRight);
095        }
096    
097        //-------------------------------------
098    
099        /**
100         *
101         * Applies the operator to the given BigInteger values, returning a BigInteger.
102         **/
103        public BigInteger apply(BigInteger pLeft,
104                                BigInteger pRight
105                                ) {
106            return pLeft.multiply(pRight);
107        }
108    
109        //-------------------------------------
110    }