1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.sf.magicproject.test;
21
22 import java.io.IOException;
23 import java.io.InputStream;
24
25 import net.sf.magicproject.clickable.ability.Ability;
26 import net.sf.magicproject.clickable.targetable.Targetable;
27 import net.sf.magicproject.tools.MToolKit;
28
29 /***
30 * Test if the tested targetable contains the given private named targetable.
31 *
32 * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
33 * @since 0.90
34 */
35 class HasPrivateObject extends TestObject {
36
37 /***
38 * Create an instance of HasPrivateNamedTargetable by reading a file. Offset's
39 * file must pointing on the first byte of this test <br>
40 * <ul>
41 * Structure of InputStream : Data[size]
42 * <li>idTest [1]</li>
43 * <li>used targetable for test [1]
44 * <li>named targetable + '\0' : String [...]</li>
45 * </ul>
46 *
47 * @param inputFile
48 * is the file containing this event
49 * @throws IOException
50 * if error occurred during the reading process from the specified
51 * input stream
52 */
53 HasPrivateObject(InputStream inputFile) throws IOException {
54 super(inputFile);
55 privateNamedTargetable = MToolKit.readString(inputFile);
56 }
57
58 @Override
59 public final boolean test(Ability ability, Targetable tested) {
60 return on.getTargetable(ability, tested).getPrivateNamedObject(
61 privateNamedTargetable) != null;
62 }
63
64 /***
65 * The name of looked for targetable.
66 */
67 protected String privateNamedTargetable;
68
69 }