org.jproggy.snippetory
Class Repo

java.lang.Object
  extended by org.jproggy.snippetory.Repo

public class Repo
extends Object

Whenever you work with Snippetory things start here. The Repo(sitory) provides access to different sources of template code. May it be the simple String within your code, a file or a stream got from an url. Repo will help you create the TemplateContext, and after configuration, the TemplateContext will provide the template.

For Strings there are even short cuts to directly parse the template.

However this is rather for simple usage like tests or examples. Whenever things get complicated consider use of TemplateContext

See Also:
TemplateContext, Template

Nested Class Summary
static class Repo.TemplateContext
          Repo uses a special TemplateContext that replaces the functionality of configuring a UrlResolver by the ability to keep the data provided during initialization.
 
Method Summary
static Template parse(CharSequence data)
          Short cut method for parsing a string into a template.
static Template parse(CharSequence data, Locale l)
          Short cut method for parsing a string into a template.
static Repo.TemplateContext read(CharSequence data)
          The really short short cut for the simple jobs.
static Repo.TemplateContext readFile(File fileName)
           
static Repo.TemplateContext readFile(String fileName)
           
static Repo.TemplateContext readReader(Reader in)
          reads the complete data of the reader.
static Repo.TemplateContext readResource(String name)
          The data for the TemplateContext is searched on class path
static Repo.TemplateContext readResource(String name, ClassLoader test)
           
static Repo.TemplateContext readStream(InputStream in)
          Reads the complete content of the stream considering it to utf-8 encoded.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parse

public static Template parse(CharSequence data)
Short cut method for parsing a string into a template. With default syntax, null encoding and no locale support.
This is sometimes useful for very short and simple templates replacing a complex string concatenation.


parse

public static Template parse(CharSequence data,
                             Locale l)
Short cut method for parsing a string into a template. With default syntax, null encoding, but supporting a locale for formatting.


read

public static Repo.TemplateContext read(CharSequence data)
The really short short cut for the simple jobs. This helps to scale from a very low level, where any character hurts. At least for playing around it's very handy.


readResource

public static Repo.TemplateContext readResource(String name)
The data for the TemplateContext is searched on class path


readResource

public static Repo.TemplateContext readResource(String name,
                                                ClassLoader test)

readFile

public static Repo.TemplateContext readFile(String fileName)

readFile

public static Repo.TemplateContext readFile(File fileName)

readStream

public static Repo.TemplateContext readStream(InputStream in)
Reads the complete content of the stream considering it to utf-8 encoded. Once read the stream is closed.

Parameters:
in - a stream providing data representing a Snippetory template.
Returns:
a TemplateContext containing the data of the stream.

readReader

public static Repo.TemplateContext readReader(Reader in)
reads the complete data of the reader. Once read the reader is closed.

Parameters:
in - a stream providing data representing a Snippetory template.
Returns:
a TemplateContext containing the data of the stream.