Bug 5518 - template: would like to have API to use templates easily
Summary: template: would like to have API to use templates easily
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Claude Knaus CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-11-05 04:37 EST by Adam Kiezun CLA
Modified: 2001-11-06 06:28 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.