org.apache.avalon.excalibur.source
Class URLSource

java.lang.Object
  |
  +--org.apache.avalon.excalibur.source.URLSource
All Implemented Interfaces:
org.apache.avalon.framework.component.Composable, ModifiableSource, Monitorable, Source, XMLizable

public final class URLSource
extends java.lang.Object
implements org.apache.avalon.framework.component.Composable, ModifiableSource, XMLizable, Monitorable

Description of a source which is described by an URL.

Version:
CVS $Revision: 1.11 $ $Date: 2002/01/08 13:43:48 $
Author:
Carsten Ziegeler

Constructor Summary
URLSource(java.net.URL url, SourceParameters parameters)
          Construct a new object
 
Method Summary
 void compose(org.apache.avalon.framework.component.ComponentManager manager)
           
 void discardValidity()
          Refresh this object and update the last modified date and content length.
 long getContentLength()
          Get the content length of the source or -1 if it is not possible to determine the length.
protected  org.xml.sax.InputSource getInputSource()
          Return a new InputSource object
 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.
 Resource getResource()
          Get the corresponding Resource object for monitoring.
 java.lang.String getSystemId()
          Return the unique identifer for this source
 SourceValidity getValidity()
          Get the Validity object.
 void toSAX(org.xml.sax.ContentHandler handler)
          Stream content to a content handler or to an XMLConsumer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URLSource

public URLSource(java.net.URL url,
                 SourceParameters parameters)
          throws java.io.IOException
Construct a new object
Parameters:
parameters - This is optional
Method Detail

compose

public void compose(org.apache.avalon.framework.component.ComponentManager manager)
Specified by:
compose in interface org.apache.avalon.framework.component.Composable

getLastModified

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

getResource

public Resource getResource()
                     throws java.lang.Exception
Get the corresponding Resource object for monitoring.
Specified by:
getResource in interface Monitorable

getContentLength

public long getContentLength()
Get the content length of the source or -1 if it is not possible to determine the length.

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Return an InputStream object to read from the source.
Specified by:
getInputStream in interface Source
Throws:
ResourceNotFoundException - if file not found or HTTP location does not exist.
java.io.IOException - if I/O error occured.

getSystemId

public java.lang.String getSystemId()
Return the unique identifer for this source
Specified by:
getSystemId in interface Source

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 ModifiableSource

discardValidity

public void discardValidity()
Refresh this object and update the last modified date and content length.
Specified by:
discardValidity in interface ModifiableSource

getInputSource

protected org.xml.sax.InputSource getInputSource()
                                          throws java.io.IOException
Return a new InputSource object
Throws:
java.io.IOException - if I/O error occured.

toSAX

public void toSAX(org.xml.sax.ContentHandler handler)
           throws org.xml.sax.SAXException
Stream content to a content handler or to an XMLConsumer.
Specified by:
toSAX in interface XMLizable
Throws:
ResourceNotFoundException - if file not found or HTTP location does not exist.
org.xml.sax.SAXException - if failed to parse source document.


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.