Package org.apache.tapestry5.internal.services

## Class UrlResource

- java.lang.Object
- - org.apache.tapestry5.internal.util.VirtualResource
  - - org.apache.tapestry5.internal.services.UrlResource

- All Implemented Interfaces:
    `Resource`

      public class UrlResource
      extends VirtualResource

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static URL` | `PLACEHOLDER_URL` |

    - ### Fields inherited from class org.apache.tapestry5.internal.util.VirtualResource

      `UTF8`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `UrlResource()` |
    `UrlResource​(URL url)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `exists()` | Returns true if the resource exists; if a stream to the content of the file may be opened.
    `Resource` | `forLocale​(Locale locale)` | Returns a localized version of the resource.
    `InputStream` | `openStream()` | Opens a stream to the content of the resource, or returns null if the resource does not exist.
    `String` | `toString()` |
    `URL` | `toURL()` | Returns the URL for the resource, or null if it does not exist.

    - ### Methods inherited from class org.apache.tapestry5.internal.util.VirtualResource

      `forFile, getFile, getFolder, getPath, isVirtual, toInputStream, toInputStream, withExtension`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### PLACEHOLDER_URL

          public static final URL PLACEHOLDER_URL

  - ### Constructor Detail

    - #### UrlResource

          public UrlResource()

    - #### UrlResource

          public UrlResource​(URL url)

  - ### Method Detail

    - #### openStream

          public InputStream openStream()
                                 throws IOException

      Description copied from interface: `Resource`
      Opens a stream to the content of the resource, or returns null if the resource does not exist. The native input stream supplied by the resource is wrapped in a `BufferedInputStream`.
      Returns:
        an open, buffered stream to the content, if available
      Throws:
        `IOException`

    - #### toURL

          public URL toURL()

      Description copied from interface: `Resource`
      Returns the URL for the resource, or null if it does not exist. This value is lazily computed; starting in 5.3.4, subclasses may cache the result. Starting in 5.4, some "virtual resources" may return null.
      Specified by:
        `toURL` in interface `Resource`
      Overrides:
        `toURL` in class `VirtualResource`

    - #### exists

          public boolean exists()

      Description copied from interface: `Resource`
      Returns true if the resource exists; if a stream to the content of the file may be opened. A resource exists if `Resource.toURL()` returns a non-null value. Starting in release 5.3.4, the result of this is cached. Starting in 5.4, some "virtual resources", may return true even though `Resource.toURL()` returns null.
      Specified by:
        `exists` in interface `Resource`
      Overrides:
        `exists` in class `VirtualResource`
      Returns:
        true if the resource exists, false if it does not

    - #### forLocale

          public Resource forLocale​(Locale locale)

      Description copied from interface: `Resource`
      Returns a localized version of the resource. May return null if no such resource exists. Starting in release 5.3.4, the result of this method is cached internally.
      Specified by:
        `forLocale` in interface `Resource`
      Overrides:
        `forLocale` in class `VirtualResource`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`