Class PropertyResource

  • All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Comparable<Resource>, java.lang.Iterable<Resource>, ResourceCollection

    public class PropertyResource
    extends Resource
    Exposes an Ant property as a Resource.
    Since:
    Ant 1.7
    • Constructor Detail

      • PropertyResource

        public PropertyResource()
        Default constructor.
      • PropertyResource

        public PropertyResource​(Project p,
                                java.lang.String n)
        Construct a new PropertyResource with the specified name.
        Parameters:
        p - the project to use.
        n - the String name of this PropertyResource (Ant property name/key).
    • Method Detail

      • getValue

        public java.lang.String getValue()
        Get the value of this PropertyResource.
        Returns:
        the value of the specified Property.
      • getObjectValue

        public java.lang.Object getObjectValue()
        Get the Object value of this PropertyResource.
        Returns:
        the Object value of the specified Property.
        Since:
        Ant 1.8.1
      • isExists

        public boolean isExists()
        Find out whether this Resource exists.
        Overrides:
        isExists in class Resource
        Returns:
        true if the Property is set, false otherwise.
      • getSize

        public long getSize()
        Get the size of this Resource.
        Overrides:
        getSize in class Resource
        Returns:
        the size, as a long, 0 if the Resource does not exist (for compatibility with java.io.File), or UNKNOWN_SIZE if not known.
      • equals

        public boolean equals​(java.lang.Object o)
        Override to implement equality with equivalent Resources, since we are capable of proxying them.
        Overrides:
        equals in class Resource
        Parameters:
        o - object to compare
        Returns:
        true if equal to o
      • hashCode

        public int hashCode()
        Get the hash code for this Resource.
        Overrides:
        hashCode in class Resource
        Returns:
        hash code as int.
      • toString

        public java.lang.String toString()
        Get the string representation of this Resource.
        Overrides:
        toString in class Resource
        Returns:
        this Resource formatted as a String.
      • getInputStream

        public java.io.InputStream getInputStream()
                                           throws java.io.IOException
        Get an InputStream for the Resource.
        Overrides:
        getInputStream in class Resource
        Returns:
        an InputStream containing this Resource's content.
        Throws:
        java.io.IOException - if unable to provide the content of this Resource as a stream.
        java.lang.UnsupportedOperationException - if InputStreams are not supported for this Resource type.
      • getOutputStream

        public java.io.OutputStream getOutputStream()
                                             throws java.io.IOException
        Get an OutputStream for the Resource.
        Overrides:
        getOutputStream in class Resource
        Returns:
        an OutputStream to which content can be written.
        Throws:
        java.io.IOException - if unable to provide the content of this Resource as a stream.
        java.lang.UnsupportedOperationException - if OutputStreams are not supported for this Resource type.
      • isReferenceOrProxy

        protected boolean isReferenceOrProxy()
        Learn whether this PropertyResource either refers to another Resource or proxies another Resource due to its object property value being said Resource.
        Returns:
        boolean
      • getReferencedOrProxied

        protected Resource getReferencedOrProxied()
        Get the referenced or proxied Resource, if applicable.
        Returns:
        Resource
        Throws:
        java.lang.IllegalStateException - if this PropertyResource neither proxies nor references another Resource.
      • getRef

        protected PropertyResource getRef()
        Description copied from class: Resource
        Perform the check for circular references and return the referenced Resource.
        Overrides:
        getRef in class Resource
        Returns:
        Resource.