Class FragmentTemplateEngine
java.lang.Object
aQute.bnd.wstemplates.FragmentTemplateEngine
Manages a set of workspace template fragments. A template fragment is a zip
file or a Github repo. A template index file (parameters format) can be used
to provide the meta information. For example, a file on Github can hold the
overview of available templates. This class is optimized to add multiple
indexes and provide a unified overview of templates. It is expected that the
users will select what templates to apply.
Once the set of templates is know, an FragmentTemplateEngine.TemplateUpdater is created.
This takes a folder and analyzes the given templates. Since there can be
multiple templates, there could be conflicts. The caller can remove
FragmentTemplateEngine.Update objects if they conflict. Otherwise, multiple updates will be
concatenated during FragmentTemplateEngine.TemplateUpdater.commit()
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic final recordInfo about a template, comes from the index files.classUsed to edit the updates.static final recordA single update operationstatic enumThe conflict status. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidConvenience method.Get the list of available templatesread(Parameters ps) Read the templates from a ParametersaQute.bnd.result.Result<List<FragmentTemplateEngine.TemplateInfo>> Parse the file from the source.aQute.bnd.result.Result<List<FragmentTemplateEngine.TemplateInfo>> Read a template index from a URL.Resolve all required templates recursively.updater(File folder, List<FragmentTemplateEngine.TemplateInfo> templates) Create a TemplateUpdater
-
Field Details
-
DEFAULT_INDEX
- See Also:
-
-
Constructor Details
-
FragmentTemplateEngine
-
-
Method Details
-
read
Read a template index from a URL. The result is **not** added to this class. Seeread(String)for the file's format- Parameters:
url- to read.- Returns:
- the result
-
read
Parse the file from the source. The format is: * key – see
TemplateID* name – A human readable name * description – An optional human readable description * require – An optional comma separated list ofTemplateIDthat will be included * tags – An optional comma separated list of tags- Parameters:
source- the source (Parameters format)- Returns:
- the result.
-
read
Read the templates from a Parameters- Parameters:
ps- the parameters- Returns:
- the list of template info
-
add
Convenience method. Add aFragmentTemplateEngine.TemplateInfoto a list of available templates, seegetAvailableTemplates()internally maintained. -
getAvailableTemplates
Get the list of available templates -
updater
public FragmentTemplateEngine.TemplateUpdater updater(File folder, List<FragmentTemplateEngine.TemplateInfo> templates) Create a TemplateUpdater -
resolveRequirements
public List<FragmentTemplateEngine.TemplateInfo> resolveRequirements(List<FragmentTemplateEngine.TemplateInfo> templates) Resolve all required templates recursively. This method processes the 'require' field of each template and includes all transitively required templates.- Parameters:
templates- the initial list of templates- Returns:
- a list containing the original templates plus all required templates, with duplicates removed
-