org.peaseplate.internal.locator
Class InMemoryTemplateLocator

java.lang.Object
  extended by org.peaseplate.internal.locator.InMemoryTemplateLocator
All Implemented Interfaces:
java.io.Serializable, Locator, TemplateLocator

public class InMemoryTemplateLocator
extends java.lang.Object
implements TemplateLocator

See Also:
Serialized Form

Constructor Summary
InMemoryTemplateLocator(char[] source)
           
 
Method Summary
 ResourceKey getKey()
          Returns the key
 java.lang.Long getRawSize()
          Returns the raw size of the resource.
 java.lang.Long getTimestamp()
          Returns the timestamp of the resource.
 java.lang.String highlight(java.lang.String message, int line, int column)
          Create a highlight from the resource with the position at line and column highlighted :) May return null.
 boolean isOutdated()
          Returns true if the resource described by the locator got updated and needs to be reloaded
 char[] load()
          Returns a char array with the raw template data Don't forget to update the timestamp and the rawSize properties when loading the data.
 Template resolve(TemplateEngine engine, java.lang.String name, java.util.Locale locale, java.lang.String encoding)
          Resolves the template with the specified name relative to this template.
 void setRawSize(java.lang.Long rawSize)
          Sets the raw size
 void setTimestamp(java.lang.Long timestamp)
          Sets the timestamp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.peaseplate.locator.Locator
toString
 

Constructor Detail

InMemoryTemplateLocator

public InMemoryTemplateLocator(char[] source)
Method Detail

getKey

public ResourceKey getKey()
Description copied from interface: Locator
Returns the key

Specified by:
getKey in interface Locator
Returns:
the key
See Also:
Locator.getKey()

getRawSize

public java.lang.Long getRawSize()
Description copied from interface: Locator
Returns the raw size of the resource. Used for checking updates to the source of the resource. (usually this is the size of the file). If there is not possibility to support such a size, just return null.

Specified by:
getRawSize in interface Locator
Returns:
the raw size, or null if not specified
See Also:
Locator.getRawSize()

getTimestamp

public java.lang.Long getTimestamp()
Description copied from interface: Locator
Returns the timestamp of the resource. Used for checking updates to the source of the resource. (usually this is the last modified date of the file). If there is no possibility to support such a timestamp, just return null.

Specified by:
getTimestamp in interface Locator
Returns:
the timestamp, or null if not specified
See Also:
Locator.getTimestamp()

isOutdated

public boolean isOutdated()
Description copied from interface: Locator
Returns true if the resource described by the locator got updated and needs to be reloaded

Specified by:
isOutdated in interface Locator
Returns:
true if the resource should get reloaded
See Also:
Locator.isOutdated()

setRawSize

public void setRawSize(java.lang.Long rawSize)
Description copied from interface: Locator
Sets the raw size

Specified by:
setRawSize in interface Locator
Parameters:
rawSize - the raw size, may be null
See Also:
Locator.setRawSize(java.lang.Long)

setTimestamp

public void setTimestamp(java.lang.Long timestamp)
Description copied from interface: Locator
Sets the timestamp

Specified by:
setTimestamp in interface Locator
Parameters:
timestamp - the timestamp, may be null
See Also:
Locator.setTimestamp(java.lang.Long)

highlight

public java.lang.String highlight(java.lang.String message,
                                  int line,
                                  int column)
Description copied from interface: TemplateLocator
Create a highlight from the resource with the position at line and column highlighted :) May return null.

Specified by:
highlight in interface TemplateLocator
Parameters:
message - TODO
line - the line
column - the column
Returns:
the highlight or null
See Also:
TemplateLocator.highlight(String, int, int)

load

public char[] load()
            throws TemplateException
Description copied from interface: TemplateLocator
Returns a char array with the raw template data Don't forget to update the timestamp and the rawSize properties when loading the data.

Specified by:
load in interface TemplateLocator
Returns:
a char array with the raw template data
Throws:
TemplateException - on occasion
See Also:
TemplateLocator.load()

resolve

public Template resolve(TemplateEngine engine,
                        java.lang.String name,
                        java.util.Locale locale,
                        java.lang.String encoding)
                 throws TemplateException
Description copied from interface: TemplateLocator
Resolves the template with the specified name relative to this template. If it can't find the template it tries to resolve the template with the absolute name, usually by asking the engine.

Specified by:
resolve in interface TemplateLocator
Parameters:
engine - the engine
name - the name, relative or absolute
locale - the locale
encoding - the locale for loading
Returns:
the template or null if not found
Throws:
TemplateException - on occasion
See Also:
TemplateLocator.resolve(org.peaseplate.TemplateEngine, java.lang.String, java.util.Locale, java.lang.String)


Copyright © 2008. All Rights Reserved.