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 plus 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 PlusOperator
031 extends ArithmeticOperator
032 {
033 //-------------------------------------
034 // Singleton
035 //-------------------------------------
036
037 public static final PlusOperator SINGLETON =
038 new PlusOperator ();
039
040 //-------------------------------------
041 /**
042 *
043 * Constructor
044 **/
045 public PlusOperator ()
046 {
047 }
048
049 //-------------------------------------
050 // Expression methods
051 //-------------------------------------
052 /**
053 *
054 * Returns the symbol representing the operator
055 **/
056 public String getOperatorSymbol () {
057 return "+";
058 }
059
060 //-------------------------------------
061 /**
062 *
063 * Applies the operator to the given double values, returning a double
064 **/
065 public double apply (double pLeft, double pRight) {
066 return pLeft + pRight;
067 }
068
069 //-------------------------------------
070 /**
071 *
072 * Applies the operator to the given double values, returning a double
073 **/
074 public long apply (long pLeft, long pRight) {
075 return pLeft + pRight;
076 }
077
078 //-------------------------------------
079
080 /**
081 *
082 * Applies the operator to the given BigDecimal values, returning a
083 * BigDecimal.
084 **/
085 public BigDecimal apply(BigDecimal pLeft, BigDecimal pRight) {
086 return pLeft.add(pRight);
087 }
088
089 //-------------------------------------
090
091 /**
092 *
093 * Applies the operator to the given BigInteger values, returning a
094 * BigInteger.
095 **/
096 public BigInteger apply(BigInteger pLeft, BigInteger pRight) {
097 return pLeft.add(pRight);
098 }
099
100 //-------------------------------------
101 }