NIHVIVO-1562 Show class of template directive/model in dump. Use LinkedHashMap in help data structure to ensure ordering of the entries.
This commit is contained in:
parent
b6ea045503
commit
1b9f4bbdce
11 changed files with 37 additions and 25 deletions
|
@ -54,6 +54,7 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
|||
private static final Pattern PROPERTY_NAME_PATTERN = Pattern.compile("^(get|is)\\w");
|
||||
|
||||
enum Key {
|
||||
CLASS("class"),
|
||||
DATE_TYPE("dateType"),
|
||||
HELP("help"),
|
||||
METHODS("methods"),
|
||||
|
@ -430,6 +431,7 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
|||
private Map<String, Object> getTemplateModelDump(TemplateMethodModel model, String varName) throws TemplateModelException {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put(Key.TYPE.toString(), Type.METHOD);
|
||||
map.put(Key.CLASS.toString(), model.getClass().getName());
|
||||
map.put(Key.HELP.toString(), getHelp(model, varName));
|
||||
return map;
|
||||
}
|
||||
|
@ -437,6 +439,7 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
|||
private Map<String, Object> getTemplateModelDump(TemplateDirectiveModel model, String varName) throws TemplateModelException {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put(Key.TYPE.toString(), Type.DIRECTIVE);
|
||||
map.put(Key.CLASS.toString(), model.getClass().getName());
|
||||
map.put(Key.HELP.toString(), getHelp(model, varName));
|
||||
return map;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package freemarker.ext.dump;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
|
@ -69,12 +69,10 @@ public class DumpAllDirective extends BaseDumpDirective {
|
|||
|
||||
@Override
|
||||
public Map<String, Object> help(String name) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
|
||||
map.put("effect", "Dumps the contents of the template data model.");
|
||||
|
||||
//map.put("comments", "");
|
||||
|
||||
|
||||
List<String> examples = new ArrayList<String>();
|
||||
examples.add("<@" + name + " />");
|
||||
map.put("examples", examples);
|
||||
|
|
|
@ -5,6 +5,7 @@ package freemarker.ext.dump;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -57,12 +58,10 @@ public class DumpDirective extends BaseDumpDirective {
|
|||
|
||||
@Override
|
||||
public Map<String, Object> help(String name) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
|
||||
map.put("effect", "Dumps the contents of a template variable.");
|
||||
|
||||
//map.put("comments", "");
|
||||
|
||||
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("var", "name of variable to dump");
|
||||
map.put("parameters", params);
|
||||
|
|
|
@ -5,6 +5,7 @@ package freemarker.ext.dump;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -17,7 +18,6 @@ import freemarker.template.TemplateHashModel;
|
|||
import freemarker.template.TemplateMethodModel;
|
||||
import freemarker.template.TemplateModel;
|
||||
import freemarker.template.TemplateModelException;
|
||||
import freemarker.template.utility.DeepUnwrap;
|
||||
|
||||
public class HelpDirective extends BaseDumpDirective {
|
||||
|
||||
|
@ -64,12 +64,10 @@ public class HelpDirective extends BaseDumpDirective {
|
|||
|
||||
@Override
|
||||
public Map<String, Object> help(String name) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
|
||||
map.put("effect", "Outputs help for a directive or method.");
|
||||
|
||||
//map.put("comments", "");
|
||||
|
||||
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("for", "name of directive or method");
|
||||
map.put("parameters", params);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue