1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package net.sf.magicproject.test;
23
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.util.Map;
27
28 import net.sf.magicproject.annotation.XmlTestElement;
29 import net.sf.magicproject.clickable.ability.Ability;
30 import net.sf.magicproject.clickable.targetable.Targetable;
31 import net.sf.magicproject.expression.Expression;
32
33 /***
34 * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
35 * @since 0.54
36 */
37 @XmlTestElement(id = IdTest.SUP)
38 public class Sup extends TestExpr {
39
40 /***
41 * Create an instance of Sup by reading a file. Offset's file must pointing on
42 * the first byte of this test <br>
43 * <ul>
44 * Structure of InputStream : Data[size]
45 * <li>left value,idToken [2]</li>
46 * <li>right value, idToken [2]</li>
47 * </ul>
48 *
49 * @param inputFile
50 * is the file containing this event
51 * @throws IOException
52 * if error occurred during the reading process from the specified
53 * input stream
54 */
55 Sup(InputStream inputFile) throws IOException {
56 super(inputFile);
57 }
58
59 /***
60 * Create a new instance of Sup given left and right expression.
61 *
62 * @param leftExpression
63 * the left expression of this test.
64 * @param rightExpression
65 * the right expression of this test.
66 */
67 private Sup(Expression leftExpression, Expression rightExpression) {
68 super(leftExpression, rightExpression);
69 }
70
71 @Override
72 public Test getConstraintTest(Map<String, Expression> values) {
73 return new Sup(leftExpression.getConstraintExpression(values),
74 rightExpression.getConstraintExpression(values));
75 }
76
77 @Override
78 public boolean test(Ability ability, Targetable tested) {
79 return getLeftValue(ability, tested) > getRightValue(ability, tested);
80 }
81
82 @Override
83 public String toString() {
84 return "(" + leftExpression.toString() + " > " + rightExpression.toString()
85 + ")";
86 }
87 }