org.apache.velocity.context.Context.put()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中org.apache.velocity.context.Context.put()方法的一些代码示例,展示了Context.put()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.put()方法的具体详情如下:
包路径:org.apache.velocity.context.Context
类名称:Context
方法名:put

Context.put介绍

[英]Adds a name/value pair to the context.
[中]将名称/值对添加到上下文中。

代码示例

代码示例来源:origin: jeremylong/DependencyCheck

/**
 * Constructs a new ReportGenerator.
 *
 * @param applicationName the application name being analyzed
 * @param groupID the group id of the project being analyzed
 * @param artifactID the application id of the project being analyzed
 * @param version the application version of the project being analyzed
 * @param dependencies the list of dependencies
 * @param analyzers the list of analyzers used
 * @param properties the database properties (containing timestamps of the
 * NVD CVE data)
 * @param settings a reference to the database settings
 */
//CSOFF: ParameterNumber
public ReportGenerator(String applicationName, String groupID, String artifactID, String version,
    List<Dependency> dependencies, List<Analyzer> analyzers, DatabaseProperties properties, Settings settings) {
  this(applicationName, dependencies, analyzers, properties, settings);
  if (version != null) {
    context.put("applicationVersion", version);
  }
  if (artifactID != null) {
    context.put("artifactID", artifactID);
  }
  if (groupID != null) {
    context.put("groupID", groupID);
  }
}
//CSON: ParameterNumber

代码示例来源:origin: gocd/gocd

private void setAnonymousUser(Context velocityContext, AuthenticationToken<?> authentication) {
  velocityContext.put(IS_ANONYMOUS_USER, "anonymous".equalsIgnoreCase(authentication.getUser().getDisplayName()));
}

代码示例来源:origin: gocd/gocd

private void setPrincipal(Context velocityContext, AuthenticationToken<?> authentication) {
  velocityContext.put(PRINCIPAL, authentication.getUser().getDisplayName());
}

代码示例来源:origin: gocd/gocd

