View Javadoc

1   package cz.cuni.amis.pogamut.usar2004.communication.messages.usarcommands;
2   
3   import java.util.*;
4   import cz.cuni.amis.pogamut.base.communication.messages.*;
5   import cz.cuni.amis.pogamut.usar2004.communication.messages.datatypes.CustomTypes.*;
6   
7   /**
8    *
9    * This is Multidrive message as a addition to Drive command
10   *
11   * Corresponding GameBots command is MULTIDRIVE.
12   *
13   */
14  public class Multidrive extends CommandMessage
15  {
16      public Multidrive(String[] Names, String[] Values)
17      {
18          if((Names.length == Values.length))
19          {
20              for(int i = 0; i < Names.length; i++)
21              {
22                  this.NameValues.put(Names[i], Values[i]);
23              }
24          }
25      }
26  
27      public Multidrive(String Name, String Value)
28      {
29          this.NameValues.put(Name, Value);
30      }
31  
32      /**
33       * <p></p>WARNING: this is empty-command constructor, you have to use
34       * setters to fill it up!
35       */
36      public Multidrive()
37      {
38      }
39      /////// Properties BEGIN
40      //Map of name/value couples.
41      protected Map<String, String> NameValues = new HashMap<String, String>();
42  
43      public Map<String, String> getNameValues()
44      {
45          return NameValues;
46      }
47  
48      public Multidrive setNameValues(Map<String, String> NameValues)
49      {
50          this.NameValues = NameValues;
51          return this;
52      }
53  
54      public Multidrive addNameValue(String Name, String Value)
55      {
56          this.NameValues.put(Name, Value);
57          return this;
58      }
59  
60      /////// Properties END
61      /////// Extra Java code BEGIN
62      /////// Additional code from xslt BEGIN
63      /////// Additional code from xslt END
64      /////// Extra Java from XML BEGIN
65      /////// Extra Java from XML END
66      /////// Extra Java code END
67      /**
68       * Cloning constructor.
69       */
70      public Multidrive(Multidrive original)
71      {
72  
73  
74          this.NameValues.putAll(original.NameValues);
75  
76      }
77  
78      @Override
79      public String toString()
80      {
81          return toMessage();
82      }
83  
84      public String toHtmlString()
85      {
86          return super.toString()
87                  + "";
88      }
89  
90      public String toMessage()
91      {
92          StringBuilder buf = new StringBuilder();
93          buf.append("MULTIDRIVE");
94  
95  
96          if(!NameValues.isEmpty())
97          {
98              Iterator it = NameValues.entrySet().iterator();
99              while(it.hasNext())
100             {
101                 Map.Entry en = (Map.Entry) it.next();
102                 buf.append(" {").append(en.getKey()).append(" ").append(en.getValue()).append("}");
103             }
104         }
105 
106         return buf.toString();
107     }
108 }