org.apache.avalon.excalibur.monitor
Class StreamResource

java.lang.Object
  extended by org.apache.avalon.excalibur.monitor.Resource
      extended by org.apache.avalon.excalibur.monitor.StreamResource
All Implemented Interfaces:
Modifiable
Direct Known Subclasses:
FileResource, SourceResource

public abstract class StreamResource
extends Resource

Managed Stream based Resource. This is convenient when you want to dynamically set and get the information from the resource. For instance, the Resource does not need to be actively monitored if all access to the resource goes through this type of Resource. It can notify the change as soon as the Writer or OutputStream has been closed.

Version:
$Id: StreamResource.java,v 1.4 2004/02/28 11:47:32 cziegeler Exp $
Author:
Avalon Development Team

Field Summary
 
Fields inherited from class org.apache.avalon.excalibur.monitor.Resource
m_eventSupport, m_previousModified, MODIFIED
 
Constructor Summary
StreamResource(String location)
          Required constructor.
 
Method Summary
abstract  Reader getResourceAsReader()
          Get the Resource contents as a Reader.
abstract  InputStream getResourceAsStream()
          Get the Resource contents as an InputStream.
abstract  OutputStream setResourceAsStream()
          Set the Resource contents as an OutputStream.
abstract  Writer setResourceAsWriter()
          Set the Resource contents as a Writer.
protected  void streamClosedEvent()
          Automatically handle the streamClosedEvent from the ResourceOutputStream and ResourceWriter.
 
Methods inherited from class org.apache.avalon.excalibur.monitor.Resource
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListenersFrom, fireAndSetModifiedTime, getEventSupport, getPreviousModified, getResourceKey, hasListeners, hasListeners, lastModified, removeAllPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener, setPreviousModified, testModifiedAfter, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StreamResource

public StreamResource(String location)
               throws Exception
Required constructor. The String location is transformed by the specific resource monitor. For instance, a FileResource will be able to convert a string representation of a path to the proper File object.

Throws:
Exception
Method Detail

getResourceAsStream

public abstract InputStream getResourceAsStream()
                                         throws IOException
Get the Resource contents as an InputStream.

Throws:
IOException

getResourceAsReader

public abstract Reader getResourceAsReader()
                                    throws IOException
Get the Resource contents as a Reader.

Throws:
IOException

setResourceAsStream

public abstract OutputStream setResourceAsStream()
                                          throws IOException
Set the Resource contents as an OutputStream.

Throws:
IOException

setResourceAsWriter

public abstract Writer setResourceAsWriter()
                                    throws IOException
Set the Resource contents as a Writer.

Throws:
IOException

streamClosedEvent

protected void streamClosedEvent()
Automatically handle the streamClosedEvent from the ResourceOutputStream and ResourceWriter.



Copyright © 1997-2012 Apache Software Foundation. All Rights Reserved.