org.apache.velocity.context.Context类的使用及代码示例

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

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

Context介绍

[英]Interface describing the application data context. This set of routines is used by the application to set and remove 'named' data object to pass them to the template engine to use when rendering a template. This is the same set of methods supported by the original Context class
[中]描述应用程序数据上下文的接口。应用程序使用这组例程来设置和删除“命名”数据对象,以便将它们传递给模板引擎,以便在呈现模板时使用。这是原始上下文类支持的同一组方法

代码示例

代码示例来源: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: webx/citrus

/**
   * 如果当前正在解析<code>StringLiteral</code>,则返回<code>true</code>。
   * <p>
   * 此特性需要打开velocity configuration:
   * <code>runtime.interpolate.string.literals.hack == true</code>。
   * </p>
   */
  public static boolean isInInterpolation(Context context) {
    return context.get(INTERPOLATE_KEY) instanceof Boolean;
  }
}

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

@Override
public Object[] internalGetKeys() {
  return context.getKeys();
}

代码示例来源:origin: org.sonatype.maven.archetype/archetype-common

private void restoreParentArtifactId(Context context, String parentArtifactId) {
  if (StringUtils.isEmpty(parentArtifactId)) {
    context.remove(Constants.PARENT_ARTIFACT_ID);
  }
  else {
    context.put(Constants.PARENT_ARTIFACT_ID, parentArtifactId);
  }
}

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

@Override
public Object internalRemove(Object key) {
  return context.remove(key);
}

代码示例来源:origin: apache/maven-archetype

private void restoreParentArtifactId( Context context, String parentArtifactId )
{
  if ( StringUtils.isEmpty( parentArtifactId ) )
  {
    context.remove( Constants.PARENT_ARTIFACT_ID );
  }
  else
  {
    context.put( Constants.PARENT_ARTIFACT_ID, parentArtifactId );
  }
}

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

@Override
public Object internalRemove(Object key) {
  return context.remove(key);
}

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

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

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

/**
   * 如果当前正在解析<code>StringLiteral</code>,则返回<code>true</code>。
   * <p>
   * 此特性需要打开velocity configuration:
   * <code>runtime.interpolate.string.literals.hack == true</code>。
   * </p>
   */
  public static boolean isInInterpolation(Context context) {
    return context.get(INTERPOLATE_KEY) instanceof Boolean;
  }
}

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

@Override
public Object[] internalGetKeys() {
  return context.getKeys();
}

代码示例来源:origin: stackoverflow.com

@ScheduledMethod(start = 10, pick = 1, interval = 1)
public void die() {  
  Context context = ContextUtils.getContext(this);
  context.remove(this);
  ((DefaultGeography) geography).remove(this);

}

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

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

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

@Override
public Object internalGet(String key) {
  return context.get(key);
}

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

/**
 * @see org.apache.velocity.context.Context#getKeys()
 */
public String[] getKeys()
{
  return context.getKeys();
}

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

/**
 * @see org.apache.velocity.context.Context#remove(java.lang.Object)
 */
public Object remove(Object key)
{
  return localContext.remove( key );
}

代码示例来源: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 internalGet(String key) {
  return context.get(key);
}

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

/**
 * @see org.apache.velocity.context.Context#getKeys()
 */
public Object[] getKeys()
{
  return context.getKeys();
}

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

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

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

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

相关文章

微信公众号

最新文章

更多