Coverage Report - pt.digitalis.dif.controller.objects.ClientDescriptor
 
Classes in this File Line Coverage Branch Coverage Complexity
ClientDescriptor
0%
0/51
N/A
1
 
 1  0
 /**
 2  
  * - Digitalis Internal Framework v2.0 - (C) 2007, Digitalis Informatica. Distribuicao e Gestao de Informatica, Lda.
 3  
  * Estrada de Paco de Arcos num.9 - Piso -1 2780-666 Paco de Arcos Telefone: (351) 21 4408990 Fax: (351) 21 4408999
 4  
  * http://www.digitalis.pt
 5  
  */
 6  
 package pt.digitalis.dif.controller.objects;
 7  
 
 8  
 import java.util.ArrayList;
 9  
 import java.util.HashMap;
 10  
 import java.util.List;
 11  
 import java.util.Map;
 12  
 
 13  
 import pt.digitalis.dif.utils.ObjectFormatter;
 14  
 
 15  
 /**
 16  
  * Request client descriptor. It can be a browser, a SMS provider, a web service, a portal, etc...
 17  
  * 
 18  
  * @author Pedro Viegas <a href="mailto:pviegas@digitalis.pt">pviegas@digitalis.pt</a>
 19  
  * @author Rodrigo Gonçalves <a href="mailto:rgoncalves@digitalis.pt">rgoncalves@digitalis.pt</a>
 20  
  * @created Nov 29, 2007
 21  
  */
 22  0
 public class ClientDescriptor {
 23  
 
 24  
     /** The attributes/configuration list of the client */
 25  0
     private Map<String, Object> attributes = new HashMap<String, Object>();
 26  
 
 27  
     /** The list of languages supported by the client. */
 28  0
     private List<String> clientSupportedLanguages = new ArrayList<String>();
 29  
 
 30  
     /** The feature list of the client */
 31  0
     private Map<String, Object> features = new HashMap<String, Object>();
 32  
 
 33  
     /** The hardware of the client */
 34  
     private String hardware;
 35  
 
 36  
     /** The name of the Client */
 37  
     private String name;
 38  
 
 39  
     /** The software of the client */
 40  
     private String software;
 41  
 
 42  
     /** The client browser is supported */
 43  
     private Boolean supportedBrowser;
 44  
 
 45  
     /** The name of the software vendor */
 46  
     private String vendor;
 47  
 
 48  
     /** The version of the software of the client */
 49  
     private String version;
 50  
 
 51  
     /**
 52  
      * Adds a new attribute
 53  
      * 
 54  
      * @param key
 55  
      *            the attribute key
 56  
      * @param value
 57  
      *            the attribute value
 58  
      */
 59  
     public void addAttribute(String key, Object value)
 60  
     {
 61  0
         this.attributes.put(key, value);
 62  0
     }
 63  
 
 64  
     /**
 65  
      * Adds a new client supported language.
 66  
      * 
 67  
      * @param language
 68  
      *            the new supported language
 69  
      */
 70  
     public void addClientSupportedLanguage(String language)
 71  
     {
 72  0
         this.clientSupportedLanguages.add(language);
 73  0
     }
 74  
 
 75  
     /**
 76  
      * Adds a new feature
 77  
      * 
 78  
      * @param key
 79  
      *            the feature key
 80  
      * @param value
 81  
      *            the feature value
 82  
      */
 83  
     public void addFeature(String key, Object value)
 84  
     {
 85  0
         this.features.put(key, value);
 86  0
     }
 87  
 
 88  
     /**
 89  
      * Gets an attribute
 90  
      * 
 91  
      * @param key
 92  
      *            the attribute key
 93  
      * @return the object if existent
 94  
      */
 95  
     public Object getAttribute(String key)
 96  
     {
 97  0
         return this.attributes.get(key);
 98  
     }
 99  
 
 100  
     /**
 101  
      * @return the attributes
 102  
      */
 103  
     public Map<String, Object> getAttributes()
 104  
     {
 105  0
         return attributes;
 106  
     }
 107  
 
 108  
     /**
 109  
      * Returns the list of client supported languages.
 110  
      * 
 111  
      * @return the list of client supported languages
 112  
      */
 113  
     public List<String> getClientSupportedLanguages()
 114  
     {
 115  0
         return this.clientSupportedLanguages;
 116  
     }
 117  
 
 118  
     /**
 119  
      * Gets an feature
 120  
      * 
 121  
      * @param key
 122  
      *            the feature key
 123  
      * @return the object if existent
 124  
      */
 125  
     public Object getFeature(String key)
 126  
     {
 127  0
         return this.features.get(key);
 128  
     }
 129  
 
 130  
     /**
 131  
      * @return the features
 132  
      */
 133  
     public Map<String, Object> getFeatures()
 134  
     {
 135  0
         return features;
 136  
     }
 137  
 
 138  
     /**
 139  
      * @return the hardware
 140  
      */
 141  
     public String getHardware()
 142  
     {
 143  0
         return hardware;
 144  
     }
 145  
 
 146  
     /**
 147  
      * @return the name
 148  
      */
 149  
     public String getName()
 150  
     {
 151  0
         return name;
 152  
     }
 153  
 
 154  
     /**
 155  
      * @return the software
 156  
      */
 157  
     public String getSoftware()
 158  
     {
 159  0
         return software;
 160  
     }
 161  
 
 162  
     /**
 163  
      * @return the supportedBrowser
 164  
      */
 165  
     public Boolean getSupportedBrowser()
 166  
     {
 167  0
         return supportedBrowser;
 168  
     }
 169  
 
 170  
     /**
 171  
      * @return the vendor
 172  
      */
 173  
     public String getVendor()
 174  
     {
 175  0
         return vendor;
 176  
     }
 177  
 
 178  
     /**
 179  
      * @return the version
 180  
      */
 181  
     public String getVersion()
 182  
     {
 183  0
         return version;
 184  
     }
 185  
 
 186  
     /**
 187  
      * Checks if a given language is supported by the client.
 188  
      * 
 189  
      * @param language
 190  
      *            the language to check
 191  
      * @return T if the language is supported, F otherwise
 192  
      */
 193  
     public boolean isLanguageSupported(String language)
 194  
     {
 195  0
         return this.clientSupportedLanguages.contains(language);
 196  
     }
 197  
 
 198  
     /**
 199  
      * Removes a client supported language.
 200  
      * 
 201  
      * @param language
 202  
      *            the language to remove
 203  
      */
 204  
     public void removeClientSupportedLanguage(String language)
 205  
     {
 206  0
         this.clientSupportedLanguages.remove(language);
 207  0
     }
 208  
 
 209  
     /**
 210  
      * @param attributes
 211  
      *            the attributes to set
 212  
      */
 213  
     public void setAttributes(Map<String, Object> attributes)
 214  
     {
 215  0
         this.attributes = attributes;
 216  0
     }
 217  
 
 218  
     /**
 219  
      * Adds a new list of client supported language.
 220  
      * 
 221  
      * @param supportedLanguages
 222  
      *            the new supported language
 223  
      */
 224  
     public void setClientSupportedLanguages(List<String> supportedLanguages)
 225  
     {
 226  0
         this.clientSupportedLanguages = supportedLanguages;
 227  0
     }
 228  
 
 229  
     /**
 230  
      * @param features
 231  
      *            the features to set
 232  
      */
 233  
     public void setFeatures(Map<String, Object> features)
 234  
     {
 235  0
         this.features = features;
 236  0
     }
 237  
 
 238  
     /**
 239  
      * @param hardware
 240  
      *            the hardware to set
 241  
      */
 242  
     public void setHardware(String hardware)
 243  
     {
 244  0
         this.hardware = hardware;
 245  0
     }
 246  
 
 247  
     /**
 248  
      * @param name
 249  
      *            the name to set
 250  
      */
 251  
     public void setName(String name)
 252  
     {
 253  0
         this.name = name;
 254  0
     }
 255  
 
 256  
     /**
 257  
      * @param software
 258  
      *            the software to set
 259  
      */
 260  
     public void setSoftware(String software)
 261  
     {
 262  0
         this.software = software;
 263  0
     }
 264  
 
 265  
     /**
 266  
      * @param supportedBrowser
 267  
      */
 268  
     public void setSupportedBrowser(Boolean supportedBrowser)
 269  
     {
 270  0
         this.supportedBrowser = supportedBrowser;
 271  0
     }
 272  
 
 273  
     /**
 274  
      * @param vendor
 275  
      *            the vendor to set
 276  
      */
 277  
     public void setVendor(String vendor)
 278  
     {
 279  0
         this.vendor = vendor;
 280  0
     }
 281  
 
 282  
     /**
 283  
      * @param version
 284  
      *            the version to set
 285  
      */
 286  
     public void setVersion(String version)
 287  
     {
 288  0
         this.version = version;
 289  0
     }
 290  
 
 291  
     /**
 292  
      * @see java.lang.Object#toString()
 293  
      */
 294  
     @Override
 295  
     public String toString()
 296  
     {
 297  0
         ObjectFormatter formatter = new ObjectFormatter();
 298  
 
 299  0
         formatter.addItem("Name", getName());
 300  0
         formatter.addItemIfNotNull("software", software);
 301  0
         formatter.addItemIfNotNull("version", version);
 302  0
         formatter.addItemIfNotNull("hardware", hardware);
 303  
 
 304  0
         formatter.addItemIfNotNull("Features", features);
 305  0
         formatter.addItemIfNotNull("Attributes", attributes);
 306  
 
 307  0
         return formatter.getFormatedObject();
 308  
     }
 309  
 }