Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 282   Methods: 11
NCLOC: 121   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ExtensionAdapter.java 0% 0% 0% 0%
 1   
 /*
 2   
  * The Apache Software License, Version 1.1
 3   
  *
 4   
  * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
 5   
  * reserved.
 6   
  *
 7   
  * Redistribution and use in source and binary forms, with or without
 8   
  * modification, are permitted provided that the following conditions
 9   
  * are met:
 10   
  *
 11   
  * 1. Redistributions of source code must retain the above copyright
 12   
  *    notice, this list of conditions and the following disclaimer.
 13   
  *
 14   
  * 2. Redistributions in binary form must reproduce the above copyright
 15   
  *    notice, this list of conditions and the following disclaimer in
 16   
  *    the documentation and/or other materials provided with the
 17   
  *    distribution.
 18   
  *
 19   
  * 3. The end-user documentation included with the redistribution, if
 20   
  *    any, must include the following acknowlegement:
 21   
  *       "This product includes software developed by the
 22   
  *        Apache Software Foundation (http://www.apache.org/)."
 23   
  *    Alternately, this acknowlegement may appear in the software itself,
 24   
  *    if and wherever such third-party acknowlegements normally appear.
 25   
  *
 26   
  * 4. The names "Ant" and "Apache Software
 27   
  *    Foundation" must not be used to endorse or promote products derived
 28   
  *    from this software without prior written permission. For written
 29   
  *    permission, please contact apache@apache.org.
 30   
  *
 31   
  * 5. Products derived from this software may not be called "Apache"
 32   
  *    nor may "Apache" appear in their names without prior written
 33   
  *    permission of the Apache Group.
 34   
  *
 35   
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 36   
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 37   
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 38   
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 39   
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 40   
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 41   
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 42   
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 43   
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 44   
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 45   
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 46   
  * SUCH DAMAGE.
 47   
  * ====================================================================
 48   
  *
 49   
  * This software consists of voluntary contributions made by many
 50   
  * individuals on behalf of the Apache Software Foundation.  For more
 51   
  * information on the Apache Software Foundation, please see
 52   
  * <http://www.apache.org/>.
 53   
  */
 54   
 package org.apache.tools.ant.taskdefs.optional.extension;
 55   
 
 56   
 import org.apache.tools.ant.BuildException;
 57   
 import org.apache.tools.ant.types.DataType;
 58   
 import org.apache.tools.ant.types.Reference;
 59   
 
 60   
 /**
 61   
  * Simple class that represents an Extension and conforms to Ants
 62   
  * patterns.
 63   
  *
 64   
  * @author <a href="mailto:peter@apache.org">Peter Donald</a>
 65   
  * @version $Revision: 1.5 $ $Date: 2003/02/26 14:22:45 $
 66   
  * @ant.data-type name="extension"
 67   
  */
 68   
 public class ExtensionAdapter
 69   
     extends DataType
 70   
 {
 71   
     /**
 72   
      * The name of the optional package being made available, or required.
 73   
      */
 74   
     private String m_extensionName;
 75   
 
 76   
     /**
 77   
      * The version number (dotted decimal notation) of the specification
 78   
      * to which this optional package conforms.
 79   
      */
 80   
     private DeweyDecimal m_specificationVersion;
 81   
 
 82   
     /**
 83   
      * The name of the company or organization that originated the
 84   
      * specification to which this optional package conforms.
 85   
      */
 86   
     private String m_specificationVendor;
 87   
 
 88   
     /**
 89   
      * The unique identifier of the company that produced the optional
 90   
      * package contained in this JAR file.
 91   
      */
 92   
     private String m_implementationVendorID;
 93   
 
 94   
     /**
 95   
      * The name of the company or organization that produced this
 96   
      * implementation of this optional package.
 97   
      */
 98   
     private String m_implementationVendor;
 99   
 
 100   
     /**
 101   
      * The version number (dotted decimal notation) for this implementation
 102   
      * of the optional package.
 103   
      */
 104   
     private DeweyDecimal m_implementationVersion;
 105   
 
 106   
     /**
 107   
      * The URL from which the most recent version of this optional package
 108   
      * can be obtained if it is not already installed.
 109   
      */
 110   
     private String m_implementationURL;
 111   
 
 112   
     /**
 113   
      * Set the name of extension.
 114   
      *
 115   
      * @param extensionName the name of extension
 116   
      */
 117  0
     public void setExtensionName( final String extensionName )
 118   
     {
 119  0
         verifyNotAReference();
 120  0
         m_extensionName = extensionName;
 121   
     }
 122   
 
 123   
     /**
 124   
      * Set the specificationVersion of extension.
 125   
      *
 126   
      * @param specificationVersion the specificationVersion of extension
 127   
      */
 128  0
     public void setSpecificationVersion( final String specificationVersion )
 129   
     {
 130  0
         verifyNotAReference();
 131  0
         m_specificationVersion = new DeweyDecimal( specificationVersion );
 132   
     }
 133   
 
 134   
     /**
 135   
      * Set the specificationVendor of extension.
 136   
      *
 137   
      * @param specificationVendor the specificationVendor of extension
 138   
      */
 139  0
     public void setSpecificationVendor( final String specificationVendor )
 140   
     {
 141  0
         verifyNotAReference();
 142  0
         m_specificationVendor = specificationVendor;
 143   
     }
 144   
 
 145   
     /**
 146   
      * Set the implementationVendorID of extension.
 147   
      *
 148   
      * @param implementationVendorID the implementationVendorID of extension
 149   
      */
 150  0
     public void setImplementationVendorId( final String implementationVendorID )
 151   
     {
 152  0
         verifyNotAReference();
 153  0
         m_implementationVendorID = implementationVendorID;
 154   
     }
 155   
 
 156   
     /**
 157   
      * Set the implementationVendor of extension.
 158   
      *
 159   
      * @param implementationVendor the implementationVendor of extension
 160   
      */
 161  0
     public void setImplementationVendor( final String implementationVendor )
 162   
     {
 163  0
         verifyNotAReference();
 164  0
         m_implementationVendor = implementationVendor;
 165   
     }
 166   
 
 167   
     /**
 168   
      * Set the implementationVersion of extension.
 169   
      *
 170   
      * @param implementationVersion the implementationVersion of extension
 171   
      */
 172  0
     public void setImplementationVersion( final String implementationVersion )
 173   
     {
 174  0
         verifyNotAReference();
 175  0
         m_implementationVersion = new DeweyDecimal( implementationVersion );
 176   
     }
 177   
 
 178   
     /**
 179   
      * Set the implementationURL of extension.
 180   
      *
 181   
      * @param implementationURL the implementationURL of extension
 182   
      */
 183  0
     public void setImplementationUrl( final String implementationURL )
 184   
     {
 185  0
         verifyNotAReference();
 186  0
         m_implementationURL = implementationURL;
 187   
     }
 188   
 
 189   
     /**
 190   
      * Makes this instance in effect a reference to another ExtensionAdapter
 191   
      * instance.
 192   
      *
 193   
      * <p>You must not set another attribute or nest elements inside
 194   
      * this element if you make it a reference.</p>
 195   
      *
 196   
      * @param reference the reference to which this instance is associated
 197   
      * @exception BuildException if this instance already has been configured.
 198   
      */
 199  0
     public void setRefid( final Reference reference )
 200   
         throws BuildException
 201   
     {
 202  0
         if( null != m_extensionName ||
 203   
             null != m_specificationVersion ||
 204   
             null != m_specificationVendor ||
 205   
             null != m_implementationVersion ||
 206   
             null != m_implementationVendorID ||
 207   
             null != m_implementationVendor ||
 208   
             null != m_implementationURL )
 209   
         {
 210  0
             throw tooManyAttributes();
 211   
         }
 212   
         // change this to get the objects from the other reference
 213  0
         Object o = reference.getReferencedObject( getProject() );
 214  0
         if( o instanceof ExtensionAdapter )
 215   
         {
 216  0
             final ExtensionAdapter other = (ExtensionAdapter)o;
 217  0
             m_extensionName = other.m_extensionName;
 218  0
             m_specificationVersion = other.m_specificationVersion;
 219  0
             m_specificationVendor = other.m_specificationVendor;
 220  0
             m_implementationVersion = other.m_implementationVersion;
 221  0
             m_implementationVendorID = other.m_implementationVendorID;
 222  0
             m_implementationVendor = other.m_implementationVendor;
 223  0
             m_implementationURL = other.m_implementationURL;
 224   
         }
 225   
         else
 226   
         {
 227  0
             final String message =
 228   
                 reference.getRefId() + " doesn\'t refer to a Extension";
 229  0
             throw new BuildException( message );
 230   
         }
 231   
 
 232  0
         super.setRefid( reference );
 233   
     }
 234   
 
 235  0
     private void verifyNotAReference()
 236   
         throws BuildException
 237   
     {
 238  0
         if( isReference() )
 239   
         {
 240  0
             throw tooManyAttributes();
 241   
         }
 242   
     }
 243   
 
 244   
     /**
 245   
      * Convert this adpater object into an extension object.
 246   
      *
 247   
      * @return the extension object
 248   
      */
 249  0
     Extension toExtension()
 250   
         throws BuildException
 251   
     {
 252  0
         if( null == m_extensionName )
 253   
         {
 254  0
             final String message = "Extension is missing name.";
 255  0
             throw new BuildException( message );
 256   
         }
 257   
 
 258  0
         String specificationVersion = null;
 259  0
         if( null != m_specificationVersion )
 260   
         {
 261  0
             specificationVersion = m_specificationVersion.toString();
 262   
         }
 263  0
         String implementationVersion = null;
 264  0
         if( null != m_implementationVersion )
 265   
         {
 266  0
             implementationVersion = m_implementationVersion.toString();
 267   
         }
 268  0
         return new Extension( m_extensionName,
 269   
                               specificationVersion,
 270   
                               m_specificationVendor,
 271   
                               implementationVersion,
 272   
                               m_implementationVendor,
 273   
                               m_implementationVendorID,
 274   
                               m_implementationURL );
 275   
     }
 276   
 
 277  0
     public String toString()
 278   
     {
 279  0
         return "{" + toExtension().toString() + "}";
 280   
     }
 281   
 }
 282