org.apache.excalibur.source.impl
Class AbstractSource

java.lang.Object
  extended byorg.apache.excalibur.source.impl.AbstractSource
All Implemented Interfaces:
Source
Direct Known Subclasses:
CommonsVFSSource, ResourceSource, URLSource

public abstract class AbstractSource
extends java.lang.Object
implements Source

Abstract base class for a source implementation.

Version:
CVS $Revision: 1.5 $ $Date: 2004/02/28 11:47:24 $
Author:
Avalon Development Team

Constructor Summary
AbstractSource()
           
 
Method Summary
protected  void checkInfos()
          Call getInfos() if it hasn't already been called since the last call to refresh().
 long getContentLength()
          Return the content length of the content or -1 if the length is unknown
protected  void getInfos()
          Get the last modification date and content length of the source.
 java.io.InputStream getInputStream()
          Return an InputStream object to read from the source.
 long getLastModified()
          Get the last modification date of the source or 0 if it is not possible to determine the date.
 java.lang.String getMimeType()
          The mime-type of the content described by this object.
 java.lang.String getScheme()
          Return the protocol identifier.
 java.lang.String getURI()
          Return the unique identifer for this source
 SourceValidity getValidity()
          Get the Validity object.
 void refresh()
          Refresh this object and update the last modified date and content length.
protected  void setContentLength(long contentLength)
          Sets the contentLength.
protected  void setLastModified(long lastModificationDate)
          Sets the lastModificationDate.
protected  void setScheme(java.lang.String scheme)
          Sets the scheme.
protected  void setSystemId(java.lang.String systemId)
          Sets the systemId.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.excalibur.source.Source
exists
 

Constructor Detail

AbstractSource

public AbstractSource()
Method Detail

getInfos

protected void getInfos()
Get the last modification date and content length of the source. Any exceptions are ignored. Override this to get the real information


checkInfos

protected void checkInfos()
Call getInfos() if it hasn't already been called since the last call to refresh().


getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException,
                                          SourceException
Return an InputStream object to read from the source. The returned stream must be closed by the calling code.

Specified by:
getInputStream in interface Source
Returns:
the InputStream to read data from (never null).
Throws:
SourceException - if file not found or HTTP location does not exist.
java.io.IOException - if I/O error occured.

getURI

public java.lang.String getURI()
Return the unique identifer for this source

Specified by:
getURI in interface Source
Returns:
the source URI.

getScheme

public java.lang.String getScheme()
Return the protocol identifier.

Specified by:
getScheme in interface Source
Returns:
the URI scheme.

getValidity

public SourceValidity getValidity()
Get the Validity object. This can either wrap the last modification date or the expires information or... If it is currently not possible to calculate such an information null is returned.

Specified by:
getValidity in interface Source
Returns:
the validity, or null.

refresh

public void refresh()
Refresh this object and update the last modified date and content length.

Specified by:
refresh in interface Source

getMimeType

public java.lang.String getMimeType()
The mime-type of the content described by this object. If the source is not able to determine the mime-type by itself this can be null.

Specified by:
getMimeType in interface Source
Returns:
the source's mime-type or null.

getContentLength

public long getContentLength()
Return the content length of the content or -1 if the length is unknown

Specified by:
getContentLength in interface Source
Returns:
the source's content length or -1.

getLastModified

public long getLastModified()
Get the last modification date of the source or 0 if it is not possible to determine the date.

Specified by:
getLastModified in interface Source
Returns:
the last modification date or 0.

setContentLength

protected void setContentLength(long contentLength)
Sets the contentLength.

Parameters:
contentLength - The contentLength to set

setLastModified

protected void setLastModified(long lastModificationDate)
Sets the lastModificationDate.

Parameters:
lastModificationDate - The lastModificationDate to set

setScheme

protected void setScheme(java.lang.String scheme)
Sets the scheme.

Parameters:
scheme - The scheme to set

setSystemId

protected void setSystemId(java.lang.String systemId)
Sets the systemId.

Parameters:
systemId - The systemId to set


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.