View Javadoc

1   /*
2    * This file is part of Pease Plate Template Engine.
3    * 
4    * Pease Plate Template Engine is free software: you can redistribute
5    * it and/or modify it under the terms of the GNU Lesser General 
6    * Public License as published by the Free Software Foundation, 
7    * either version 3 of the License, or any later version.
8    * 
9    * Pease Plate Template Engine is distributed in the hope that it 
10   * will be useful, but WITHOUT ANY WARRANTY; without even the implied
11   * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12   * See the GNU Lesser General Public License for more details.
13   * 
14   * You should have received a copy of the GNU Lesser General Public 
15   * License along with Pease Plate Template Engine. If not, see 
16   * <http://www.gnu.org/licenses/>.
17   * 
18   * Copyright (c) 2008 Manfred HANTSCHEL
19   */
20  package org.peaseplate.internal.lang.command;
21  
22  import java.math.BigDecimal;
23  import java.math.BigInteger;
24  
25  import org.peaseplate.TemplateRuntimeException;
26  import org.peaseplate.locator.TemplateLocator;
27  
28  public class MultiplyCommand extends AbstractNumericCommand {
29  
30  	public MultiplyCommand(TemplateLocator locator, int line, int column, ICommand leftCommand, ICommand rightCommand) {
31  		super(locator, line, column, leftCommand, rightCommand);
32  	}
33  
34  	/**
35  	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#getSign()
36  	 */
37  	@Override
38  	public String getSign() {
39  		return "*";
40  	}
41  
42  	/**
43  	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#calculate(java.lang.Byte, java.lang.Byte)
44  	 */
45  	@Override
46      public Byte calculate(Byte left, Byte right) throws TemplateRuntimeException {
47  		return Byte.valueOf((byte)(left.byteValue() * right.byteValue()));
48      }
49  
50  	/**
51  	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#calculate(java.lang.Short, java.lang.Short)
52  	 */
53  	@Override
54  	public Short calculate(Short left, Short right) throws TemplateRuntimeException {
55  		return Short.valueOf((short)(left.shortValue() * right.shortValue()));
56  	}
57  	
58  	/**
59  	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#calculate(java.lang.Character, java.lang.Character)
60  	 */
61  	@Override
62      public Character calculate(Character left, Character right) throws TemplateRuntimeException {
63  		return Character.valueOf((char)(left.charValue() * right.charValue()));
64      }
65  
66  	/**
67  	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#calculate(java.lang.Integer, java.lang.Integer)
68  	 */
69  	@Override
70  	public Integer calculate(Integer left, Integer right) throws TemplateRuntimeException {
71  		return Integer.valueOf(left.intValue() * right.intValue());
72  	}
73  	
74  	/**
75  	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#calculate(java.lang.Long, java.lang.Long)
76  	 */
77  	@Override
78  	public Long calculate(Long left, Long right) throws TemplateRuntimeException {
79  		return Long.valueOf(left.longValue() * right.longValue());
80  	}
81  	
82  	/**
83  	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#calculate(java.lang.Float, java.lang.Float)
84  	 */
85  	@Override
86  	public Float calculate(Float left, Float right) throws TemplateRuntimeException {
87  		return Float.valueOf(left.floatValue() * right.floatValue());
88  	}
89  	
90  	/**
91  	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#calculate(java.lang.Double, java.lang.Double)
92  	 */
93  	@Override
94      public Double calculate(Double left, Double right) throws TemplateRuntimeException {
95  		return Double.valueOf(left.doubleValue() * right.doubleValue());
96      }
97  
98  	/**
99  	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#calculate(java.math.BigDecimal, java.math.BigDecimal)
100 	 */
101 	@Override
102 	public BigDecimal calculate(BigDecimal left, BigDecimal right) throws TemplateRuntimeException {
103 		return left.multiply(right);
104 	}
105 	
106 	/**
107 	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#calculate(java.math.BigInteger, java.math.BigInteger)
108 	 */
109 	@Override
110 	public BigInteger calculate(BigInteger left, BigInteger right) throws TemplateRuntimeException {
111 		return left.multiply(right);
112 	}
113 	
114 }