Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tapestry5.ioc.internal.util
Class AbstractResource

    java.lang.Object
      org.apache.tapestry5.ioc.internal.util.LockSupport
          org.apache.tapestry5.ioc.internal.util.AbstractResource

All Implemented Interfaces:
  Resource

Direct Known Subclasses:
  ClasspathResource, ContextResource

    public abstract class AbstractResource

extends LockSupport
implements Resource

Abstract implementation of `Resource`. Subclasses must implement the abstract methods `Resource.toURL()` and `newResource(String)` as well as toString(), hashCode() and equals().

Constructor Summary
`protected` | `AbstractResource(java.lang.String path)`

Method Summary
`boolean` | `exists()` Simple check for whether `Resource.toURL()` returns null or not.
`Resource` | `forFile(java.lang.String relativePath)` Returns a Resource based on a relative path, relative to the folder containing the resource.
`Resource` | `forLocale(java.util.Locale locale)` Returns a localized version of the resource.
`java.lang.String` | `getFile()` Returns the file portion of the Resource path, everything that follows the final forward slash.
`java.lang.String` | `getFolder()` Returns the portion of the path up to the last forward slash; this is the directory or folder portion of the Resource.
`java.lang.String` | `getPath()` Return the path (the combination of folder and file).
`protected abstract Resource` | `newResource(java.lang.String path)` Factory method provided by subclasses.
`java.io.InputStream` | `openStream()` Obtains the URL for the Resource and opens the stream, wrapped by a BufferedInputStream.
`Resource` | `withExtension(java.lang.String extension)` Returns a new Resource with the extension changed (or, if the resource does not have an extension, the extension is added).

Methods inherited from class org.apache.tapestry5.ioc.internal.util.LockSupport
`acquireReadLock, downgradeWriteLockToReadLock, releaseReadLock, releaseWriteLock, takeWriteLock, upgradeReadLockToWriteLock`

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

Methods inherited from interface org.apache.tapestry5.ioc.Resource
`toURL`

Constructor Detail

### AbstractResource

    protected AbstractResource(java.lang.String path)

Method Detail

### getPath

    public final java.lang.String getPath()

  Description copied from interface: `Resource`
  Return the path (the combination of folder and file).

  Specified by:
    `getPath` in interface `Resource`

### getFile

    public final java.lang.String getFile()

  Description copied from interface: `Resource`
  Returns the file portion of the Resource path, everything that follows the final forward slash.

  Specified by:
    `getFile` in interface `Resource`

### getFolder

    public final java.lang.String getFolder()

  Description copied from interface: `Resource`
  Returns the portion of the path up to the last forward slash; this is the directory or folder portion of the Resource.

  Specified by:
    `getFolder` in interface `Resource`

### forFile

    public final Resource forFile(java.lang.String relativePath)

  Description copied from interface: `Resource`
  Returns a Resource based on a relative path, relative to the folder containing the resource. Understands the "." (current folder) and ".." (parent folder) conventions, and treats multiple sequential slashes as a single slash.

  Specified by:
    `forFile` in interface `Resource`

### forLocale

    public final Resource forLocale(java.util.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`

### withExtension

    public final Resource withExtension(java.lang.String extension)

  Description copied from interface: `Resource`
  Returns a new Resource with the extension changed (or, if the resource does not have an extension, the extension is added). The new Resource may not exist (that is, `Resource.toURL()` may return null.

  Specified by:
    `withExtension` in interface `Resource`
  Parameters:
    `extension` - to apply to the resource, such as "html" or "properties"
  Returns:
    the new resource

### exists

    public boolean exists()

  Simple check for whether `Resource.toURL()` returns null or not.

  Specified by:
    `exists` in interface `Resource`
  Returns:
    true if the resource exists, false if it does not

### openStream

    public java.io.InputStream openStream()
                                   throws java.io.IOException

  Obtains the URL for the Resource and opens the stream, wrapped by a BufferedInputStream.

  Specified by:
    `openStream` in interface `Resource`
  Returns:
    an open, buffered stream to the content, if available
  Throws:
    `java.io.IOException`

### newResource

    protected abstract Resource newResource(java.lang.String path)

  Factory method provided by subclasses.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2012 The Apache Software Foundation.