Data Models

Simple Models

Simple implementations of hashes, lists, numbers and scalars have been provided as a convenience: SimpleScalar, SimpleNumber, SimpleList, and SimpleHash. All of the methods of these models are synchronized. Unless you're doing something highly unusual, you'll want to use a SimpleHash for the root node.

In many cases, it will be sufficient to copy your data from its original source into a tree of SimpleScalar, SimpleNumber, SimpleList, and SimpleHash objects. If you want to implement lazy evaluation, or if you want to wrap existing data objects for use with templates, you'll want to make adapter or wrapper classes that implement the TemplateModel interfaces. See the sample code for an example.

Fast Models

In addition to the simple models above, there are also unsynchronized implementations provided: FastScalar, FastNumber, FastList, FastHash, and FastBoolean. To avoid excessive object creation, the values of FastBoolean are implemented as singletons.

Use the fast models when you are sure that there won't be any synchronization issues if you have multiple threads that can use the data model at the same time, or if you only use the data model within a single thread. Fast models will typically perform faster than their simple equivalents, due to the lack of synchronization blocks. The FM-Classic engine uses the fast models internally to hold intermediate results when evaluating expressions.