org.apache.excalibur.source.impl
Class URLSource

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

public class URLSource
extends AbstractSource
implements Source

Description of a source which is described by an URL.

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

Field Summary
protected  long m_cachedLastModificationDate
           
protected  SourceValidity m_cachedValidity
          the prev returned SourceValidity
protected  java.net.URLConnection m_connection
          The connection for a real URL
protected  java.lang.String m_encoding
          The encoding of the SourceParameters
protected  boolean m_exists
          Does this source exist ?
protected  boolean m_isPost
          Is this a post?
protected  java.lang.String m_mimeType
          The content type (if known)
protected  SourceParameters m_parameters
          The SourceParameters used for a post
protected  java.net.URL m_url
          The URL of the source
 
Constructor Summary
URLSource()
          Constructor
 
Method Summary
 boolean exists()
          Does this source exist ?
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.
 java.lang.String getMimeType()
          The mime-type of the content described by this object.
protected  java.lang.String getUserInfo()
          The decoded userinfo for this source.
 SourceValidity getValidity()
          Get the Validity object.
 void init(java.net.URL url, java.util.Map parameters)
          Initialize a new object from a URL.
 void refresh()
          Refresh this object and update the last modified date and content length.
 
Methods inherited from class org.apache.excalibur.source.impl.AbstractSource
checkInfos, getContentLength, getLastModified, getScheme, getURI, setContentLength, setLastModified, setScheme, setSystemId
 
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
getContentLength, getLastModified, getScheme, getURI
 

Field Detail

m_url

protected java.net.URL m_url
The URL of the source


m_connection

protected java.net.URLConnection m_connection
The connection for a real URL


m_parameters

protected SourceParameters m_parameters
The SourceParameters used for a post


m_encoding

protected java.lang.String m_encoding
The encoding of the SourceParameters


m_isPost

protected boolean m_isPost
Is this a post?


m_exists

protected boolean m_exists
Does this source exist ?


m_cachedValidity

protected SourceValidity m_cachedValidity
the prev returned SourceValidity


m_cachedLastModificationDate

protected long m_cachedLastModificationDate

m_mimeType

protected java.lang.String m_mimeType
The content type (if known)

Constructor Detail

URLSource

public URLSource()
Constructor

Method Detail

init

public void init(java.net.URL url,
                 java.util.Map parameters)
          throws java.io.IOException
Initialize a new object from a URL.

Parameters:
parameters - This is optional
Throws:
java.io.IOException

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

Overrides:
getInfos in class AbstractSource

exists

public boolean exists()
Does this source exist ?

Specified by:
exists in interface Source
Returns:
true if the source exists

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
Overrides:
getInputStream in class AbstractSource
Throws:
SourceException - if file not found or HTTP location does not exist.
java.io.IOException - if I/O error occured.

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
Overrides:
getValidity in class AbstractSource

refresh

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

Specified by:
refresh in interface Source
Overrides:
refresh in class AbstractSource

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
Overrides:
getMimeType in class AbstractSource

getUserInfo

protected java.lang.String getUserInfo()
The decoded userinfo for this source. null, if no userinfo exists



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