Coverage Report - org.apache.maven.plugin.doap.options.ASFExtOptions
 
Classes in this File Line Coverage Branch Coverage Complexity
ASFExtOptions
18 %
20/109
8 %
7/88
2,13
 
 1  
 /*
 2  
  * $Id$
 3  
  */
 4  
 
 5  
 package org.apache.maven.plugin.doap.options;
 6  
 
 7  
   //---------------------------------/
 8  
  //- Imported classes and packages -/
 9  
 //---------------------------------/
 10  
 
 11  
 import java.util.Date;
 12  
 
 13  
 /**
 14  
  * Specific ASF DOAP parameters, i.e. ASF options which make DOAP
 15  
  * file ASF compliant.
 16  
  * @see <a
 17  
  * href="http://svn.apache.org/repos/asf/infrastructure/site-tools/trunk/projects/asfext">
 18  
  * http://svn.apache.org/repos/asf/infrastructure/site-tools/trunk/projects/asfext</a>
 19  
  * @see <a
 20  
  * href="http://projects.apache.org/docs/pmc.html">http://projects.apache.org/docs/pmc.html</a>
 21  
  * @see <a
 22  
  * href="http://projects.apache.org/docs/standards.html">http://projects.apache.org/docs/standards.html</a>
 23  
  * 
 24  
  * @version $Revision$ $Date$
 25  
  */
 26  2
 public class ASFExtOptions implements java.io.Serializable {
 27  
 
 28  
 
 29  
       //--------------------------/
 30  
      //- Class/Member Variables -/
 31  
     //--------------------------/
 32  
 
 33  
     /**
 34  
      * Flag to use or not the ASF extension in the generated DOAP.
 35  
      * Required.
 36  
      */
 37  2
     private boolean included = true;
 38  
 
 39  
     /**
 40  
      * The top level element within a file. Optional will be
 41  
      * discovered from POM.
 42  
      * @see <a
 43  
      * href="http://projects.apache.org/docs/pmc.html">http://projects.apache.org/docs/pmc.html</a>
 44  
      */
 45  
     private String pmc;
 46  
 
 47  
     /**
 48  
      * The name of the PMC, including the 'Apache ', e.g. 'Apache
 49  
      * Forrest'. Optional will be discovered from POM.
 50  
      * @see <a
 51  
      * href="http://projects.apache.org/docs/pmc.html">http://projects.apache.org/docs/pmc.html</a>
 52  
      */
 53  
     private String name;
 54  
 
 55  
     /**
 56  
      * Every PMC is created by a board resolution with a specific
 57  
      * charter. That charter should be
 58  
      *             listed here as it gives the focus and scope of
 59  
      * the PMC. Optional.
 60  
      * @see <a
 61  
      * href="http://projects.apache.org/docs/pmc.html">http://projects.apache.org/docs/pmc.html</a>
 62  
      */
 63  
     private String charter;
 64  
 
 65  
     /**
 66  
      * This should contain the name of the current PMC chairperson.
 67  
      * Optional.
 68  
      * @see <a
 69  
      * href="http://projects.apache.org/docs/pmc.html">http://projects.apache.org/docs/pmc.html</a>
 70  
      */
 71  
     private String chair;
 72  
 
 73  
     /**
 74  
      * Field standards.
 75  
      */
 76  
     private java.util.List standards;
 77  
 
 78  
 
 79  
       //-----------/
 80  
      //- Methods -/
 81  
     //-----------/
 82  
 
 83  
     /**
 84  
      * Method addStandard.
 85  
      * 
 86  
      * @param standard
 87  
      */
 88  
     public void addStandard(Standard standard)
 89  
     {
 90  0
         if ( !(standard instanceof Standard) )
 91  
         {
 92  0
             throw new ClassCastException( "ASFExtOptions.addStandards(standard) parameter must be instanceof " + Standard.class.getName() );
 93  
         }
 94  0
         getStandards().add( standard );
 95  0
     } //-- void addStandard(Standard) 
 96  
 
 97  
     /**
 98  
      * Method equals.
 99  
      * 
 100  
      * @param other
 101  
      * @return boolean
 102  
      */
 103  
     public boolean equals(Object other)
 104  
     {
 105  0
         if ( this == other)
 106  
         {
 107  0
             return true;
 108  
         }
 109  
         
 110  0
         if ( !(other instanceof ASFExtOptions) )
 111  
         {
 112  0
             return false;
 113  
         }
 114  
         
 115  0
         ASFExtOptions that = (ASFExtOptions) other;
 116  0
         boolean result = true;
 117  
         
 118  0
         result = result && included == that.included;
 119  0
         result = result && ( getPmc() == null ? that.getPmc() == null : getPmc().equals( that.getPmc() ) );
 120  0
         result = result && ( getName() == null ? that.getName() == null : getName().equals( that.getName() ) );
 121  0
         result = result && ( getCharter() == null ? that.getCharter() == null : getCharter().equals( that.getCharter() ) );
 122  0
         result = result && ( getChair() == null ? that.getChair() == null : getChair().equals( that.getChair() ) );
 123  
         
 124  0
         return result;
 125  
     } //-- boolean equals(Object) 
 126  
 
 127  
     /**
 128  
      * Get this should contain the name of the current PMC
 129  
      * chairperson. Optional.
 130  
      * @see <a
 131  
      * href="http://projects.apache.org/docs/pmc.html">http://projects.apache.org/docs/pmc.html</a>
 132  
      * 
 133  
      * @return String
 134  
      */
 135  
     public String getChair()
 136  
     {
 137  1
         return this.chair;
 138  
     } //-- String getChair() 
 139  
 
 140  
     /**
 141  
      * Get every PMC is created by a board resolution with a
 142  
      * specific charter. That charter should be
 143  
      *             listed here as it gives the focus and scope of
 144  
      * the PMC. Optional.
 145  
      * @see <a
 146  
      * href="http://projects.apache.org/docs/pmc.html">http://projects.apache.org/docs/pmc.html</a>
 147  
      * 
 148  
      * @return String
 149  
      */
 150  
     public String getCharter()
 151  
     {
 152  1
         return this.charter;
 153  
     } //-- String getCharter() 
 154  
 
 155  
     /**
 156  
      * Get the name of the PMC, including the 'Apache ', e.g.
 157  
      * 'Apache Forrest'. Optional will be discovered from POM.
 158  
      * @see <a
 159  
      * href="http://projects.apache.org/docs/pmc.html">http://projects.apache.org/docs/pmc.html</a>
 160  
      * 
 161  
      * @return String
 162  
      */
 163  
     public String getName()
 164  
     {
 165  1
         return this.name;
 166  
     } //-- String getName() 
 167  
 
 168  
     /**
 169  
      * Get the top level element within a file. Optional will be
 170  
      * discovered from POM.
 171  
      * @see <a
 172  
      * href="http://projects.apache.org/docs/pmc.html">http://projects.apache.org/docs/pmc.html</a>
 173  
      * 
 174  
      * @return String
 175  
      */
 176  
     public String getPmc()
 177  
     {
 178  1
         return this.pmc;
 179  
     } //-- String getPmc() 
 180  
 
 181  
     /**
 182  
      * Method getStandards.
 183  
      * 
 184  
      * @return java.util.List
 185  
      */
 186  
     public java.util.List getStandards()
 187  
     {
 188  2
         if ( this.standards == null )
 189  
         {
 190  1
             this.standards = new java.util.ArrayList();
 191  
         }
 192  
         
 193  2
         return this.standards;
 194  
     } //-- java.util.List getStandards() 
 195  
 
 196  
     /**
 197  
      * Method hashCode.
 198  
      * 
 199  
      * @return int
 200  
      */
 201  
     public int hashCode()
 202  
     {
 203  0
         int result = 17;
 204  
         
 205  0
         result = 37 * result + ( included ? 0 : 1 );
 206  0
         result = 37 * result + ( pmc != null ? pmc.hashCode() : 0 );
 207  0
         result = 37 * result + ( name != null ? name.hashCode() : 0 );
 208  0
         result = 37 * result + ( charter != null ? charter.hashCode() : 0 );
 209  0
         result = 37 * result + ( chair != null ? chair.hashCode() : 0 );
 210  
         
 211  0
         return result;
 212  
     } //-- int hashCode() 
 213  
 
 214  
     /**
 215  
      * Get flag to use or not the ASF extension in the generated
 216  
      * DOAP. Required.
 217  
      * 
 218  
      * @return boolean
 219  
      */
 220  
     public boolean isIncluded()
 221  
     {
 222  10
         return this.included;
 223  
     } //-- boolean isIncluded() 
 224  
 
 225  
     /**
 226  
      * Method removeStandard.
 227  
      * 
 228  
      * @param standard
 229  
      */
 230  
     public void removeStandard(Standard standard)
 231  
     {
 232  0
         if ( !(standard instanceof Standard) )
 233  
         {
 234  0
             throw new ClassCastException( "ASFExtOptions.removeStandards(standard) parameter must be instanceof " + Standard.class.getName() );
 235  
         }
 236  0
         getStandards().remove( standard );
 237  0
     } //-- void removeStandard(Standard) 
 238  
 
 239  
     /**
 240  
      * Set this should contain the name of the current PMC
 241  
      * chairperson. Optional.
 242  
      * @see <a
 243  
      * href="http://projects.apache.org/docs/pmc.html">http://projects.apache.org/docs/pmc.html</a>
 244  
      * 
 245  
      * @param chair
 246  
      */
 247  
     public void setChair(String chair)
 248  
     {
 249  0
         this.chair = chair;
 250  0
     } //-- void setChair(String) 
 251  
 
 252  
     /**
 253  
      * Set every PMC is created by a board resolution with a
 254  
      * specific charter. That charter should be
 255  
      *             listed here as it gives the focus and scope of
 256  
      * the PMC. Optional.
 257  
      * @see <a
 258  
      * href="http://projects.apache.org/docs/pmc.html">http://projects.apache.org/docs/pmc.html</a>
 259  
      * 
 260  
      * @param charter
 261  
      */
 262  
     public void setCharter(String charter)
 263  
     {
 264  0
         this.charter = charter;
 265  0
     } //-- void setCharter(String) 
 266  
 
 267  
     /**
 268  
      * Set flag to use or not the ASF extension in the generated
 269  
      * DOAP. Required.
 270  
      * 
 271  
      * @param included
 272  
      */
 273  
     public void setIncluded(boolean included)
 274  
     {
 275  2
         this.included = included;
 276  2
     } //-- void setIncluded(boolean) 
 277  
 
 278  
     /**
 279  
      * Set the name of the PMC, including the 'Apache ', e.g.
 280  
      * 'Apache Forrest'. Optional will be discovered from POM.
 281  
      * @see <a
 282  
      * href="http://projects.apache.org/docs/pmc.html">http://projects.apache.org/docs/pmc.html</a>
 283  
      * 
 284  
      * @param name
 285  
      */
 286  
     public void setName(String name)
 287  
     {
 288  0
         this.name = name;
 289  0
     } //-- void setName(String) 
 290  
 
 291  
     /**
 292  
      * Set the top level element within a file. Optional will be
 293  
      * discovered from POM.
 294  
      * @see <a
 295  
      * href="http://projects.apache.org/docs/pmc.html">http://projects.apache.org/docs/pmc.html</a>
 296  
      * 
 297  
      * @param pmc
 298  
      */
 299  
     public void setPmc(String pmc)
 300  
     {
 301  0
         this.pmc = pmc;
 302  0
     } //-- void setPmc(String) 
 303  
 
 304  
     /**
 305  
      * Set list of Standard object. Optional.
 306  
      * @see <a
 307  
      * href="http://projects.apache.org/docs/standards.html">http://projects.apache.org/docs/standards.html</a>
 308  
      * 
 309  
      * @param standards
 310  
      */
 311  
     public void setStandards(java.util.List standards)
 312  
     {
 313  0
         this.standards = standards;
 314  0
     } //-- void setStandards(java.util.List) 
 315  
 
 316  
     /**
 317  
      * Method toString.
 318  
      * 
 319  
      * @return java.lang.String
 320  
      */
 321  
     public java.lang.String toString()
 322  
     {
 323  0
         StringBuffer buf = new StringBuffer();
 324  
         
 325  0
         buf.append( "included = '" );
 326  0
         buf.append( isIncluded() );
 327  0
         buf.append( "'" );
 328  0
         buf.append( "\n" ); 
 329  0
         buf.append( "pmc = '" );
 330  0
         buf.append( getPmc() );
 331  0
         buf.append( "'" );
 332  0
         buf.append( "\n" ); 
 333  0
         buf.append( "name = '" );
 334  0
         buf.append( getName() );
 335  0
         buf.append( "'" );
 336  0
         buf.append( "\n" ); 
 337  0
         buf.append( "charter = '" );
 338  0
         buf.append( getCharter() );
 339  0
         buf.append( "'" );
 340  0
         buf.append( "\n" ); 
 341  0
         buf.append( "chair = '" );
 342  0
         buf.append( getChair() );
 343  0
         buf.append( "'" );
 344  
         
 345  0
         return buf.toString();
 346  
     } //-- java.lang.String toString() 
 347  
 
 348  
 
 349  
             
 350  
     /** The ASF ext namespace. */
 351  
     public static final String ASFEXT_NAMESPACE = "http://projects.apache.org/ns/asfext#";
 352  
 
 353  
     /**
 354  
      * The ASF category resource.
 355  
      *
 356  
      * @see <a href="http://projects.apache.org/guidelines.html">http://projects.apache.org/guidelines.html</a>
 357  
      */
 358  
     public static final String CATEGORY_RESOURCE = "http://projects.apache.org/category/";
 359  
 
 360  
     /** Projects related to building/maintaining source code/websites. */
 361  
     public static final String BUILD_MANAGEMENT_CATEGORY = "build-management";
 362  
 
 363  
     /** Projects related to databases. */
 364  
     public static final String DATABASE_CATEGORY = "database";
 365  
 
 366  
     /** Related to the HyperText Transfer Protocol. */
 367  
     public static final String HTTP_CATEGORY = "http";
 368  
 
 369  
     /** Modules designed for use by the Apache HTTP Server. */
 370  
     public static final String HTTP_MODULES_CATEGORY = "httpd-modules";
 371  
 
 372  
     /** A library meant to be used by other applications. */
 373  
     public static final String LIBRARY_CATEGORY = "library";
 374  
 
 375  
     /** Servers or applications related to internet mail protocols. */
 376  
     public static final String MAIL_CATEGORY = "mail";
 377  
 
 378  
     /** Anything that acts as a client across a network. */
 379  
     public static final String NETWORK_CLIENT_CATEGORY = "network-client";
 380  
 
 381  
     /** Anything that acts as a server across a network. */
 382  
     public static final String NETWORK_SERVER_CATEGORY = "network-server";
 383  
 
 384  
     /** Software designed to test or verify other software. */
 385  
     public static final String TESTING_CATEGORY = "testing";
 386  
 
 387  
     /** Unifying frameworks for website development. */
 388  
     public static final String WEB_FRAMEWORK_CATEGORY = "web-framework";
 389  
 
 390  
     /** Software based on XML technologies. */
 391  
     public static final String XML_CATEGORY = "xml";
 392  
 
 393  
     /** All categories supported by ASF */
 394  1
     public static final String[] CATEGORIES = {
 395  
         BUILD_MANAGEMENT_CATEGORY,
 396  
         DATABASE_CATEGORY,
 397  
         HTTP_CATEGORY,
 398  
         HTTP_MODULES_CATEGORY,
 399  
         LIBRARY_CATEGORY,
 400  
         MAIL_CATEGORY,
 401  
         NETWORK_CLIENT_CATEGORY,
 402  
         NETWORK_SERVER_CATEGORY,
 403  
         TESTING_CATEGORY,
 404  
         WEB_FRAMEWORK_CATEGORY,
 405  
         XML_CATEGORY };
 406  
 
 407  
     /** C or C++ Programming Language. */
 408  
     public static final String C_PROGRAMMING_LANGUAGE = "C";
 409  
 
 410  
     /** Java Programming Language and all its components.*/
 411  
     public static final String JAVA_PROGRAMMING_LANGUAGE = "Java";
 412  
 
 413  
     /** Perl Programming Language.*/
 414  
     public static final String PERL_PROGRAMMING_LANGUAGE = "Perl";
 415  
 
 416  
     /** Python Programming Language.*/
 417  
     public static final String PYTHON_PROGRAMMING_LANGUAGE = "Python";
 418  
 
 419  
     /** Scalable Vector Graphic Programming Language.*/
 420  
     public static final String SVG_PROGRAMMING_LANGUAGE = "SVG";
 421  
 
 422  
     /** Tcl Programming Language.*/
 423  
     public static final String TCL_PROGRAMMING_LANGUAGE = "Tcl";
 424  
 
 425  
     /** All Programming Languages supported by ASF */
 426  1
     public static final String[] PROGRAMMING_LANGUAGES = {
 427  
         C_PROGRAMMING_LANGUAGE,
 428  
         JAVA_PROGRAMMING_LANGUAGE,
 429  
         PERL_PROGRAMMING_LANGUAGE,
 430  
         PYTHON_PROGRAMMING_LANGUAGE,
 431  
         SVG_PROGRAMMING_LANGUAGE,
 432  
         TCL_PROGRAMMING_LANGUAGE};
 433  
 
 434  
     /**
 435  
      * @param category not null
 436  
      * @return <code>true</code> if the given category is supported by ASF.
 437  
      * @see <a href="http://projects.apache.org/categories.html">http://projects.apache.org/categories.html</a>
 438  
      * @see #CATEGORIES
 439  
      */
 440  
     public static boolean isCategorySupportedByASF( String category )
 441  
     {
 442  0
         for ( int i = 0; i < CATEGORIES.length; i++ )
 443  
         {
 444  0
             if ( CATEGORIES[i].equalsIgnoreCase( category ) )
 445  
             {
 446  0
                 return true;
 447  
             }
 448  
         }
 449  
 
 450  0
         return false;
 451  
     }
 452  
 
 453  
     /**
 454  
      * @param programmingLanguage not null
 455  
      * @return <code>true</code> if the given programming language is supported by ASF.
 456  
      * @see <a href="http://projects.apache.org/languages.html">http://projects.apache.org/languages.html</a>
 457  
      * @see #PROGRAMMING_LANGUAGES
 458  
      */
 459  
     public static boolean isProgrammingLanguageSupportedByASF( String programmingLanguage )
 460  
     {
 461  2
         for ( int i = 0; i < PROGRAMMING_LANGUAGES.length; i++ )
 462  
         {
 463  2
             if ( PROGRAMMING_LANGUAGES[i].equalsIgnoreCase( programmingLanguage ) )
 464  
             {
 465  1
                 return true;
 466  
             }
 467  
         }
 468  
 
 469  0
         return false;
 470  
     }
 471  
 
 472  
     /**
 473  
      * Find the chair man of the project. The role of the developer should contain <code>chair</code>.
 474  
      *
 475  
      * @param developers list of <code>{@link org.apache.maven.model.Developer}</code>
 476  
      * @return a Developer or null if not found.
 477  
      */
 478  
     public static org.apache.maven.model.Developer findChair( java.util.List developers )
 479  
     {
 480  1
         if ( developers == null || developers.isEmpty() )
 481  
         {
 482  1
             return null;
 483  
         }
 484  
 
 485  0
         for ( java.util.Iterator it = developers.iterator(); it.hasNext(); )
 486  
         {
 487  0
             org.apache.maven.model.Developer developer = (org.apache.maven.model.Developer) it.next();
 488  0
             java.util.List roles = developer.getRoles();
 489  
 
 490  0
             for ( java.util.Iterator it2 = roles.iterator(); it2.hasNext(); )
 491  
             {
 492  0
                 String role = (String) it2.next();
 493  
 
 494  0
                 if ( role.toLowerCase().indexOf( "chair" ) != -1 )
 495  
                 {
 496  0
                     return developer;
 497  
                 }
 498  0
             }
 499  0
         }
 500  
 
 501  0
         return null;
 502  
     }
 503  
 
 504  
     /**
 505  
      * Find the list of PMC members of the project. The role of each developer should contain <code>pmc</code>.
 506  
      *
 507  
      * @param developers list of <code>{@link org.apache.maven.model.Developer}</code>
 508  
      * @return a not null list of Developer.
 509  
      */
 510  
     public static java.util.List findPMCMembers( java.util.List developers )
 511  
     {
 512  0
         if ( developers == null || developers.isEmpty() )
 513  
         {
 514  0
             return null;
 515  
         }
 516  
 
 517  0
         java.util.List pmc = new java.util.ArrayList();
 518  0
         for ( java.util.Iterator it = developers.iterator(); it.hasNext(); )
 519  
         {
 520  0
             org.apache.maven.model.Developer developer = (org.apache.maven.model.Developer) it.next();
 521  0
             java.util.List roles = developer.getRoles();
 522  
 
 523  0
             for ( java.util.Iterator it2 = roles.iterator(); it2.hasNext(); )
 524  
             {
 525  0
                 String role = (String) it2.next();
 526  
 
 527  0
                 if ( role.toLowerCase().indexOf( "pmc" ) != -1 )
 528  
                 {
 529  0
                     pmc.add( developer );
 530  
                 }
 531  0
             }
 532  0
         }
 533  
 
 534  0
         return pmc;
 535  
     }
 536  
             
 537  
           
 538  2
     private String modelEncoding = "UTF-8";
 539  
 
 540  
     /**
 541  
      * Set an encoding used for reading/writing the model.
 542  
      *
 543  
      * @param modelEncoding the encoding used when reading/writing the model.
 544  
      */
 545  
     public void setModelEncoding( String modelEncoding )
 546  
     {
 547  0
         this.modelEncoding = modelEncoding;
 548  0
     }
 549  
 
 550  
     /**
 551  
      * @return the current encoding used when reading/writing this model.
 552  
      */
 553  
     public String getModelEncoding()
 554  
     {
 555  0
         return modelEncoding;
 556  
     }
 557  
 }