EchoPoint
1.0

echopoint.template
Interface DataSource

All Known Implementing Classes:
AbstractDataSource, SwitchedDataSource

public interface DataSource

A DataSource for a Template. This encapsulates what is the notion of a template from the parser's point of view: some named entity, that might change over time and thus has a modification time; an input reader to access the contents. So DataSource is a general source where templates can come from. You can think of Files, URLs, Database-BLOBS ..


Method Summary
 java.lang.String getCanonicalName()
          Returns a canonical name of this DataSource.
 java.lang.String getCharacterEncoding()
          This returns the encoding of the DataSource.
 java.io.Reader getInputReader()
          Gets an Reader of this DataSource.
 long lastModified()
          Returns the time the content of this DataSource was last modified.
 

Method Detail

getCanonicalName

public java.lang.String getCanonicalName()
Returns a canonical name of this DataSource.

The name returned here is used to look up the parsing result of the internal caching, so it should differ for all different Sources :-) May return null if this Source is supposed to be parsed each time. The canonical name would be something like a filename or an URL.


getCharacterEncoding

public java.lang.String getCharacterEncoding()
This returns the encoding of the DataSource. This should be used by the DataSource when returning a localised Reader within getInputReader().


getInputReader

public java.io.Reader getInputReader()
                              throws java.io.IOException
Gets an Reader of this DataSource.

Note that this method may be called twice if the page has to be parsed first. So you probably have to implement a buffer if your underlying source is transient ..

Throws:
java.io.IOException

lastModified

public long lastModified()
Returns the time the content of this DataSource was last modified.

The return value is used to decide whether to reparse a Source or not. Reparsing is done if the value returned here differs from the value returned at the last processing time. This may not return a 'real' time, it needs just to be comparable to itself; so some sort of version counter would be perfect as well.

Returns:
long a modification time

EchoPoint
1.0