1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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 SubstractCommand extends AbstractNumericCommand {
29
30 public SubstractCommand(TemplateLocator locator, int line, int column, ICommand leftCommand, ICommand rightCommand) {
31 super(locator, line, column, leftCommand, rightCommand);
32 }
33
34
35
36
37 @Override
38 public String getSign() {
39 return "-";
40 }
41
42
43
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
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
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
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
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
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
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
100
101 @Override
102 public BigDecimal calculate(BigDecimal left, BigDecimal right) throws TemplateRuntimeException {
103 return left.subtract(right);
104 }
105
106
107
108
109 @Override
110 public BigInteger calculate(BigInteger left, BigInteger right) throws TemplateRuntimeException {
111 return left.subtract(right);
112 }
113
114 }