Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 183   Methods: 13
NCLOC: 54   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Resource.java - 58.8% 53.8% 56.7%
 1   
 /*
 2   
  * The Apache Software License, Version 1.1
 3   
  *
 4   
  * Copyright (c) 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.types;
 55   
 
 56   
 /**
 57   
  * describes a File or a ZipEntry
 58   
  *
 59   
  * this class is meant to be used by classes needing to record path
 60   
  * and date/time information about a file, a zip entry or some similar
 61   
  * resource (URL, archive in a version control repository, ...)
 62   
  *
 63   
  * @author <a href="mailto:levylambert@tiscali-dsl.de">Antoine Levy-Lambert</a>
 64   
  * @since Ant 1.5.2
 65   
  */
 66   
 public class Resource implements Cloneable {
 67   
     private String name = null;
 68   
     private boolean exists = true;
 69   
     private long lastmodified = 0;
 70   
     private boolean directory = false;
 71   
 
 72   
     /**
 73   
      * default constructor
 74   
      */
 75  0
     public Resource() {
 76   
     }
 77   
 
 78   
     /**
 79   
      * only sets the name.
 80   
      *
 81   
      * <p>This is a dummy, used for not existing resources.</p>
 82   
      *
 83   
      * @param name relative path of the resource.  Expects
 84   
      * &quot;/&quot; to be used as the directory separator.
 85   
      */
 86  104
     public Resource(String name) {
 87  104
         this(name, false, 0, false);
 88   
     }
 89   
 
 90   
     /**
 91   
      * sets the name, lastmodified flag, and exists flag
 92   
      *
 93   
      * @param name relative path of the resource.  Expects
 94   
      * &quot;/&quot; to be used as the directory separator.
 95   
      */
 96  458
     public Resource(String name, boolean exists, long lastmodified) {
 97  458
         this(name, exists, lastmodified, false);
 98   
     }
 99   
 
 100   
     /**
 101   
      * @param name relative path of the resource.  Expects
 102   
      * &quot;/&quot; to be used as the directory separator.
 103   
      */
 104  5051
     public Resource(String name, boolean exists, long lastmodified,
 105   
                     boolean directory) {
 106  5051
         this.name = name;
 107  5051
         this.exists = exists;
 108  5051
         this.lastmodified = lastmodified;
 109  5051
         this.directory = directory;
 110   
     }
 111   
 
 112   
     /**
 113   
      * name attribute will contain the path of a file relative to the
 114   
      * root directory of its fileset or the recorded path of a zip
 115   
      * entry.
 116   
      *
 117   
      * <p>example for a file with fullpath /var/opt/adm/resource.txt
 118   
      * in a file set with root dir /var/opt it will be
 119   
      * adm/resource.txt.</p>
 120   
      *
 121   
      * <p>&quot;/&quot; will be used as the directory separator.</p>
 122   
      */
 123  9200
     public String getName() {
 124  9200
         return name;
 125   
     }
 126   
 
 127   
     /**
 128   
      * @param name relative path of the resource.  Expects
 129   
      * &quot;/&quot; to be used as the directory separator.
 130   
      */
 131  0
     public void setName(String name) {
 132  0
         this.name = name;
 133   
     }
 134   
     /**
 135   
      * the exists attribute tells whether a file exists
 136   
      */
 137  1465
     public boolean isExists() {
 138  1465
         return exists;
 139   
     }
 140   
 
 141  0
     public void setExists(boolean exists) {
 142  0
         this.exists = exists;
 143   
     }
 144   
 
 145   
     /**
 146   
      * tells the modification time in milliseconds since 01.01.1970 of
 147   
      *
 148   
      * @return 0 if the resource does not exist to mirror the behavior
 149   
      * of {@link java.io.File File}.
 150   
      */
 151  4468
     public long getLastModified() {
 152  4468
         return !exists || lastmodified < 0 ? 0 : lastmodified;
 153   
     }
 154   
 
 155  0
     public void setLastModified(long lastmodified) {
 156  0
         this.lastmodified = lastmodified;
 157   
     }
 158   
     /**
 159   
      * tells if the resource is a directory
 160   
      * @return boolean flag indicating if the resource is a directory
 161   
      */
 162  3950
     public boolean isDirectory() {
 163  3950
         return directory;
 164   
     }
 165   
 
 166  0
     public void setDirectory(boolean directory) {
 167  0
         this.directory = directory;
 168   
     }
 169   
 
 170   
     /**
 171   
      * @return copy of this
 172   
      */
 173  0
     public Object clone() {
 174  0
         try {
 175  0
             return super.clone();
 176   
         } catch (CloneNotSupportedException e) {
 177  0
             throw new Error("CloneNotSupportedException for a "
 178   
                             + "Clonable Resource caught?");
 179   
         }
 180   
     }
 181   
 
 182   
 }
 183