View Javadoc

1   package cz.cuni.amis.pogamut.ut3.communication.messages.gbinfomessages;
2    		
3    		// --- IMPORTS FROM /messages/settings/javasettings/javaimport BEGIN
4   			import java.util.*;import javax.vecmath.*;import cz.cuni.amis.pogamut.base.communication.messages.*;import cz.cuni.amis.pogamut.base.communication.worldview.*;import cz.cuni.amis.pogamut.base.communication.worldview.event.*;import cz.cuni.amis.pogamut.base.communication.worldview.object.*;import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;import cz.cuni.amis.pogamut.base.communication.translator.event.*;import cz.cuni.amis.pogamut.multi.communication.translator.event.*;import cz.cuni.amis.pogamut.base3d.worldview.object.*;import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.*;import cz.cuni.amis.pogamut.ut2004.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004.communication.translator.itemdescriptor.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType.Category;import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;import cz.cuni.amis.utils.exception.*;import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;import cz.cuni.amis.utils.SafeEquals;import cz.cuni.amis.pogamut.base.agent.*;import cz.cuni.amis.pogamut.multi.agent.*;import cz.cuni.amis.pogamut.multi.communication.worldview.property.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.property.*;import cz.cuni.amis.utils.token.*;import cz.cuni.amis.utils.*;
5   		// --- IMPORTS FROM /messages/settings/javasettings/javaimport END
6   		
7   		
8   		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] BEGIN
9   				
10  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] END
11  		
12  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=static]+classtype[@name=impl] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=static]+classtype[@name=impl] END
15      
16   		/**
17           *  
18              				Implementation of the static part of the GameBotsUT3 message EMP.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24           */
25   	public class EmptyStaticImpl 
26    						extends
27    						EmptyStatic
28  	    {
29   	
30      	
31      	
32      	/**
33      	 * Parameter-less contructor for the message.
34      	 */
35  		public EmptyStaticImpl()
36  		{
37  		}
38  	
39      	/**
40  		 * Cloning constructor from the full message.
41  		 *
42  		 * @param original
43  		 */
44  		public EmptyStaticImpl(Empty original) {		
45  			
46  			this.SimTime = original.getSimTime();			
47  		}
48  		
49  		/**
50  		 * Cloning constructor from the full message.
51  		 *
52  		 * @param original
53  		 */
54  		public EmptyStaticImpl(EmptyStaticImpl original) {		
55  			
56  			this.SimTime = original.getSimTime();
57  		}
58  		
59  			/**
60  			 * Cloning constructor from the message part.
61  			 *
62  			 * @param original
63  			 */
64  			public EmptyStaticImpl(EmptyStatic original) {
65  				
66  			}
67  		
68  						
69  						public UnrealId getId() {						
70  							return cz.cuni.amis.pogamut.ut3.communication.messages.gbinfomessages.Empty.EmptyId;
71  						}
72  					
73     				
74     				@Override
75     				public void setSimTime(long SimTime) {
76  					super.setSimTime(SimTime);
77  				}
78     			
79  	    				@Override
80  	    				public 
81  	    				EmptyStaticImpl clone() {
82  	    					return new 
83  	    					EmptyStaticImpl(this);
84  	    				}
85  	    				
86  	    				
87      	
88      	
89      	public static class EmptyStaticUpdate
90       implements IStaticWorldObjectUpdatedEvent
91  		{
92  			
93  			private EmptyStatic data;
94  			private long time;
95  			
96  			public EmptyStaticUpdate
97      (EmptyStatic source, long time)
98  			{
99  				this.data = source;
100 				this.time = time;
101 			}
102 			
103 			/**
104 			 * Simulation time in MILLI SECONDS !!!
105 			 */
106 			@Override
107 			public long getSimTime() {
108 				return time;
109 			}
110 	
111 			@Override
112 			public WorldObjectId getId() {
113 				return data.getId();
114 			}
115 			
116 			@Override
117 			public IWorldObjectUpdateResult<IStaticWorldObject> update(
118 					IStaticWorldObject object) {
119 				if ( object == null)
120 				{
121 					data = new EmptyStaticImpl(data);
122 					return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.CREATED, data);
123 				}
124 				//since static objects can't be updated, we'll just check that the object stays the same
125 				if ( object instanceof EmptyStaticImpl)
126 				{
127 					EmptyStaticImpl orig = (EmptyStaticImpl)object;
128 					//since these errors usually mean error in gamebots, we will just print an error message
129 					if ( data.isDifferentFrom(orig) )
130 					{
131 						//data.isDifferentFrom(orig);
132 						//throw new PogamutException("Trying to modify static object " + this.data.getId().toString() , this);
133 						System.out.println("!!!!!ERROR!!!!!! in static object modification. Object class : EmptyStaticImpl to see which property was different see !!!!PROPERTY UPDATE ERROR!!!!");
134 					}
135 					return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.SAME, data);
136 				}				
137 				throw new PogamutException("Unexpected object type for update, EmptyStaticImpl expected not class " + object.getClass().getSimpleName() + ".", this);
138 			}
139 		}
140 	
141     
142  		
143  		@Override
144  		public boolean isDifferentFrom(IStaticWorldObject other)
145  		{
146  			if (other == null) //early fail
147  			{
148  				return true;
149  			}
150  			else if (other == this) //early out
151  			{
152  				return false;
153  			}
154  			else
155  			{
156  				EmptyStatic obj = (EmptyStatic) other;
157 
158  				
159  			}
160  			return false;
161  		}
162  	 
163  		
164  	    public String toString() {
165             return
166             	super.toString() + "[" +
167             	
168 				"]";           		
169         }
170  	
171  		
172  		public String toHtmlString() {
173  			return super.toString() + "[<br/>" +
174             	
175 				"<br/>]";     
176 		}
177  	
178  		
179  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
180         	
181 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
182 		
183 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=static+classtype[@name=impl]) ---
184 	        
185 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=static+classtype[@name=impl]) ---        	            	
186  	
187 		}
188