nu.staldal.lagoon.core
Interface SourceManager


public interface SourceManager

Defines operations a Producer can do on the source file tree.


Method Summary
 boolean fileHasBeenUpdated(java.lang.String url, long when)
          Check if the specified file has been updated since the specified time.
 java.io.File getFile(java.lang.String url)
          Get a File object representing the given file or directory.
 javax.xml.transform.Source getFileAsJAXPSource(java.lang.String url, Target target)
          Get a TrAX/JAXP Source object representing the given file.
 void getFileAsSAX(java.lang.String url, org.xml.sax.ContentHandler sax, Target target)
          Parse the file as XML and deliver SAX2 events.
 java.lang.String getFileURL(java.lang.String url)
          Get an URL representing the given file or directory.
 java.lang.String getSourceURL()
          Get the URL representing the main source.
 java.io.InputStream openFile(java.lang.String url)
          Open an auxiallary source file.
 

Method Detail

getSourceURL

java.lang.String getSourceURL()
                              throws java.io.FileNotFoundException
Get the URL representing the main source. Might be a file or a directory.

Returns:
an absolute or pseudo-absolute URL, never null
Throws:
java.io.FileNotFoundException - if the main source file is not specified

openFile

java.io.InputStream openFile(java.lang.String url)
                             throws java.io.FileNotFoundException,
                                    java.io.IOException
Open an auxiallary source file. This might e.g. be used to read the stylesheet for an XSLT transformation.

Parameters:
url - URL to the file, if relative it's searched for relative to the main source file (or a FileNotFoundException is thrown if there is no main source file).
Returns:
an InputStream to the file.
Throws:
java.io.FileNotFoundException
java.io.IOException

getFile

java.io.File getFile(java.lang.String url)
                     throws java.io.FileNotFoundException
Get a File object representing the given file or directory.

Parameters:
url - URL to the file, if relative it's searched for relative to the main source file (or a FileNotFoundException is thrown if there is no main source file).
Returns:
null if URL is absolute with another scheme than file or res.
Throws:
java.io.FileNotFoundException

getFileAsJAXPSource

javax.xml.transform.Source getFileAsJAXPSource(java.lang.String url,
                                               Target target)
                                               throws java.io.FileNotFoundException
Get a TrAX/JAXP Source object representing the given file.

Parameters:
url - URL to the file, if relative it's searched for relative to the main source file (or a FileNotFoundException is thrown if there is no main source file).
target - The current target.
Throws:
java.io.FileNotFoundException - if the main source file is not specified

getFileAsSAX

void getFileAsSAX(java.lang.String url,
                  org.xml.sax.ContentHandler sax,
                  Target target)
                  throws java.io.FileNotFoundException,
                         java.io.IOException,
                         org.xml.sax.SAXException
Parse the file as XML and deliver SAX2 events.

Parameters:
url - URL to the file, if relative it's searched for relative to the main source file (or a FileNotFoundException is thrown if there is no main source file).
sax - The SAX2 ContentHandler to deliver events to.
target - The current target.
Throws:
java.io.FileNotFoundException - if the main source file is not specified
java.io.IOException
org.xml.sax.SAXException

getFileURL

java.lang.String getFileURL(java.lang.String url)
                            throws java.io.FileNotFoundException
Get an URL representing the given file or directory.

Parameters:
url - URL to the file, if relative it's searched for relative to the main source file (or a FileNotFoundException is thrown if there is no main source file).
Returns:
an absolute or pseudo-absolute URL (the url parameter unchanged unless it's relative)
Throws:
java.io.FileNotFoundException

fileHasBeenUpdated

boolean fileHasBeenUpdated(java.lang.String url,
                           long when)
                           throws java.io.FileNotFoundException,
                                  java.io.IOException,
                                  LagoonException
Check if the specified file has been updated since the specified time.

Parameters:
url - URL to the file, if relative it's searched for relative to the main source file (or a FileNotFoundException is thrown if there is no main source file).
when - the time
Throws:
java.io.FileNotFoundException
java.io.IOException
LagoonException