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

java.lang.Object
  extended by org.apache.excalibur.source.impl.AbstractSource
      extended by org.apache.cocoon.components.source.impl.XModuleSource
All Implemented Interfaces:
DOMBuilder.Listener, ModifiableSource, Source, XMLizable

public class XModuleSource
extends AbstractSource
implements ModifiableSource, XMLizable, DOMBuilder.Listener

A ModifiableSource that takes its content from a module.

The URI syntax is "xmodule:[|]:attribute-name[#XPath]", where :

Author:
Daniel Fagerstom

Field Summary
protected  ServiceManager manager
           
 
Constructor Summary
XModuleSource(Map objectModel, String uri, ServiceManager manager, Logger logger)
          Create a xmodule source from a 'xmodule:' uri and a the object model.
 
Method Summary
 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 delete()
          Delete the source
 void deleteTest()
          FIXME delete is an operator in java script, this method is for testing puposes in java script only
 boolean exists()
          Does this source actually exist ?
 ContentHandler getContentHandler()
          Get a ContentHandler where an XML document can be written using SAX events.
 InputStream getInputStream()
          Return an InputStream object to read from the source.
 OutputStream getOutputStream()
          Get an InputStream where raw bytes can be written to.
 void notify(Document insertDoc)
          Receive notification of a successfully completed DOM tree generation.
 void toSAX(ContentHandler handler)
          Implement this method to obtain SAX events.
 
Methods inherited from class org.apache.excalibur.source.impl.AbstractSource
checkInfos, getContentLength, getInfos, getLastModified, getMimeType, getScheme, getURI, getValidity, refresh, 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, getMimeType, getScheme, getURI, getValidity, refresh
 

Field Detail

manager

protected ServiceManager manager
Constructor Detail

XModuleSource

public XModuleSource(Map objectModel,
                     String uri,
                     ServiceManager manager,
                     Logger logger)
              throws MalformedURLException
Create a xmodule source from a 'xmodule:' uri and a the object model.

The uri is of the form "xmodule:/attribute-type/attribute-name/xpath

Throws:
MalformedURLException
Method Detail

toSAX

public void toSAX(ContentHandler handler)
           throws SAXException
Implement this method to obtain SAX events.

Specified by:
toSAX in interface XMLizable
Throws:
SAXException

getInputStream

public InputStream getInputStream()
                           throws IOException,
                                  SourceException
Return an InputStream object to read from the source.

Specified by:
getInputStream in interface Source
Overrides:
getInputStream in class AbstractSource
Throws:
IOException - if I/O error occured.
SourceException

exists

public boolean exists()
Does this source actually exist ?

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

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Get an InputStream 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

delete

public void delete()
            throws SourceException
Delete the source

Specified by:
delete in interface ModifiableSource
Throws:
SourceException

deleteTest

public void deleteTest()
                throws SourceException
FIXME delete is an operator in java script, this method is for testing puposes in java script only

Throws:
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
Returns:
true if the stream can be cancelled

cancel

public void cancel(OutputStream stream)
            throws IOException
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
Throws:
IOException

getContentHandler

public ContentHandler getContentHandler()
Get a ContentHandler where an XML document can be written using SAX events.

Care should be taken that the returned handler can actually be a XMLConsumer supporting also lexical events such as comments.

Returns:
a handler for SAX events

notify

public void notify(Document insertDoc)
            throws SAXException
Description copied from interface: DOMBuilder.Listener
Receive notification of a successfully completed DOM tree generation.

Specified by:
notify in interface DOMBuilder.Listener
Throws:
SAXException


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