org.apache.cocoon.components.source
Class SourceDTO

java.lang.Object
  extended by org.apache.cocoon.components.source.SourceDTO
All Implemented Interfaces:
InspectableSource, LockableSource, VersionableSource, ModifiableSource, ModifiableTraversableSource, MoveableSource, Source, TraversableSource

public class SourceDTO
extends Object
implements Source, ModifiableTraversableSource, MoveableSource, LockableSource, InspectableSource, VersionableSource

Data transfer object for a Source object.

Version:
CVS $Id: SourceDTO.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Constructor Summary
SourceDTO(Source source)
          Create a data transfer object for a Source.
SourceDTO(Source source, boolean deep)
          Create a data transfer object for a Source.
 
Method Summary
 void addSourceLocks(SourceLock sourcelock)
          Add a lock to this source
 boolean canCancel(OutputStream stream)
          Can the data sent to an OutputStream returned by getOutputStream() be cancelled ?
 void cancel(OutputStream stream)
          Cancel the data sent to an OutputStream returned by getOutputStream().
 void copyTo(Source source)
          Copy the current source to a specified destination.
 void delete()
          Delete the source.
 boolean exists()
          Does this source actually exist ?
 String getAuthority()
          Return the authority of a URI.
 Source getChild(String name)
           
 Collection getChildren()
           
 long getContentLength()
          Return the content length of the content or -1 if the length is unknown.
 String getFragment()
          Return the fragment of a URI.
 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.
 String getLatestSourceRevision()
          Get the latest revision
 String getMimeType()
          The mime-type of the content described by this object.
 String getName()
           
 OutputStream getOutputStream()
          Get an OutputStream where raw bytes can be written to.
 Source getParent()
           
 String getPath()
          Return the path of a URI.
 String getQuery()
          Return the query of a URI.
 String getScheme()
           
 SourceLock[] getSourceLocks()
          Returns a enumeration of the existing locks
 SourceProperty[] getSourceProperties()
          Returns a enumeration of the properties
 SourceProperty getSourceProperty(String namespace, String name)
          Returns a property from a source.
 String getSourceRevision()
          Get the current revision of the source
 String getSourceRevisionBranch()
          Get the current branch of the revision from the source
 String getURI()
          Return the unique identifer for this source
 SourceValidity getValidity()
          Get the Validity object.
 boolean isCollection()
           
 boolean isVersioned()
          If this source versioned
 void makeCollection()
           
 void moveTo(Source source)
          Move the current source to a specified destination.
 void refresh()
          Refresh the content of this object after the underlying data content has changed.
 void removeSourceProperty(String namespace, String name)
          Remove a specified source property.
 void setSourceProperty(SourceProperty property)
          Sets a property for a source.
 void setSourceRevision(String revision)
          Not implemented.
 void setSourceRevisionBranch(String branch)
          Not implemented.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SourceDTO

public SourceDTO(Source source)
Create a data transfer object for a Source.

Parameters:
source - Source

SourceDTO

public SourceDTO(Source source,
                 boolean deep)
Create a data transfer object for a Source.

Parameters:
source - Source
Method Detail

getInputStream

public InputStream getInputStream()
                           throws IOException,
                                  SourceException
Return an InputStream object to read from the source. This is the data at the point of invocation of this method, so if this is Modifiable, you might get different content from two different invocations.

Specified by:
getInputStream in interface Source
Returns:
Input stream for the source.
Throws:
IOException - If an IO excepetion occurs.
SourceException - If an exception occurs.

getURI

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

Specified by:
getURI in interface Source
Returns:
System identifier for the source.

getScheme

public String getScheme()
Specified by:
getScheme in interface Source
Returns:
Scheme of the source.
See Also:
Source.getScheme()

getAuthority

public String getAuthority()
Return the authority of a URI. This authority is typically defined by an Internet-based server or a scheme-specific registry of naming authorities (see RFC 2396).

Returns:
Scheme of the URI.

getPath

public String getPath()
Return the path of a URI. The path contains data, specific to the authority (or the scheme if there is no authority component), identifying the resource within the scope of that scheme and authority (see RFC 2396).

Returns:
Path of the URI.

getQuery

public String getQuery()
Return the query of a URI. The query is a string of information to be interpreted by the resource (see RFC 2396).

Returns:
Query of the URI.

getFragment

public String getFragment()
Return the fragment of a URI. When a URI reference is used to perform a retrieval action on the identified resource, the optional fragment identifier, consists of additional reference information to be interpreted by the user agent after the retrieval action has been successfully completed (see RFC 2396).

Returns:
Fragment of the URI.

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:
Validity for the source.

refresh

public void refresh()
Refresh the content of this object after the underlying data content has changed.

Specified by:
refresh in interface Source

getMimeType

public 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:
Mime type of the source.

exists

public boolean exists()
Does this source actually exist ?

