Coverage Report - org.apache.maven.plugin.registry.PluginRegistry
 
Classes in this File Line Coverage Branch Coverage Complexity
PluginRegistry
0%
0/40
0%
0/14
1.438
 
 1  
 /*
 2  
  * $Id$
 3  
  */
 4  
 
 5  
 package org.apache.maven.plugin.registry;
 6  
 
 7  
   //---------------------------------/
 8  
  //- Imported classes and packages -/
 9  
 //---------------------------------/
 10  
 
 11  
 import java.util.Date;
 12  
 
 13  
 /**
 14  
  * Root element of the plugin registry file.
 15  
  * 
 16  
  * @version $Revision$ $Date$
 17  
  */
 18  0
 public class PluginRegistry extends TrackableBase 
 19  
 implements java.io.Serializable
 20  
 {
 21  
 
 22  
 
 23  
       //--------------------------/
 24  
      //- Class/Member Variables -/
 25  
     //--------------------------/
 26  
 
 27  
     /**
 28  
      * 
 29  
      *             Specifies how often to check for plugin updates.
 30  
      * Valid values are: never, always, interval:XXX.
 31  
      *             For the interval specification, XXX denotes a
 32  
      * terse interval specification, such as 4h.
 33  
      *             Where h=hours, m=minutes, d=days, w=weeks. The
 34  
      * interval period should be specified in descending
 35  
      *             order of granularity, like this: '[n]w [n]d [n]h
 36  
      * [n]m'. Any omitted level of granularity will be
 37  
      *             assumed to be a zero value.
 38  
      *           
 39  
      */
 40  0
     private String updateInterval = "never";
 41  
 
 42  
     /**
 43  
      * Specifies whether the user should be prompted to update
 44  
      * plugins.
 45  
      */
 46  
     private String autoUpdate;
 47  
 
 48  
     /**
 49  
      * Whether to resolve plugin versions using LATEST metadata.
 50  
      */
 51  
     private String checkLatest;
 52  
 
 53  
     /**
 54  
      * Field plugins.
 55  
      */
 56  
     private java.util.List plugins;
 57  
 
 58  
 
 59  
       //-----------/
 60  
      //- Methods -/
 61  
     //-----------/
 62  
 
 63  
     /**
 64  
      * Method addPlugin.
 65  
      * 
 66  
      * @param plugin
 67  
      */
 68  
     public void addPlugin( Plugin plugin )
 69  
     {
 70  0
         if ( !(plugin instanceof Plugin) )
 71  
         {
 72  0
             throw new ClassCastException( "PluginRegistry.addPlugins(plugin) parameter must be instanceof " + Plugin.class.getName() );
 73  
         }
 74  0
         getPlugins().add( plugin );
 75  0
     } //-- void addPlugin( Plugin ) 
 76  
 
 77  
     /**
 78  
      * Get specifies whether the user should be prompted to update
 79  
      * plugins.
 80  
      * 
 81  
      * @return String
 82  
      */
 83  
     public String getAutoUpdate()
 84  
     {
 85  0
         return this.autoUpdate;
 86  
     } //-- String getAutoUpdate() 
 87  
 
 88  
     /**
 89  
      * Get whether to resolve plugin versions using LATEST
 90  
      * metadata.
 91  
      * 
 92  
      * @return String
 93  
      */
 94  
     public String getCheckLatest()
 95  
     {
 96  0
         return this.checkLatest;
 97  
     } //-- String getCheckLatest() 
 98  
 
 99  
     /**
 100  
      * Method getPlugins.
 101  
      * 
 102  
      * @return java.util.List
 103  
      */
 104  
     public java.util.List getPlugins()
 105  
     {
 106  0
         if ( this.plugins == null )
 107  
         {
 108  0
             this.plugins = new java.util.ArrayList();
 109  
         }
 110  
     
 111  0
         return this.plugins;
 112  
     } //-- java.util.List getPlugins() 
 113  
 
 114  
     /**
 115  
      * Get 
 116  
      *             Specifies how often to check for plugin updates.
 117  
      * Valid values are: never, always, interval:XXX.
 118  
      *             For the interval specification, XXX denotes a
 119  
      * terse interval specification, such as 4h.
 120  
      *             Where h=hours, m=minutes, d=days, w=weeks. The
 121  
      * interval period should be specified in descending
 122  
      *             order of granularity, like this: '[n]w [n]d [n]h
 123  
      * [n]m'. Any omitted level of granularity will be
 124  
      *             assumed to be a zero value.
 125  
      *           
 126  
      * 
 127  
      * @return String
 128  
      */
 129  
     public String getUpdateInterval()
 130  
     {
 131  0
         return this.updateInterval;
 132  
     } //-- String getUpdateInterval() 
 133  
 
 134  
     /**
 135  
      * Method removePlugin.
 136  
      * 
 137  
      * @param plugin
 138  
      */
 139  
     public void removePlugin( Plugin plugin )
 140  
     {
 141  0
         if ( !(plugin instanceof Plugin) )
 142  
         {
 143  0
             throw new ClassCastException( "PluginRegistry.removePlugins(plugin) parameter must be instanceof " + Plugin.class.getName() );
 144  
         }
 145  0
         getPlugins().remove( plugin );
 146  0
     } //-- void removePlugin( Plugin ) 
 147  
 
 148  
     /**
 149  
      * Set specifies whether the user should be prompted to update
 150  
      * plugins.
 151  
      * 
 152  
      * @param autoUpdate
 153  
      */
 154  
     public void setAutoUpdate( String autoUpdate )
 155  
     {
 156  0
         this.autoUpdate = autoUpdate;
 157  0
     } //-- void setAutoUpdate( String ) 
 158  
 
 159  
     /**
 160  
      * Set whether to resolve plugin versions using LATEST
 161  
      * metadata.
 162  
      * 
 163  
      * @param checkLatest
 164  
      */
 165  
     public void setCheckLatest( String checkLatest )
 166  
     {
 167  0
         this.checkLatest = checkLatest;
 168  0
     } //-- void setCheckLatest( String ) 
 169  
 
 170  
     /**
 171  
      * Set specified plugin update policy information.
 172  
      * 
 173  
      * @param plugins
 174  
      */
 175  
     public void setPlugins( java.util.List plugins )
 176  
     {
 177  0
         this.plugins = plugins;
 178  0
     } //-- void setPlugins( java.util.List ) 
 179  
 
 180  
     /**
 181  
      * Set 
 182  
      *             Specifies how often to check for plugin updates.
 183  
      * Valid values are: never, always, interval:XXX.
 184  
      *             For the interval specification, XXX denotes a
 185  
      * terse interval specification, such as 4h.
 186  
      *             Where h=hours, m=minutes, d=days, w=weeks. The
 187  
      * interval period should be specified in descending
 188  
      *             order of granularity, like this: '[n]w [n]d [n]h
 189  
      * [n]m'. Any omitted level of granularity will be
 190  
      *             assumed to be a zero value.
 191  
      *           
 192  
      * 
 193  
      * @param updateInterval
 194  
      */
 195  
     public void setUpdateInterval( String updateInterval )
 196  
     {
 197  0
         this.updateInterval = updateInterval;
 198  0
     } //-- void setUpdateInterval( String ) 
 199  
 
 200  
 
 201  
     private java.util.Map pluginsByKey;
 202  
     
 203  
     public java.util.Map getPluginsByKey()
 204  
     {
 205  0
         if ( pluginsByKey == null )
 206  
         {
 207  0
             pluginsByKey = new java.util.HashMap();
 208  
             
 209  0
             for ( java.util.Iterator it = getPlugins().iterator(); it.hasNext(); )
 210  
             {
 211  0
                 Plugin plugin = (Plugin) it.next();
 212  
             
 213  0
                 pluginsByKey.put( plugin.getKey(), plugin );
 214  0
             }
 215  
         }
 216  
         
 217  0
         return pluginsByKey;
 218  
     }
 219  
     
 220  
     public void flushPluginsByKey()
 221  
     {
 222  0
         this.pluginsByKey = null;
 223  0
     }
 224  
     
 225  
     private RuntimeInfo runtimeInfo;
 226  
     
 227  
     public void setRuntimeInfo( RuntimeInfo runtimeInfo )
 228  
     {
 229  0
         this.runtimeInfo = runtimeInfo;
 230  0
     }
 231  
     
 232  
     public RuntimeInfo getRuntimeInfo()
 233  
     {
 234  0
         return runtimeInfo;
 235  
     }
 236  
         
 237  0
     private String modelEncoding = "UTF-8";
 238  
 
 239  
     /**
 240  
      * Set an encoding used for reading/writing the model.
 241  
      *
 242  
      * @param modelEncoding the encoding used when reading/writing the model.
 243  
      */
 244  
     public void setModelEncoding( String modelEncoding )
 245  
     {
 246  0
         this.modelEncoding = modelEncoding;
 247  0
     }
 248  
 
 249  
     /**
 250  
      * @return the current encoding used when reading/writing this model.
 251  
      */
 252  
     public String getModelEncoding()
 253  
     {
 254  0
         return modelEncoding;
 255  
     }
 256  
 }