## org.apache.tools.ant.types
Class Resource

    java.lang.Object
      |
      +--org.apache.tools.ant.types.Resource

All Implemented Interfaces:
  java.lang.Cloneable, java.lang.Comparable

public class Resource
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable

describes a File or a ZipEntry this class is meant to be used by classes needing to record path and date/time information about a file, a zip entry or some similar resource (URL, archive in a version control repository, ...)

Since:
  Ant 1.5.2

Constructor Summary
`Resource()` default constructor
`Resource(java.lang.String name)` only sets the name.
`Resource(java.lang.String name, boolean exists, long lastmodified)` sets the name, lastmodified flag, and exists flag
`Resource(java.lang.String name, boolean exists, long lastmodified, boolean directory)`

Method Summary
`java.lang.Object` `clone()`
`int` `compareTo(java.lang.Object other)` delegates to a comparison of names.
`long` `getLastModified()` tells the modification time in milliseconds since 01.01.1970 of
`java.lang.String` `getName()` name attribute will contain the path of a file relative to the root directory of its fileset or the recorded path of a zip entry.
`boolean` `isDirectory()` tells if the resource is a directory
`boolean` `isExists()` the exists attribute tells whether a file exists
`void` `setDirectory(boolean directory)`
`void` `setExists(boolean exists)`
`void` `setLastModified(long lastmodified)`
`void` `setName(java.lang.String name)`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Resource

    public Resource()

  default constructor

### Resource

    public Resource(java.lang.String name)

  only sets the name.

  This is a dummy, used for not existing resources.

Parameters:
  `name` - relative path of the resource. Expects "/" to be used as the directory separator.

### Resource

    public Resource(java.lang.String name,
                    boolean exists,
                    long lastmodified)

  sets the name, lastmodified flag, and exists flag

Parameters:
  `name` - relative path of the resource. Expects "/" to be used as the directory separator.

### Resource

    public Resource(java.lang.String name,
                    boolean exists,
                    long lastmodified,
                    boolean directory)

Parameters:
  `name` - relative path of the resource. Expects "/" to be used as the directory separator.

Method Detail

### getName

    public java.lang.String getName()

  name attribute will contain the path of a file relative to the root directory of its fileset or the recorded path of a zip entry.

  example for a file with fullpath /var/opt/adm/resource.txt in a file set with root dir /var/opt it will be adm/resource.txt.

  "/" will be used as the directory separator.

### setName

    public void setName(java.lang.String name)

  Parameters:
    `name` - relative path of the resource. Expects "/" to be used as the directory separator.

### isExists

    public boolean isExists()

  the exists attribute tells whether a file exists

### setExists

    public void setExists(boolean exists)

### getLastModified

    public long getLastModified()

  tells the modification time in milliseconds since 01.01.1970 of

  Returns:
    0 if the resource does not exist to mirror the behavior of `File`.

### setLastModified

    public void setLastModified(long lastmodified)

### isDirectory

    public boolean isDirectory()

  tells if the resource is a directory

  Returns:
    boolean flag indicating if the resource is a directory

### setDirectory

    public void setDirectory(boolean directory)

### clone

    public java.lang.Object clone()

  Overrides:
    `clone` in class `java.lang.Object`
  Returns:
    copy of this

### compareTo

    public int compareTo(java.lang.Object other)

  delegates to a comparison of names.

  Specified by:
    `compareTo` in interface `java.lang.Comparable`
  Since:
    Ant 1.6

Copyright © 2000-2004 Apache Software Foundation. All Rights Reserved.