Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

freemarker.template.utility.* (18)

freemarker.template: Javadoc index of package freemarker.template.


Package Samples:

freemarker.template.utility: This package contains the core API's that most users will use.  

Classes:

Template: A core FreeMarker API that represents a compiled template. Typically, you will use a Configuration object to instantiate a template. Configuration cfg = new Configuration(); ... Template myTemplate = cfg.getTemplate("myTemplate.html"); However, you can also construct a template directly by passing in to the appropriate constructor a java.io.Reader instance that is set to read the raw template text. The compiled template is stored in an an efficient data structure for later use. To render the template, i.e. to merge it with a data model, and thus produce "cooked" output, call the process method. ...
TemplateTransformModel: Objects that implement this interface can be used in a <transform> block to perform arbitrary transformations on a part of the template processing output. Note that, as of FreeMarker 2.1, TemplateTransform Model has changed. This is a more powerful implementation. There is a quick-and-dirty way to patch any legacy TemplateTransformModel so that it implements the new API. You simply add the following as your implementation of the getWriter() call: public Writer getWriter(final Writer out, Map args) { final StringBuffer buf = new StringBuffer(); return new Writer() { public void write(char cbuf[], ...
SimpleCollection: A simple implementation of TemplateCollectionModel . It's able to wrap java.util.Iterator -s and java.util.Collection -s. If you wrap an Iterator , the variable can be <list>-ed (<forach>-ed) only once! Consider using SimpleSequence instead of this class if you want to wrap Iterator s. SimpleSequence will read all elements of the Iterator , and store them in a List (this may cause too high resource consumption in some applications), so you can list the variable for unlimited times. Also, if you want to wrap Collection s, and then list the resulting variable for many times, SimpleSequence ...
TemplateHashModelEx: An extended hash interface with a couple of extra hooks. If a class implements this interface, then the built-in operators ?size , ?keys , and ?values can be applied to its instances in the template. As of version 2.2.2, the engine will automatically wrap the collections returned by keys and values to present them as sequences to the template. For performance, you may wish to return objects that implement both TemplateCollectionModel and TemplateSequenceModel . Note that the wrapping to sequence happens on demand; if the template does not try to use the variable returned by ?keys or ?values as ...
StandardCompress: A filter that compresses each sequence of consecutive whitespace to a single line break (if the sequence contains a line break) or a single space. In addition, leading and trailing whitespace is completely removed. Specify the transform parameter single_line = true to always compress to a single space instead of a line break. The default buffer size can be overridden by specifying a buffer_size transform parameter (in bytes). Note: The compress tag is implemented using this filter Usage: From java: SimpleHash root = new SimpleHash(); root.put( "standardCompress", new freemarker.template.utility.StandardCompress() ...
CaptureOutput: A transform that captures the output of a block of FTL code and stores that in a variable. As this transform is initially present in the shared variable set, you can always access it from the templates: <@capture_output var="captured"> ... </@capture_output> And later in the template you can use the captured output: ${captured} This transform requires one of three parameters: var , local , or global . Each of them specifies the name of the variable that stores the captured output, but the first creates a variable in a name-space (as <#assign>), the second creates a macro-local variable ...
SimpleSequence: A convenient implementation of a list. This object implements TemplateSequenceModel , using an underlying java.util.List implementation. A SimpleSequence can act as a cache for a TemplateCollectionModel , e.g. one that gets data from a database. When passed a TemplateCollectionModel as an argument to its constructor, the SimpleSequence immediately copies all the elements and discards the TemplateCollectionModel . This class is thread-safe if you don't call the add method after you have made the object available for multiple threads. Note: As of 2.0, this class is unsynchronized by default. To obtain ...
Configuration: Main entry point into the FreeMarker API, this class encapsulates the various configuration parameters with which FreeMarker is run, as well as serves as a central template loading and caching point. Note that this class uses a default strategy for loading and caching templates. You can plug in a replacement template loading mechanism by using the setTemplateLoader(TemplateLoader) 55 method. This object is not synchronized . Thus, the settings must not be changed after you have started to access the object from multiple threads. If you use multiple threads, set everything directly after you have ...
NormalizeNewlines: Transformer that supports FreeMarker legacy behavior: all newlines appearing within the transformed area will be transformed into the platform's default newline. Unlike the old behavior, however, newlines generated by the data model are also converted. Legacy behavior was to leave newlines in the data model unaltered. Usage: From java: SimpleHash root = new SimpleHash(); root.put( "normalizeNewlines", new freemarker.template.utility.NormalizeNewlines() ); ... From your FreeMarker template: <transform normalizeNewlines> <html> <head> ... <p>This template has all newlines ...
Execute: Gives FreeMarker the the ability to execute external commands. Will fork a process, and inline anything that process sends to stdout in the template. Based on a patch submitted by Peter Molettiere. BE CAREFUL! this tag, depending on use, may allow you to set something up so that users of your web application could run arbitrary code on your server. This can only happen if you allow unchecked GET/POST submissions to be used as the command string in the exec tag. Usage: From java: SimpleHash root = new SimpleHash(); root.put( "exec", new freemarker.template.utility.Execute() ); ... From your FreeMarker ...
TemplateMethodModelEx: A subinterface of TemplateMethodModel that acts on models, rather than on strings. TemplateMethodModel interface will receive string representations of its argument expressions. The interface has no new methods. Instead, by implementing this interface the class declares that it wishes to receive actual TemplateModel instances in its arguments list when invoked instead of their string representations. Implementions of TemplateMethodModelEx should be thread-safe.
TemplateSequenceModel: List values in a template data model whose elements are accessed by the index operator should implement this interface. In addition to accessing elements by index and querying size using the ?size built-in, objects that implement this interface can be iterated in <#foreach ...> and <#list ...> directives. The iteration is implemented by calling the get(int) 55 method repeatedly starting from zero and going to size() 55 - 1 .
SimpleHash: A simple implementation of the TemplateHashModelEx interface, using an underlying java.util.Map or java.util.SortedMap . This class is thread-safe if you don't call the put or remove methods after you have made the object available for multiple threads. Note: As of 2.0, this class is unsynchronized by default. To obtain a synchronized wrapper, call the synchronizedWrapper() 55 method.
AdapterTemplateModel: Supplemental interface that can be implemented by classes that also implement any of the TemplateModel interfaces. A class implementing this interface usually serves as an adapter that provides bridging between a different object model and FreeMarker template models. It provides a capability to retrieve the underlying object. This interface is rarely implemented by applications. It is tipically implemented by adapter classes used for wrapping in various object wrapper implementation.
TransformControl: An interface that can be implemented by writers returned from TemplateTransformModel.getWriter(java.io.Writer, java.util.Map) 55 . The methods on this interfaces are callbacks that will be called by the template engine and that give the writer a chance to better control the evaluation of the transform body. The writer can instruct the engine to skip or to repeat body evaluation, and gets notified about exceptions that are thrown during the body evaluation.
Constants: Frequently used constant freemarker.template.TemplateModel values. These constants should be stored in the freemarker.template.TemplateModel sub-interfaces, but for bacward compatibility they are stored here instead. Starting from FreeMarker 2.4 they should be copyed (not moved!) into the freemarker.template.TemplateModel sub-interfaces, and this class should be marked as deprecated.
HtmlEscape: Performs an HTML escape of a given template fragment. Specifically, < > " and & are all turned into entities. Usage: From java: SimpleHash root = new SimpleHash(); root.put( "htmlEscape", new freemarker.template.utility.HtmlEscape() ); ... From your FreeMarker template: The following is HTML-escaped: <transform htmlEscape> <p>This paragraph has all HTML special characters escaped.</p> </transform> ...
LocalizedString: An abstract base class for scalars that vary by locale. Here is a silly usage example. TemplateScalarModel localizedYes = new LocalizedString() { public String getLocalizedString(java.util.Locale locale) { String lang = locale.getLanguage(); if "fr".equals(lang) return "oui"; else if "de".equals(lang) return "sí"; else return "yes"; } };
TemplateCollectionModel: This interface can be implemented by a class to make a variable "foreach-able", i.e. the model can be used as the list in a <foreach...> or a <list...> directive. Use this model when your collection does not support index-based access and possibly, the size cannot be known in advance. If you need index-based access, use a TemplateSequenceModel instead.
ObjectConstructor: An object that you can make available in a template to instantiate arbitrary beans-wrapped objects in a template. Beware of this class's security implications. It allows the instantiation of arbitrary objects and invoking methods on them. Usage is something like: myDataModel.put("objectConstructor", new ObjectConstructor()); And then from your FTL code: <#assign aList = objectConstructor("java.util.ArrayList", 100)>
TemplateModelAdapter: Implemented by classes that serve as adapters for template model objects in some other object model. Actually a functional inverse of AdapterTemplateModel . You will rarely implement this interface directly. It is usually implemented by unwrapping adapter classes of various object wrapper implementations.
TemplateNodeModel: Describes objects that are nodes in a tree. If you have a tree of objects, they can be recursively visited using the <#visit...> and <#recurse...> FTL directives. This API is largely based on the W3C Document Object Model (DOM) API. However, it is meant to be generally useful for describing any tree of objects that you wish to navigate using a recursive visitor design pattern.
TemplateDateModel: Date values in a template data model must implement this interface. Contrary to Java, FreeMarker actually distinguishes values that represent only a time, only a date, or a combined date and time. All three are represented using this single interface, however there's a method that
ResourceBundleLocalizedString: A concrete implementation of LocalizedString that gets a localized string from a java.util.ResourceBundle
TemplateScalarModel: String values in a template data model must implement this interface. (Actually, the name of this interface should be TemplateStringModel . The bad name was inherited from the ancient times, when there was only 1 kind of scalars in FreeMarker.)

Home | Contact Us | Privacy Policy | Terms of Service