本文整理匯總了Java中freemarker.template.SimpleHash.put方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleHash.put方法的具體用法?Java SimpleHash.put怎麽用?Java SimpleHash.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類freemarker.template.SimpleHash
的用法示例。
在下文中一共展示了SimpleHash.put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: merge
import freemarker.template.SimpleHash; //導入方法依賴的package包/類
private void merge() {
try (PrintWriter writer = new PrintWriter(fileCreator.getReportFile("html", getReportStartingDate()),
StandardCharsets.UTF_8.name())) {
SimpleHash root = new SimpleHash();
root.put("collector", testEventCollector);
root.put("date", new SimpleDateFormat("yyyy-MM-dd HH.mm.ss").format(new Date()));
root.put("total", getTestCount());
root.put("passed", getPassedTestCount());
root.put("failed", getFailedCount());
root.put("passedPercent", getPassedTestPercent());
root.put("failedPercent", getFailedPercent());
temp.process(root, writer);
writer.flush();
} catch (TemplateException | IOException e) {
LOG.error("Exception when merging model with template", e);
}
}
示例2: getSubSubField
import freemarker.template.SimpleHash; //導入方法依賴的package包/類
public List getSubSubField(Subfield subfield,SimpleHash subField){
List ssf=new ArrayList();;
for (int j=0; j<subfield.getSubsubfieldCount(); j++){
Subsubfield subsubfield=subfield.getSubsubfield(j);
if(subsubfield!=null){
SimpleHash subSubField=new SimpleHash();
subSubField.put("name",subsubfield.getName()+"");
String cont=subsubfield.getContent();
cont=cont.replaceAll("<","<");
cont=cont.replaceAll(">",">");
subSubField.put("content",cont);
if(!subsubfield.getContent().equals("")&& !subsubfield.getContent().equals(" ")){
ssf.add(subSubField);
}
}
}
return ssf;
}
示例3: render
import freemarker.template.SimpleHash; //導入方法依賴的package包/類
@Override
public void render(JAGeneratorContext context) throws Exception {
util = new JavaClassGeneratorUtil(getId().getClassName());
ByteArrayOutputStream bodyStream = renderBody(context);
// Now render header in case there are injections
ByteArrayOutputStream headerStream = renderHeader(context);
// Now add the header
SimpleHash freemarkerContext = context.createSimpleHash();
freemarkerContext.put("model", this);
freemarkerContext.put("util", util);
freemarkerContext.put("context", context);
Template template = context.getTemplate("JavaHeader.ftl");
File file = getPath(context).toFile();
// create file structure
file.getParentFile().mkdirs();
// before writing to it
FileOutputStream outputStream = new FileOutputStream(file);
template.process(freemarkerContext, new OutputStreamWriter(outputStream));
// And append the header & body
if (headerStream != null) {
headerStream.writeTo(outputStream);
}
bodyStream.writeTo(outputStream);
}
示例4: renderHeader
import freemarker.template.SimpleHash; //導入方法依賴的package包/類
private ByteArrayOutputStream renderHeader(JAGeneratorContext context) throws IOException, TemplateException {
String headerTemplate = getFreemarkerHeaderTemplateName();
if (headerTemplate != null) {
SimpleHash freemarkerContext = context.createSimpleHash();
freemarkerContext.put("model", getFreemarkerModel());
freemarkerContext.put("util", util);
freemarkerContext.put("context", context);
// First process body
Template template = context.getTemplate(headerTemplate);
ByteArrayOutputStream headerStream = new ByteArrayOutputStream();
template.process(freemarkerContext, new OutputStreamWriter(headerStream));
return headerStream;
} else {
return null;
}
}
示例5: render
import freemarker.template.SimpleHash; //導入方法依賴的package包/類
/**
* 渲染
*
*/
public void render(RenderClass target, String template, String outpath) {
try {
StringWriter writer = new StringWriter();
Template tl = templateconfig.getTemplate(template,
templateconfig.getLocale());
SimpleHash root= new SimpleHash();
root.put("entity", target);
tl.process(root, writer);
// Assistant.createNewFile(outpath);
FileOutputStream fos = new FileOutputStream(outpath);
PrintWriter pwriter = new PrintWriter(fos);
pwriter.write(writer.toString());
pwriter.close();
fos.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例6: render
import freemarker.template.SimpleHash; //導入方法依賴的package包/類
/**
* 渲染
*
*/
public void render(RenderClass target,String template,String outpath)
{
try
{
StringWriter writer = new StringWriter();
Template tl = templateconfig.getTemplate(
template,
templateconfig.getLocale());
SimpleHash root = new SimpleHash();
root.put("entity", target);
tl.process(root, writer);
Assistant.createNewFile(outpath);
FileOutputStream fos = new FileOutputStream(outpath);
PrintWriter pwriter = new PrintWriter(fos);
pwriter.write(writer.toString());
pwriter.close();
fos.close();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
示例7: generate
import freemarker.template.SimpleHash; //導入方法依賴的package包/類
@Override
public Set<FileInfo> generate(CGModel cgModel, CGConfig config) throws ModuleException {
Set<FileInfo> targetFileSet = new HashSet<>();
SimpleHash fmModel = this.getFreemarkerModel();
fmModel.put("config", config);
Map<String, String> enumConstants = new HashMap<>();
for (EnumInfo enums : cgModel.getEnums()) {
enumConstants.put(enums.getName(), joinEnumConstants(enums.getEnumConstants()));
}
fmModel.put("enumConstants", enumConstants);
for (ClassInfo classInfo : cgModel.getClasses()) {
fmModel.put("clazz", classInfo);
}
fmModel.put("classes", cgModel.getClasses());
String relativePath = ClassNameUtil.packageNameToPath("com.vsc_technologies");
FileInfo classFile = this.generateFile(classTemplate, fmModel, "schemas", "coffee", relativePath, SOURCE_FOLDER);
targetFileSet.add(classFile);
return targetFileSet;
}
示例8: generate
import freemarker.template.SimpleHash; //導入方法依賴的package包/類
@Override
public Set<FileInfo> generate(CGModel cgModel, CGConfig config) throws ModuleException {
Set<FileInfo> targetFileSet = new HashSet<>();
SimpleHash fmModel = this.getFreemarkerModel();
fmModel.put("config", config);
Map<String, String> enumConstants = new HashMap<>();
for (EnumInfo enums : cgModel.getEnums()) {
enumConstants.put(enums.getName(), joinEnumConstants(enums.getEnumConstants()));
}
fmModel.put("enumConstants", enumConstants);
for (ClassInfo classInfo : cgModel.getClasses()) {
fmModel.put("clazz", classInfo);
}
fmModel.put("classes", cgModel.getClasses());
String relativePath = ClassNameUtil.packageNameToPath("com.vsc_technologies");
FileInfo classFile = this.generateFile(classTemplate, fmModel, "schemas", "js", relativePath, SOURCE_FOLDER);
targetFileSet.add(classFile);
return targetFileSet;
}
示例9: getModel
import freemarker.template.SimpleHash; //導入方法依賴的package包/類
private static TemplateModel getModel (String screen_name, long interval) {
List<Follower> followers = ui.getRecentFollowers(screen_name, interval);
List<Unfollower> unfollowers = ui.getRecentUnfollowers(screen_name, interval);
int unfollowers_deleted = 0;
for (Iterator<Unfollower> i = unfollowers.iterator(); i.hasNext();) {
Unfollower u = i.next();
if (u.getFollowerScreenName().startsWith("*")) {
i.remove();
unfollowers_deleted++;
}
}
SimpleHash root = new SimpleHash();
root.put("screen_name", screen_name);
root.put("interval", interval);
root.put("followers", followers);
root.put("unfollowers", unfollowers);
root.put("unfollowers_deleted", unfollowers_deleted);
return root;
}
示例10: toMapModel
import freemarker.template.SimpleHash; //導入方法依賴的package包/類
public TemplateHashModelEx toMapModel(Environment env) {
SimpleHash map = new SimpleHash(env.getObjectWrapper());
map.put("ctxVars", ctxVars);
map.put("globalCtxVars", globalCtxVars);
map.put("reqAttribs", reqAttribs);
return map;
}
示例11: addToSimpleMap
import freemarker.template.SimpleHash; //導入方法依賴的package包/類
/**
* Adds to simple hash from source map.
* <p>
* <em>WARN</em>: This is not BeanModel-aware (complex map).
*/
public static void addToSimpleMap(SimpleHash dest, TemplateHashModelEx source) throws TemplateModelException {
TemplateCollectionModel keysModel = source.keys();
TemplateModelIterator modelIt = keysModel.iterator();
while(modelIt.hasNext()) {
String key = getAsStringNonEscaping((TemplateScalarModel) modelIt.next());
dest.put(key, source.get(key));
}
}
示例12: getSubField
import freemarker.template.SimpleHash; //導入方法依賴的package包/類
public List getSubField(Field f,SimpleHash field){
List sf=new ArrayList();
for (int j=0; j<f.getSubfieldCount(); j++){
Subfield subfield=f.getSubfield(j);
if(subfield!=null){
SimpleHash secField=new SimpleHash();
List ssf=new ArrayList();
SimpleHash subField=new SimpleHash();
subField.put("name",subfield.getName()+"");
String cont=subfield.getContent();
cont=cont.replaceAll("<","<");
cont=cont.replaceAll(">",">");
subField.put("content",cont);
if(subfield.getSubsubfieldCount()>=1){
ssf=getSubSubField(subfield,subField);
subField.put("ssf",ssf);
}
if(subfield.getSecField()!=null){
secField=getSecField(subfield,subField);
subField.put("secField",secField);
}
if((!subfield.getContent().equals("")&& !subfield.getContent().equals(" ")) ||subfield.getSubsubfieldCount()>=1 || subfield.getSecField()!=null ){
sf.add(subField);
}
}
}
return sf;
}
示例13: getSecField
import freemarker.template.SimpleHash; //導入方法依賴的package包/類
public SimpleHash getSecField(Subfield subfield,SimpleHash subField){
Field sec=subfield.getSecField();
SimpleHash secField=new SimpleHash();
List sf=new ArrayList();
for(int i=0;i<sec.getSubfieldCount();i++){
Subfield subfield1=sec.getSubfield(i);
if(subfield!=null){
SimpleHash subFieldSec=new SimpleHash();
subFieldSec.put("name",subfield1.getName()+"");
String cont=subfield1.getContent();
cont=cont.replaceAll("<","<");
cont=cont.replaceAll(">",">");
subFieldSec.put("content",cont);
if(!subfield1.getContent().equals(""))
sf.add(subFieldSec);
}
}
if(sf.size()>=1){
//secField.put("one",sec.getName());
subField.put("content",sec.getName());
secField.put("ind1",sec.getInd1()+"");
secField.put("ind2",sec.getInd2()+"");
secField.put("sf",sf);
}
return secField;
}
示例14: renderBody
import freemarker.template.SimpleHash; //導入方法依賴的package包/類
@Override
protected ByteArrayOutputStream renderBody(JAGeneratorContext context) throws IOException, TemplateException {
SimpleHash freemarkerContext = context.createSimpleHash();
freemarkerContext.put("model", getFreemarkerModel());
freemarkerContext.put("util", util);
freemarkerContext.put("context", context);
// First process body start
Template template;
ByteArrayOutputStream bodyStream = new ByteArrayOutputStream();
OutputStreamWriter out = new OutputStreamWriter(bodyStream);
// Then each body parts
for (RenderPart renderPart : renderParts) {
try {
template = context.getTemplate(renderPart.getFreemarkerTemplateName());
SimpleHash partContext = context.createSimpleHash();
partContext.put("baseModel", getFreemarkerModel());
partContext.put("model", renderPart.getModel());
partContext.put("util", util);
partContext.put("context", context);
template.process(partContext, out);
} catch (Exception e) {
throw new IllegalStateException("Problem while rendering "+getId()+"["+renderPart.getSource()+"]", e);
}
}
// Then body end
template = context.getTemplate("entities/EntityBaseService_bodyEnd.java.ftl");
template.process(freemarkerContext, out);
return bodyStream;
}
示例15: renderBody
import freemarker.template.SimpleHash; //導入方法依賴的package包/類
protected ByteArrayOutputStream renderBody(JAGeneratorContext context) throws IOException, TemplateException {
SimpleHash freemarkerContext = context.createSimpleHash();
freemarkerContext.put("model", getFreemarkerModel());
freemarkerContext.put("util", util);
freemarkerContext.put("context", context);
// First process body
Template template = context.getTemplate(getFreemarkerBodyTemplateName());
ByteArrayOutputStream bodyStream = new ByteArrayOutputStream();
template.process(freemarkerContext, new OutputStreamWriter(bodyStream));
return bodyStream;
}