org.apache.cocoon.components.source.impl
Class RepositorySource

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.components.source.impl.RepositorySource
All Implemented Interfaces:
LogEnabled, InspectableSource, ModifiableSource, ModifiableTraversableSource, Source, TraversableSource

public class RepositorySource
extends AbstractLogEnabled
implements Source, ModifiableTraversableSource, InspectableSource

Source wrapper that enhances the wrapped sources with additional capabilities.

Currently this Source optionally adds inspectability through the InspectableSource interface.

Wrapped sources must implement ModifiableTraversableSource.


Constructor Summary
RepositorySource(String prefix, ModifiableTraversableSource delegate, SourceDescriptor descriptor, Logger logger)
           
 
Method Summary
 boolean canCancel(OutputStream out)
           
 void cancel(OutputStream out)
           
 void delete()
           
 boolean exists()
           
 Source getChild(String name)
           
 Collection getChildren()
           
 long getContentLength()
           
 InputStream getInputStream()
           
 long getLastModified()
           
 String getMimeType()
           
 String getName()
           
 OutputStream getOutputStream()
           
 Source getParent()
           
 String getScheme()
           
 SourceProperty[] getSourceProperties()
          Get all source properties that are defined on the wrapped source.
 SourceProperty getSourceProperty(String uri, String name)
          Get the source property on the wrapped source.
 String getURI()
           
 SourceValidity getValidity()
          Return a SourceValidity object describing the validity of this Source.
 boolean isCollection()
           
 void makeCollection()
           
 void refresh()
           
 void removeSourceProperty(String uri, String name)
          Remove the source property on the wrapped source.
 void setSourceProperty(SourceProperty property)
          Set the source property on the wrapped source.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepositorySource

public RepositorySource(String prefix,
                        ModifiableTraversableSource delegate,
                        SourceDescriptor descriptor,
                        Logger logger)
                 throws SourceException
Throws:
SourceException
Method Detail

getSourceProperties

public SourceProperty[] getSourceProperties()
                                     throws SourceException
Get all source properties that are defined on the wrapped source. If the wrapped source is itself an InspectableSource the implementation will return the aggregate set that results from combining the properties returned from a delegate call to the wrapped source with the properties returned by the source descriptor.

Specified by:
getSourceProperties in interface InspectableSource
Throws:
SourceException

getSourceProperty

public SourceProperty getSourceProperty(String uri,
                                        String name)
                                 throws SourceException
Get the source property on the wrapped source. If the wrapped source implements InspectableSource the implementation will first try to get it from there. If it doesn't exist on the delegate it will try to find it using the source descriptor.

Specified by:
getSourceProperty in interface InspectableSource
Throws:
SourceException

removeSourceProperty

public void removeSourceProperty(String uri,
                                 String name)
                          throws SourceException
Remove the source property on the wrapped source. If the wrapped source implements InspectableSource the implementation will try to remove the property on both the wrapped source directly and on the source descriptor.

Specified by:
removeSourceProperty in interface InspectableSource
Throws:
SourceException

setSourceProperty

public void setSourceProperty(SourceProperty property)
                       throws SourceException
Set the source property on the wrapped source. If the wrapped source implements InspectableSource set the property directly on the wrapped source. Otherwise set it on the SourceDescriptor.

Specified by:
setSourceProperty in interface InspectableSource
Throws:
SourceException

exists

public boolean exists()
Specified by:
exists in interface Source

getContentLength

public long getContentLength()
Specified by:
getContentLength in interface Source

getInputStream

public InputStream getInputStream()
                           throws IOException,
                                  SourceNotFoundException
Specified by:
getInputStream in interface Source
Throws:
IOException
SourceNotFoundException

getLastModified

public long getLastModified()
Specified by:
getLastModified in interface Source

getMimeType

public String getMimeType()
Specified by:
getMimeType in interface Source

getScheme

public String getScheme()
Specified by:
getScheme in interface Source

getURI

public String getURI()
Specified by:
getURI in interface Source

getValidity

public SourceValidity getValidity()
Return a SourceValidity object describing the validity of this Source.

If the SourceDescriptor service is present, the resulting validity is an aggregated validity object containing both the validity describing the source itself _and_ one describing the validity of the SourceProperties managed by the SourceDescriptor.

Specified by:
getValidity in interface Source

refresh

public void refresh()
Specified by:
refresh in interface Source

getChild

public Source getChild(String name)
                throws SourceException
Specified by:
getChild in interface TraversableSource
Throws:
SourceException

getChildren

public Collection getChildren()
                       throws SourceException
Specified by:
getChildren in interface TraversableSource
Throws:
SourceException

getName

public String getName()
Specified by:
getName in interface TraversableSource

getParent

public Source getParent()
                 throws SourceException
Specified by:
getParent in interface TraversableSource
Throws:
SourceException

isCollection

public boolean isCollection()
Specified by:
isCollection in interface TraversableSource

makeCollection

public void makeCollection()
                    throws SourceException
Specified by:
makeCollection in interface ModifiableTraversableSource
Throws:
SourceException

canCancel

public boolean canCancel(OutputStream out)
Specified by:
canCancel in interface ModifiableSource

cancel

public void cancel(OutputStream out)
            throws IOException
Specified by:
cancel in interface ModifiableSource
Throws:
IOException

delete

public void delete()
            throws SourceException
Specified by:
delete in interface ModifiableSource
Throws:
SourceException

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Specified by:
getOutputStream in interface ModifiableSource
Throws:
IOException


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.