com.google.clearsilver.jsilver.resourceloader
Class InMemoryResourceLoader
java.lang.Object
com.google.clearsilver.jsilver.resourceloader.BaseResourceLoader
com.google.clearsilver.jsilver.resourceloader.InMemoryResourceLoader
- All Implemented Interfaces:
- ResourceLoader
public class InMemoryResourceLoader
- extends BaseResourceLoader
ResourceLoader that pulls all items from memory. This is particularly useful for small templates
that can be embedded in code (e.g. in unit tests).
Content needs to be stored first using the store(String, String)
method.
- See Also:
ResourceLoader
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
InMemoryResourceLoader
public InMemoryResourceLoader()
open
public Reader open(String name)
throws IOException
- Description copied from interface:
ResourceLoader
- Open a resource. If this resource is not found, null should be returned.
The caller of this method is guaranteed to call
ResourceLoader.close(Reader)
when done with the
reader.
- Parameters:
name
- the name of the resource
- Returns:
- Reader, or null if not found.
- Throws:
IOException
- if resource fails to open
openOrFail
public Reader openOrFail(String name)
throws JSilverTemplateNotFoundException,
IOException
- Description copied from interface:
ResourceLoader
- Open a resource or throw an exception if no such resource is found.
The caller of this method is guaranteed to call
ResourceLoader.close(Reader)
when done with the
reader.
- Parameters:
name
- the name of the resource
- Returns:
- Reader, or null if not found.
- Throws:
JSilverTemplateNotFoundException
- if resource is not found
IOException
- if resource fails to open
store
public void store(String name,
String contents)
remove
public void remove(String name)
getItems
public ConcurrentMap<String,String> getItems()
Copyright © 2010-2012 Google. All Rights Reserved.