Bug 5518

Summary: template: would like to have API to use templates easily
Product: [Eclipse Project] JDT Reporter: Adam Kiezun <akiezun>
Component: UIAssignee: Claude Knaus <Claude_Knaus>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3    
Version: 2.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Adam Kiezun CLA 2001-11-05 04:37:49 EST
TemplateSet - i would like to use it.
would it be possible to provide interface like (or sth similar)?
(stream management should be done within TemplateSet)

TemplateSet ts= new TemplateSet();
ts.read(file); //file is instanceof IFile
Template[] temps= ts.getTemplates();

does not have to be exactly this - something similar will do.
what i want to be able to do is:
- read templates from a file
- parse template(s) from a given String object
- substitute keys (the ${xxx} things) for some real values (and support to 
substitute them all properly)
- write templates to a file

ask me if you need more info
Comment 1 Erich Gamma CLA 2001-11-05 08:31:15 EST
need more info on this. What are you trying to achieve
Comment 2 Claude Knaus CLA 2001-11-05 12:16:59 EST
Adam is trying to use templates for generating classes like <MyPackage>Messages 
for NLS.
Comment 3 Claude Knaus CLA 2001-11-06 06:28:48 EST
fixed > 208

For reading templates, you can do:

TemplateSet set= new TemplateSet();
set.addFromFile(new File("templates.xml"));
Template[] templates= set.getTemplates();

For interpolating templates, you have to use the TemplateInterpolator parser
and implement a TemplateEvaluator which is fed by the parser.