Coverage Report - org.jtheque.core.managers.core.application.XMLApplication
 
Classes in this File Line Coverage Branch Coverage Complexity
XMLApplication
0 %
0/33
N/A
1
 
 1  
 package org.jtheque.core.managers.core.application;
 2  
 
 3  
 import org.jtheque.core.managers.resource.ImageDescriptor;
 4  
 import org.jtheque.core.managers.resource.ImageType;
 5  
 import org.jtheque.utils.bean.Version;
 6  
 import org.jtheque.utils.collections.ArrayUtils;
 7  
 
 8  
 import java.util.HashMap;
 9  
 import java.util.Map;
 10  
 
 11  
 /*
 12  
  * This file is part of JTheque.
 13  
  *            
 14  
  * JTheque is free software: you can redistribute it and/or modify
 15  
  * it under the terms of the GNU General Public License as published by
 16  
  * the Free Software Foundation, either version 3 of the License. 
 17  
  *
 18  
  * JTheque is distributed in the hope that it will be useful,
 19  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 20  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 21  
  * GNU General Public License for more details.
 22  
  *
 23  
  * You should have received a copy of the GNU General Public License
 24  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 25  
  */
 26  
 
 27  
 /**
 28  
  * An XML Application. It seems a JTheque Core Application who's read from an XML file.
 29  
  *
 30  
  * @author Baptiste Wicht
 31  
  */
 32  0
 public final class XMLApplication implements Application {
 33  
     private Version version;
 34  
 
 35  
     private ApplicationProperties applicationProperties;
 36  
 
 37  
     private ImageDescriptor icon;
 38  
     private ImageDescriptor logo;
 39  
 
 40  
     private boolean displayLicence;
 41  
 
 42  0
     private String[] supportedLanguages = {"fr", "en"};
 43  
 
 44  0
     private final Map<String, String> properties = new HashMap<String, String>(5);
 45  
 
 46  
     @Override
 47  
     public Version getVersion(){
 48  0
         return version;
 49  
     }
 50  
 
 51  
     @Override
 52  
     public String getAuthor(){
 53  0
         return applicationProperties.getAuthor();
 54  
     }
 55  
 
 56  
     @Override
 57  
     public String getName(){
 58  0
         return applicationProperties.getName();
 59  
     }
 60  
 
 61  
     @Override
 62  
     public String getSite(){
 63  0
         return applicationProperties.getSite();
 64  
     }
 65  
 
 66  
     @Override
 67  
     public String getEmail(){
 68  0
         return applicationProperties.getEmail();
 69  
     }
 70  
 
 71  
     @Override
 72  
     public String getCopyright(){
 73  0
         return applicationProperties.getCopyright();
 74  
     }
 75  
 
 76  
     @Override
 77  
     public String getLogo(){
 78  0
         return logo.getImage();
 79  
     }
 80  
 
 81  
     @Override
 82  
     public ImageType getLogoType(){
 83  0
         return logo.getType();
 84  
     }
 85  
 
 86  
     @Override
 87  
     public String getWindowIcon(){
 88  0
         return icon.getImage();
 89  
     }
 90  
 
 91  
     @Override
 92  
     public ImageType getWindowIconType(){
 93  0
         return icon.getType();
 94  
     }
 95  
 
 96  
     @Override
 97  
     public boolean isDisplayLicence(){
 98  0
         return displayLicence;
 99  
     }
 100  
 
 101  
     @Override
 102  
     public String getRepository(){
 103  0
         return getProperty("application.repository");
 104  
     }
 105  
 
 106  
     @Override
 107  
     public String getMessageFileURL(){
 108  0
         return getProperty("application.messages");
 109  
     }
 110  
 
 111  
     @Override
 112  
     public String[] getSupportedLanguages(){
 113  0
         return ArrayUtils.copyOf(supportedLanguages);
 114  
     }
 115  
 
 116  
     @Override
 117  
     public String getProperty(String key){
 118  0
         return properties.get(key);
 119  
     }
 120  
 
 121  
     @Override
 122  
     public String getLicenceFilePath(){
 123  0
         return getProperty("application.licence");
 124  
     }
 125  
 
 126  
     @Override
 127  
     public String getFolderPath(){
 128  0
         return getProperty("application.folder.path");
 129  
     }
 130  
 
 131  
     //Package protected methods to fill the application
 132  
 
 133  
     /**
 134  
      * Set the property value.
 135  
      *
 136  
      * @param name The name of the property.
 137  
      * @param value The value of the property.
 138  
      */
 139  
     void setProperty(String name, String value){
 140  0
         properties.put(name, value);
 141  0
     }
 142  
 
 143  
     /**
 144  
      * Set that the application must diplay licence.
 145  
      */
 146  
     void displayLicence(){
 147  0
         displayLicence = true;
 148  0
     }
 149  
 
 150  
     /**
 151  
      * Set the version of the application.
 152  
      *
 153  
      * @param version The version of the application.
 154  
      */
 155  
     void setVersion(Version version){
 156  0
         this.version = version;
 157  0
     }
 158  
 
 159  
     /**
 160  
      * Set the supported languages of the application.
 161  
      *
 162  
      * @param supportedLanguages The supported languages of the application.
 163  
      */
 164  
     void setSupportedLanguages(String[] supportedLanguages){
 165  0
         this.supportedLanguages = ArrayUtils.copyOf(supportedLanguages);
 166  0
     }
 167  
 
 168  
     /**
 169  
      * Set the application internationalisation of the application.
 170  
      *
 171  
      * @param applicationProperties The application properties. 
 172  
      */
 173  
     void setApplicationProperties(ApplicationProperties applicationProperties){
 174  0
         this.applicationProperties = applicationProperties;
 175  0
     }
 176  
 
 177  
     /**
 178  
      * Set the images of the application. 
 179  
      *
 180  
      * @param logo The logo of the application.
 181  
      * @param icon The icon of the application. 
 182  
      */
 183  
     void setImages(ImageDescriptor logo, ImageDescriptor icon){
 184  0
         this.logo = logo;
 185  0
         this.icon = icon;
 186  0
     }
 187  
 }