View Javadoc

1   package cz.cuni.amis.pogamut.ut2004multi.communication.worldview.objects;
2   
3   import cz.cuni.amis.pogamut.base.communication.worldview.object.WorldObjectId;
4   import cz.cuni.amis.pogamut.multi.communication.translator.event.ILocalWorldObjectUpdatedEvent;
5   import cz.cuni.amis.utils.flag.FlagInteger;
6   import cz.cuni.amis.utils.flag.ImmutableFlag;
7   
8   public class TestLocalViewableObjectImpl extends TestLocalViewableObject{
9   
10  private static FlagInteger instances = new FlagInteger(0);
11  	
12  	public static ImmutableFlag<Integer> getInstances() {
13  		return instances.getImmutable();
14  	}
15  	
16  	@Override
17  	protected void finalize() throws Throwable {
18  		super.finalize();
19  		instances.decrement(1);
20  	}
21  	
22  	protected String stringVal;
23  	protected Long longVal;
24  	protected boolean visible;
25  	
26  	public TestLocalViewableObjectImpl( WorldObjectId id, long simTime, String localString, long localLong , boolean visible)
27  	{
28  		super(id, simTime);
29  		instances.increment(1);
30  		stringVal = localString;
31  		longVal = localLong;
32  		this.visible = visible;
33  	}
34  	
35  	public TestLocalViewableObjectImpl( TestLocalViewableObject other)
36  	{
37  		super(other.getId(), other.getSimTime());
38  		instances.increment(1);
39  		this.stringVal = new String(other.getLocalString());
40  		this.longVal = other.getLocalLong();
41  		this.visible = other.isVisible();
42  	}
43  	
44  	@Override
45  	public String getLocalString() {
46  		return stringVal;
47  	}
48  
49  	@Override
50  	public long getLocalLong() {
51  		return longVal;
52  	}
53  
54  	@Override
55  	public TestLocalViewableObject clone() {
56  		return new TestLocalViewableObjectImpl(this);
57  	}
58  
59  	@Override
60  	public ILocalWorldObjectUpdatedEvent createDisappearEvent() 
61  	{
62  		TestLocalViewableObjectImpl data = new TestLocalViewableObjectImpl(this);
63  		data.visible = false;
64  		return new TestLocalViewableObjectUpdatedEvent(data, this.simTime);
65  	}
66  	
67  	@Override
68  	public boolean isVisible() {
69  		return this.visible;
70  	}
71  	
72  
73  }