org.apache.velocity.runtime.RuntimeSingleton.getString()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(118)

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

RuntimeSingleton.getString介绍

[英]String property accessor method to hide the configuration implementation
[中]用于隐藏配置实现的字符串属性访问器方法

代码示例

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

/**
 * String property accessor method to hide the configuration implementation
 * @param key  property key
 * @return   value of key or null
 */
public static String getString(String key)
{
  return RuntimeSingleton.getString( key );
}

代码示例来源:origin: com.samskivert/samskivert

/**
 * Chooses the output character encoding to be used as the value for the "charset=" portion of
 * the HTTP Content-Type header (and thus returned by
 * <code>response.getCharacterEncoding()</code>). Called by {@link #setContentType} if an
 * encoding isn't already specified by Content-Type.  By default, chooses the value of
 * RuntimeSingleton's <code>output.encoding</code> property.
 */
protected String chooseCharacterEncoding (HttpServletRequest request)
{
  return RuntimeSingleton.getString(
    RuntimeConstants.OUTPUT_ENCODING, DEFAULT_OUTPUT_ENCODING);
}

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

/**
 * String property accessor method to hide the configuration implementation
 * @param key  property key
 * @return   value of key or null
 */
public static String getString(String key)
{
  return RuntimeSingleton.getString( key );
}

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

/**
 * String property accessor method with default to hide the
 * configuration implementation.
 * 
 * @param String key property key
 * @param String defaultValue  default value to return if key not 
 *               found in resource manager.
 * @return String  value of key or default 
 */
public static String getString( String key, String defaultValue)
{
  return RuntimeSingleton.getString( key, defaultValue );
}

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

/**
 * String property accessor method with default to hide the
 * configuration implementation.
 *
 * @param key A property key.
 * @param defaultValue  default value to return if key not
 *               found in resource manager.
 * @return The property value of of key or default.
 */
public static String getString( String key, String defaultValue)
{
  return RuntimeSingleton.getString( key, defaultValue );
}

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

/**
 * String property accessor method to hide the configuration implementation
 * @param key  property key
 * @return   value of key or null
 */
public static String getString(String key)
{
  return RuntimeSingleton.getString( key );
}

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

/**
 * String property accessor method with default to hide the
 * configuration implementation.
 *
 * @param key A property key.
 * @param defaultValue  default value to return if key not
 *               found in resource manager.
 * @return The property value of of key or default.
 */
public static String getString( String key, String defaultValue)
{
  return RuntimeSingleton.getString( key, defaultValue );
}

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

/**
 * Chooses the output character encoding to be used as the value
 * for the "charset=" portion of the HTTP Content-Type header (and
 * thus returned by <code>response.getCharacterEncoding()</code>).
 * Called by {@link #setContentType(HttpServletRequest,
 * HttpServletResponse)} if an encoding isn't already specified by
 * Content-Type.  By default, chooses the value of
 * RuntimeSingleton's <code>output.encoding</code> property.
 *
 * @param request The servlet request from the client.
 * @return The chosen character encoding.
 */
protected String chooseCharacterEncoding(HttpServletRequest request)
{
  return RuntimeSingleton.getString(RuntimeConstants.OUTPUT_ENCODING,
                   DEFAULT_OUTPUT_ENCODING);
}

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

/**
 * Chooses the output character encoding to be used as the value
 * for the "charset=" portion of the HTTP Content-Type header (and
 * thus returned by <code>response.getCharacterEncoding()</code>).
 * Called by {@link #setContentType(HttpServletRequest,
 * HttpServletResponse)} if an encoding isn't already specified by
 * Content-Type.  By default, chooses the value of
 * RuntimeSingleton's <code>output.encoding</code> property.
 *
 * @param request The servlet request from the client.
 */
protected String chooseCharacterEncoding(HttpServletRequest request)
{
  return RuntimeSingleton.getString(RuntimeConstants.OUTPUT_ENCODING,
                   DEFAULT_OUTPUT_ENCODING);
}

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

/**
 * Chooses the output character encoding to be used as the value
 * for the "charset=" portion of the HTTP Content-Type header (and
 * thus returned by <code>response.getCharacterEncoding()</code>).
 * Called by {@link #setContentType(HttpServletRequest,
 * HttpServletResponse)} if an encoding isn't already specified by
 * Content-Type.  By default, chooses the value of
 * RuntimeSingleton's <code>output.encoding</code> property.
 *
 * @param request The servlet request from the client.
 * @return The chosen character encoding.
 */
protected String chooseCharacterEncoding(HttpServletRequest request)
{
  return RuntimeSingleton.getString(RuntimeConstants.OUTPUT_ENCODING,
                   DEFAULT_OUTPUT_ENCODING);
}

代码示例来源:origin: com.opensymphony/webwork

private String getEncoding() {
    // todo look into converting this to using XWork/WebWork2 encoding rules
    try {
      return Configuration.getString(WebWorkConstants.WEBWORK_I18N_ENCODING);
    } catch (IllegalArgumentException e) {
      return RuntimeSingleton.getString(RuntimeSingleton.OUTPUT_ENCODING, DEFAULT_OUTPUT_ENCODING);
    }
  }
}

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

/**
 *  merges a template and puts the rendered stream into the writer
 *
 *  @param templateName name of template to be used in merge
 *  @param context  filled context to be used in merge
 *  @param  writer  writer to write template into
 *
 *  @return true if successful, false otherwise.  Errors
 *           logged to velocity log.
 *  @deprecated Use
 *  {@link #mergeTemplate( String templateName, String encoding,
 *                Context context, Writer writer )}
 */
public static boolean mergeTemplate( String templateName,
                   Context context, Writer writer )
  throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception
{
  return mergeTemplate( templateName, RuntimeSingleton.getString(INPUT_ENCODING,ENCODING_DEFAULT),
              context, writer );
}

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

/**
 *  Merges a template and puts the rendered stream into the writer.
 *  The default encoding that Velocity uses to read template files is defined in
 *  the property input.encoding and defaults to ISO-8859-1.
 *
 *  @param templateName name of template to be used in merge
 *  @param context  filled context to be used in merge
 *  @param  writer  writer to write template into
 *
 *  @return true if successful, false otherwise.  Errors
 *           logged to velocity log.
 *  @deprecated Use
 *  {@link #mergeTemplate( String templateName, String encoding,
 *                Context context, Writer writer )}
 * @throws ParseErrorException The template could not be parsed.
 * @throws MethodInvocationException A method on a context object could not be invoked.
 * @throws ResourceNotFoundException A referenced resource could not be loaded.
 * @throws Exception Any other exception.
 */
public static boolean mergeTemplate( String templateName,
                   Context context, Writer writer )
  throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception
{
  return mergeTemplate( templateName, RuntimeSingleton.getString(INPUT_ENCODING,ENCODING_DEFAULT),
              context, writer );
}

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

/**
 * Performs initialization of this servlet.  Called by the servlet
 * container on loading.
 *
 * @param config The servlet configuration to apply.
 *
 * @exception ServletException
 */
public void init( ServletConfig config )
  throws ServletException
{
  super.init( config );
  /*
   *  do whatever we have to do to init Velocity
   */
  initVelocity( config );
  /*
   *  Now that Velocity is initialized, cache some config.
   */
  VelocityServlet.defaultContentType =
      RuntimeSingleton.getString(CONTENT_TYPE, DEFAULT_CONTENT_TYPE);
}

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

/**
 * Performs initialization of this servlet.  Called by the servlet
 * container on loading.
 *
 * @param config The servlet configuration to apply.
 *
 * @exception ServletException
 */
public void init( ServletConfig config )
  throws ServletException
{
  super.init( config );
  /*
   *  do whatever we have to do to init Velocity
   */
  initVelocity( config );
  /*
   *  Now that Velocity is initialized, cache some config.
   */
  VelocityServlet.defaultContentType =
      RuntimeSingleton.getString(CONTENT_TYPE, DEFAULT_CONTENT_TYPE);
}

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

/**
 *  Merges a template and puts the rendered stream into the writer.
 *  The default encoding that Velocity uses to read template files is defined in
 *  the property input.encoding and defaults to ISO-8859-1.
 *
 *  @param templateName name of template to be used in merge
 *  @param context  filled context to be used in merge
 *  @param  writer  writer to write template into
 *
 *  @return true if successful, false otherwise.  Errors
 *           logged to velocity log.
 *  @deprecated Use
 *  {@link #mergeTemplate( String templateName, String encoding,
 *                Context context, Writer writer )}
 * @throws ParseErrorException The template could not be parsed.
 * @throws MethodInvocationException A method on a context object could not be invoked.
 * @throws ResourceNotFoundException A referenced resource could not be loaded.
 */
public static boolean mergeTemplate( String templateName,
                   Context context, Writer writer )
  throws ResourceNotFoundException, ParseErrorException, MethodInvocationException
{
  return mergeTemplate( templateName, RuntimeSingleton.getString(INPUT_ENCODING,ENCODING_DEFAULT),
              context, writer );
}

代码示例来源:origin: net.ontopia/ontopia-webed

public static void processWithVelocity(PageContext pageContext, String template_file, 
                    Writer writer, VelocityContext vc) {
 try {
  VelocityEngine vengine = getVelocityEngine(pageContext.getServletContext());
  vengine.mergeTemplate(template_file, org.apache.velocity.runtime.RuntimeSingleton.getString(Velocity.INPUT_ENCODING, Velocity.ENCODING_DEFAULT), vc, writer);
 } catch (Exception e) {
  throw new OntopiaRuntimeException(e);
 }
}

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

/** 
 * Performs initialization of this servlet.  Called by the servlet 
 * container on loading.
 *
 * @param config The servlet configuration to apply.
 *
 * @exception ServletException
 */
public void init( ServletConfig config )
  throws ServletException
{
  super.init( config );
  /*
   *  do whatever we have to do to init Velocity
   */                
  initVelocity( config );
  /*
   *  Now that Velocity is initialized, cache some config.
   */
  defaultContentType = RuntimeSingleton.getString(CONTENT_TYPE,
                          DEFAULT_CONTENT_TYPE);
}

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

/**
 * Default constructor: sets up the Velocity
 * Runtime, creates the visitor for traversing
 * the node structure and then produces the
 * visual representation by the visitation.
 */
public TemplateNodeView(String template)
{
  try
  {
    RuntimeSingleton.init("velocity.properties");
    InputStreamReader isr = new InputStreamReader(
                  new FileInputStream(template),
                  RuntimeSingleton.getString(RuntimeSingleton.INPUT_ENCODING));
    BufferedReader br = new BufferedReader( isr );
                       document = RuntimeSingleton.parse( br, template);
    visitor = new NodeViewMode();
    visitor.setContext(null);
    visitor.setWriter(new PrintWriter(System.out));
    document.jjtAccept(visitor, null);
  }
  catch (Exception e)
  {
    System.out.println(e);
    e.printStackTrace();
  }
}

代码示例来源:origin: com.samskivert/samskivert

@Override
public void init (ServletConfig config)
  throws ServletException
{
  super.init(config);
  // create and initialize our application
  try {
    _app = createApp(config);
    _app.init(config, getServletContext(), getLogicPackage(config));
  } catch (Throwable t) {
    throw new ServletException("Error instantiating Application: " + t, t);
  }
  try {
    Velocity.init(loadConfiguration(config));
  } catch (Exception e) {
    throw new ServletException("Error initializing Velocity: " + e, e);
  }
  _defaultContentType = RuntimeSingleton.getString(CONTENT_TYPE, DEFAULT_CONTENT_TYPE);
  // determine the character set we'll use
  _charset = config.getInitParameter(CHARSET_KEY);
  if (_charset == null) {
    _charset = "UTF-8";
  }
}

相关文章