Wrapper for String valued working memory elements. @author voigtjr
| 10 | * |
| 11 | */ |
| 12 | public class StringWme implements Wme |
| 13 | { |
| 14 | /** |
| 15 | * Create working memory element instance with no value. The value will be |
| 16 | * set (and underlying SML Wme created) on first update. |
| 17 | * |
| 18 | * @param parent |
| 19 | * Parent identifier |
| 20 | * @param attr |
| 21 | * Attribute |
| 22 | * @return Wme ready for update |
| 23 | */ |
| 24 | public static StringWme newInstance(Identifier parent, String attr) |
| 25 | { |
| 26 | return new StringWme(parent, attr); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Create working memory element instance with known initial value. |
| 31 | * |
| 32 | * @param parent |
| 33 | * Parent identifier |
| 34 | * @param attr |
| 35 | * Attribute |
| 36 | * @param val |
| 37 | * Initial value |
| 38 | * @return Wme ready for update |
| 39 | */ |
| 40 | public static StringWme newInstance(Identifier parent, String attr, |
| 41 | String val) |
| 42 | { |
| 43 | StringWme temp = new StringWme(parent, attr); |
| 44 | temp.update(val); |
| 45 | return temp; |
| 46 | } |
| 47 | |
| 48 | private final Identifier parent; |
| 49 | |
| 50 | private final String attr; |
| 51 | |
| 52 | private StringElement wme; |
| 53 | |
| 54 | private StringWme(Identifier parent, String attr) |
| 55 | { |
| 56 | this.parent = parent; |
| 57 | this.attr = attr; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * <p> |
| 62 | * Update to possibly new value. See Agent.BlinkIfNoChange() |
| 63 | * |
| 64 | * @param val |
| 65 | * The new value |
| 66 | * @throws NullPointerException |
| 67 | * if val is null |
| 68 | */ |
| 69 | public void update(String val) |
nothing calls this directly
no outgoing calls
no test coverage detected