velocityContext.put(ADMINISTRATOR, securityService.isUserAdmin(username));
velocityContext.put(GROUP_ADMINISTRATOR, securityService.isUserGroupAdmin(username));
velocityContext.put(TEMPLATE_ADMINISTRATOR, securityService.isAuthorizedToViewAndEditTemplates(username));
velocityContext.put(VIEW_ADMINISTRATOR_RIGHTS, securityService.canViewAdminPage(username));
velocityContext.put(TEMPLATE_VIEW_USER, securityService.isAuthorizedToViewTemplates(username));
velocityContext.put(USE_COMPRESS_JS, systemEnvironment.useCompressedJs());
velocityContext.put(Toggles.PIPELINE_COMMENT_FEATURE_TOGGLE_KEY, Toggles.isToggleOn(Toggles.PIPELINE_COMMENT_FEATURE_TOGGLE_KEY));
velocityContext.put(CONCATENATED_JAVASCRIPT_FILE_PATH, railsAssetsService.getAssetPath("application.js"));
velocityContext.put(CONCATENATED_APPLICATION_CSS_FILE_PATH, railsAssetsService.getAssetPath("application.css"));
velocityContext.put(CURRENT_GOCD_VERSION, CurrentGoCDVersion.getInstance());
velocityContext.put(CONCATENATED_VM_APPLICATION_CSS_FILE_PATH, railsAssetsService.getAssetPath("vm/application.css"));
velocityContext.put(CONCATENATED_CSS_APPLICATION_CSS_FILE_PATH, railsAssetsService.getAssetPath("css/application.css"));
velocityContext.put(CONCATENATED_NEW_THEME_CSS_FILE_PATH, railsAssetsService.getAssetPath("new-theme.css"));
velocityContext.put(CONCATENATED_STAGE_BAR_CANCELLED_ICON_FILE_PATH, railsAssetsService.getAssetPath("g9/stage_bar_cancelled_icon.png"));
velocityContext.put(CONCATENATED_SPINNER_ICON_FILE_PATH, railsAssetsService.getAssetPath("spinner.gif"));
velocityContext.put(CONCATENATED_CRUISE_ICON_FILE_PATH, railsAssetsService.getAssetPath("cruise.ico"));
velocityContext.put(PATH_RESOLVER, railsAssetsService);
velocityContext.put(GO_UPDATE, versionInfoService.getGoUpdate());
velocityContext.put(GO_UPDATE_CHECK_ENABLED, versionInfoService.isGOUpdateCheckEnabled());
velocityContext.put(SHOW_ANALYTICS_DASHBOARD, (securityService.isUserAdmin(username) && supportsAnalyticsDashboard()));
velocityContext.put(WEBPACK_ASSETS_SERVICE, webpackAssetsService());
velocityContext.put(MAINTENANCE_MODE_SERVICE, getMaintenanceModeService());
if (!SessionUtils.hasAuthenticationToken(request)) {
  return;

代码示例来源:origin: webx/citrus

@Override
public Object internalPut(String key, Object value) {
  return context.put(key, value);
}

代码示例来源:origin: webx/citrus

@Override
public Object internalPut(String key, Object value) {
  return context.put(key, value);
}

代码示例来源:origin: schemacrawler/SchemaCrawler

context.put("catalog", catalog);
context.put("identifiers", identifiers);

代码示例来源:origin: org.apache.velocity/velocity-engine-core

/**
 * @see org.apache.velocity.context.Context#put(java.lang.String, java.lang.Object)
 */
public Object put(String key, Object value)
{
  return context.put( key , value );
}

代码示例来源:origin: org.apache.velocity/com.springsource.org.apache.velocity

/**
 * @see org.apache.velocity.context.Context#put(java.lang.String, java.lang.Object)
 */
public Object put(String key, Object value)
{
  return context.put( key , value );
}

代码示例来源:origin: approvals/ApprovalTests.Java

/***********************************************************************/
public void setupContext(Context context)
{
 context.put("stats", stats);
}
/***********************************************************************/

代码示例来源:origin: approvals/ApprovalTests.Java

/***********************************************************************/
public void setupContext(Context context)
{
 context.put("error", this);
}
/***********************************************************************/

代码示例来源:origin: approvals/ApprovalTests.Java

public void setupContext(Context context)
 {
  context.put("config", config);
  context.put("shipment", shipment);
 }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.velocity

/**
 * Add properties that will aways be in the context by default
 *
 * @param context control context to fill with default values.
 */
protected void fillContextDefaults (Context context)
{
  context.put ("generator", instance);
  context.put ("outputDirectory", getOutputPath());
}

代码示例来源:origin: velocity/velocity-dep

/**
 * Add properties that will aways be in the context by default
 *
 * @param Context control context to fill with default values.
 */
protected void fillContextDefaults (Context context)
{
  context.put ("generator", instance);
  context.put ("outputDirectory", getOutputPath());
}

代码示例来源:origin: org.apache.velocity/com.springsource.org.apache.velocity

/**
 * Add properties that will aways be in the context by default
 *
 * @param context control context to fill with default values.
 */
protected void fillContextDefaults (Context context)
{
  context.put ("generator", instance);
  context.put ("outputDirectory", getOutputPath());
}

代码示例来源:origin: org.kuali.maven.impex/torque-generator

/**
 * Change type of "now" to java.util.Date
 * 
 * @see org.apache.velocity.texen.ant.TexenTask#populateInitialContext(org.apache.velocity.context.Context)
 */
protected void populateInitialContext(Context context) throws Exception {
  super.populateInitialContext(context);
  context.put("now", new Date());
}

代码示例来源:origin: velocity/velocity-dep

/**
 * Makes an alternator object that alternates between four values.
 *
 * @see #makeAlternator(String name, String alt1, String alt2)
 */
public String makeAlternator(String name, String alt1, String alt2,
               String alt3, String alt4)
{
  String[] alternates = { alt1, alt2, alt3, alt4 };
  context.put(name, new VelocityAlternator(alternates));
  return "";
}

代码示例来源:origin: org.apache.portals.applications/apa-gems

protected void setParameterContextVars( RenderRequest request, RenderResponse response, Context context, SWFContext swfContext )
{
  context.put( OBJECT_PARAMS, JSONUtils.makeJSONObject( getObjectParameters( request, response, swfContext ), true ).toString() );
  
  Map objNodeIdMap = new HashMap();
  objNodeIdMap.put( "id", response.getNamespace() + "_objnode" );
  Map[] attrMaps = new Map[] { getObjectAttributes( request, response, swfContext ), objNodeIdMap };
  context.put( OBJECT_ATTRIBUTES, JSONUtils.makeJSONObject( attrMaps, true ).toString() );
  
  context.put( FLASHVARS, JSONUtils.makeJSONObject( getFlashVars( request, response, swfContext ), true ).toString() );
}

代码示例来源:origin: net.bpelunit/framework

protected String expandTemplateToString(VelocityContextProvider context, String template) throws DataSourceException {
  Context velocityCtx = CLONER.deepClone(context.createVelocityContext());
  velocityCtx.put("xpath", new XPathTool(getNamespaceContext()));
  velocityCtx.put("printer", new XMLPrinterTool());
  // Expand the template as a regular string
  StringWriter writer = new StringWriter();
  Velocity.evaluate(velocityCtx, writer, "expandTemplate", template);
  return writer.toString();
}

代码示例来源:origin: jobop/anylog

@Override
protected Template handleRequest(HttpServletRequest request, HttpServletResponse response, Context ctx) {
  //输出所有vm
  List<VirtualMachineWrapper> wrapper=VirtualMachineManager.getInstance().listVMs();
  ctx.put("wrappers", wrapper);
  
  
  // 调用父类的方法getTemplate()
  return getTemplate("menu.vm");
}

相关文章

微信公众号

最新文章

更多