View Javadoc

1   /*
2       Jameleon - An automation testing tool..
3       Copyright (C) 2006 Christian W. Hargraves (engrean@hotmail.com)
4       
5       This library is free software; you can redistribute it and/or
6       modify it under the terms of the GNU Lesser General Public
7       License as published by the Free Software Foundation; either
8       version 2.1 of the License, or (at your option) any later version.
9   
10      This library is distributed in the hope that it will be useful,
11      but WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13      Lesser General Public License for more details.
14  
15      You should have received a copy of the GNU Lesser General Public
16      License along with this library; if not, write to the Free Software
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19  package net.sf.jameleon.util;
20  
21  import java.io.File;
22  import java.util.Collections;
23  import java.util.HashMap;
24  import java.util.Iterator;
25  import java.util.Map;
26  import java.util.TreeMap;
27  
28  import net.sf.jameleon.bean.FunctionalPoint;
29  import net.sf.jameleon.util.JameleonUtility;
30  
31  public class GenSyntaxReference {
32  
33      protected SupportedTags supportedTags;
34      protected Map tags;
35  
36      public GenSyntaxReference(){
37          supportedTags = new SupportedTags();
38      }
39  
40      public Map getTagsForPlugin(String plugin){
41          Map supportedTagsMap = Collections.synchronizedMap(new TreeMap());
42          tags = Collections.synchronizedMap(new TreeMap());
43          supportedTags.setTagsFor(supportedTagsMap, plugin);
44          Iterator it = supportedTagsMap.keySet().iterator();
45          String className, key;
46          FunctionalPoint fp;
47          while (it.hasNext()) {
48              key = (String)it.next();
49              className = (String)supportedTagsMap.get(key);
50              fp = JameleonUtility.loadFunctionalPoint(className, this);
51              tags.put(fp.getDefaultTagName(), fp);
52          }
53          return tags;
54      }
55  
56      public void genReferenceForPlugin(String plugin, String templateName, File toFile, Map templateParams){
57          getTagsForPlugin(plugin);
58          Map params = new HashMap();
59          params.put("tags", tags);
60          params.putAll(templateParams);
61          TemplateProcessor tcdf = new TemplateProcessor(templateName);
62          tcdf.transform(toFile,params);
63      }
64  }