Specified by:
exists in interface Source
Returns:
true if the resource exists.

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:
Content length of the source.

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:
Last modified date of the source.

getOutputStream

public OutputStream getOutputStream()
                             throws IOException,
                                    SourceException
Get an OutputStream where raw bytes can be written to. The signification of these bytes is implementation-dependent and is not restricted to a serialized XML document.

Specified by:
getOutputStream in interface ModifiableSource
Returns:
a stream to write to
Throws:
IOException
SourceException

canCancel

public boolean canCancel(OutputStream stream)
Can the data sent to an OutputStream returned by getOutputStream() be cancelled ?

Specified by:
canCancel in interface ModifiableSource
Parameters:
stream - The ouput stream, which should be cancelled.
Returns:
true if the stream can be cancelled

cancel

public void cancel(OutputStream stream)
            throws SourceException
Cancel the data sent to an OutputStream returned by getOutputStream().

After cancel, the stream should no more be used.

Specified by:
cancel in interface ModifiableSource
Parameters:
stream - The ouput stream, which should be cancelled.
Throws:
SourceException - If the ouput stream can't be cancelled.

delete

public void delete()
Delete the source.

Specified by:
delete in interface ModifiableSource

makeCollection

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

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

moveTo

public void moveTo(Source source)
            throws SourceException
Move the current source to a specified destination.

Specified by:
moveTo in interface MoveableSource
Parameters:
source -
Throws:
SourceException - If an exception occurs during the move.

copyTo

public void copyTo(Source source)
            throws SourceException
Copy the current source to a specified destination.

Specified by:
copyTo in interface MoveableSource
Parameters:
source -
Throws:
SourceException - If an exception occurs during the copy.

getSourceProperty

public SourceProperty getSourceProperty(String namespace,
                                        String name)
                                 throws SourceException
Returns a property from a source.

Specified by:
getSourceProperty in interface InspectableSource
Parameters:
namespace - Namespace of the property
name - Name of the property
Returns:
Property of the source.
Throws:
SourceException - If an exception occurs.

setSourceProperty

public void setSourceProperty(SourceProperty property)
                       throws SourceException
Sets a property for a source.

Specified by:
setSourceProperty in interface InspectableSource
Parameters:
property - Property of the source
Throws:
SourceException - If an exception occurs during this operation

getSourceProperties

public SourceProperty[] getSourceProperties()
                                     throws SourceException
Returns a enumeration of the properties

Specified by:
getSourceProperties in interface InspectableSource
Returns:
Enumeration of SourceProperty
Throws:
SourceException - If an exception occurs.

removeSourceProperty

public void removeSourceProperty(String namespace,
                                 String name)
                          throws SourceException
Remove a specified source property.

Specified by:
removeSourceProperty in interface InspectableSource
Parameters:
namespace - Namespace of the property.
name - Name of the property.
Throws:
SourceException - If an exception occurs.

addSourceLocks

public void addSourceLocks(SourceLock sourcelock)
                    throws SourceException
Add a lock to this source

Specified by:
addSourceLocks in interface LockableSource
Parameters:
sourcelock - Lock, which should be added
Throws:
SourceException - If an exception occurs during this operation

getSourceLocks

public SourceLock[] getSourceLocks()
                            throws SourceException
Returns a enumeration of the existing locks

Specified by:
getSourceLocks in interface LockableSource
Returns:
Enumeration of SourceLock
Throws:
SourceException - If an exception occurs.

isVersioned

public boolean isVersioned()
                    throws SourceException
If this source versioned

Specified by:
isVersioned in interface VersionableSource
Returns:
True if the current source is versioned.
Throws:
SourceException - If an exception occurs.

getSourceRevision

public String getSourceRevision()
Get the current revision of the source

Specified by:
getSourceRevision in interface VersionableSource
Returns:
The current revision of the source

setSourceRevision

public void setSourceRevision(String revision)
                       throws SourceException
Not implemented.

Specified by:
setSourceRevision in interface VersionableSource
Parameters:
revision - The revision, which should be used.
Throws:
SourceException - If an exception occurs.

getSourceRevisionBranch

public String getSourceRevisionBranch()
                               throws SourceException
Get the current branch of the revision from the source

Specified by:
getSourceRevisionBranch in interface VersionableSource
Returns:
The branch of the revision
Throws:
SourceException - If an exception occurs.

setSourceRevisionBranch

public void setSourceRevisionBranch(String branch)
                             throws SourceException
Not implemented.

Specified by:
setSourceRevisionBranch in interface VersionableSource
Parameters:
branch - The branch, which should be used.
Throws:
SourceException - If an exception occurs.

getLatestSourceRevision

public String getLatestSourceRevision()
                               throws SourceException
Get the latest revision

Specified by:
getLatestSourceRevision in interface VersionableSource
Returns:
Last revision of the source.
Throws:
SourceException - If an exception occurs.


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