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 org.peaseplate.TemplateRuntimeException;
23  import org.peaseplate.locator.TemplateLocator;
24  
25  public class BitwiseInclusiveOrCommand extends AbstractNumericCommand {
26  
27  	public BitwiseInclusiveOrCommand(TemplateLocator locator, int line, int column, ICommand leftCommand, ICommand rightCommand) {
28  		super(locator, line, column, leftCommand, rightCommand);
29  	}
30  
31  	/**
32  	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#getSign()
33  	 */
34  	@Override
35  	public String getSign() {
36  		return "|";
37  	}
38  
39  	/**
40  	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#calculate(java.lang.Byte, java.lang.Byte)
41  	 */
42  	@Override
43      public Byte calculate(Byte left, Byte right) throws TemplateRuntimeException {
44  		return Byte.valueOf((byte)(left.byteValue() | right.byteValue()));
45      }
46  
47  	/**
48  	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#calculate(java.lang.Short, java.lang.Short)
49  	 */
50  	@Override
51  	public Short calculate(Short left, Short right) throws TemplateRuntimeException {
52  		return Short.valueOf((short)(left.shortValue() | right.shortValue()));
53  	}
54  	
55  	/**
56  	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#calculate(java.lang.Character, java.lang.Character)
57  	 */
58  	@Override
59      public Character calculate(Character left, Character right) throws TemplateRuntimeException {
60  		return Character.valueOf((char)(left.charValue() | right.charValue()));
61      }
62  
63  	/**
64  	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#calculate(java.lang.Integer, java.lang.Integer)
65  	 */
66  	@Override
67  	public Integer calculate(Integer left, Integer right) throws TemplateRuntimeException {
68  		return Integer.valueOf(left.intValue() | right.intValue());
69  	}
70  	
71  	/**
72  	 * @see org.peaseplate.internal.lang.command.AbstractNumericCommand#calculate(java.lang.Long, java.lang.Long)
73  	 */
74  	@Override
75  	public Long calculate(Long left, Long right) throws TemplateRuntimeException {
76  		return Long.valueOf(left.longValue() | right.longValue());
77  	}
78  	
79  }