📄 runtimesingleton.java
字号:
* @see RuntimeInstance#getTemplate(String, String)
*/
public static Template getTemplate(String name, String encoding)
throws ResourceNotFoundException, ParseErrorException, Exception
{
return ri.getTemplate( name, encoding );
}
/**
* Returns a static content resource from the
* resource manager. Uses the current value
* if INPUT_ENCODING as the character encoding.
*
* @param name Name of content resource to get
* @return parsed ContentResource object ready for use
* @throws ResourceNotFoundException if template not found
* from any available source.
* @throws ParseErrorException When the template could not be parsed.
* @throws Exception Any other error.
* @see RuntimeInstance#getContent(String)
*/
public static ContentResource getContent(String name)
throws ResourceNotFoundException, ParseErrorException, Exception
{
return ri.getContent( name );
}
/**
* Returns a static content resource from the
* resource manager.
*
* @param name Name of content resource to get
* @param encoding Character encoding to use
* @return parsed ContentResource object ready for use
* @throws ResourceNotFoundException if template not found
* from any available source.
* @throws ParseErrorException When the template could not be parsed.
* @throws Exception Any other error.
* @see RuntimeInstance#getContent(String, String)
*/
public static ContentResource getContent( String name, String encoding )
throws ResourceNotFoundException, ParseErrorException, Exception
{
return ri.getContent( name, encoding );
}
/**
* Determines is a template exists, and returns name of the loader that
* provides it. This is a slightly less hokey way to support
* the Velocity.templateExists() utility method, which was broken
* when per-template encoding was introduced. We can revisit this.
*
* @param resourceName Name of template or content resource
* @return class name of loader than can provide it
* @see RuntimeInstance#getLoaderNameForResource(String)
*/
public static String getLoaderNameForResource( String resourceName )
{
return ri.getLoaderNameForResource( resourceName );
}
/**
* Returns a convenient Log instance that wraps the current LogChute.
*
* @return A convenience Log instance that wraps the current LogChute.
* @see RuntimeInstance#getLog()
*/
public static Log getLog()
{
return ri.getLog();
}
/**
* @deprecated Use getLog() and call warn() on it.
* @see Log#warn(Object)
* @param message The message to log.
*/
public static void warn(Object message)
{
getLog().warn(message);
}
/**
* @deprecated Use getLog() and call info() on it.
* @see Log#info(Object)
* @param message The message to log.
*/
public static void info(Object message)
{
getLog().info(message);
}
/**
* @deprecated Use getLog() and call error() on it.
* @see Log#error(Object)
* @param message The message to log.
*/
public static void error(Object message)
{
getLog().error(message);
}
/**
* @deprecated Use getLog() and call debug() on it.
* @see Log#debug(Object)
* @param message The message to log.
*/
public static void debug(Object message)
{
getLog().debug(message);
}
/**
* String property accessor method with default to hide the
* configuration implementation.
*
* @param key property key
* @param defaultValue default value to return if key not
* found in resource manager.
* @return value of key or default
* @see RuntimeInstance#getString(String, String)
*/
public static String getString( String key, String defaultValue)
{
return ri.getString( key, defaultValue );
}
/**
* Returns the appropriate VelocimacroProxy object if strVMname
* is a valid current Velocimacro.
*
* @param vmName Name of velocimacro requested
* @param templateName Name of the template that contains the velocimacro.
* @return The requested VelocimacroProxy.
* @see RuntimeInstance#getVelocimacro(String, String)
*/
public static Directive getVelocimacro( String vmName, String templateName )
{
return ri.getVelocimacro( vmName, templateName );
}
/**
* Adds a new Velocimacro. Usually called by Macro only while parsing.
*
* @param name Name of velocimacro
* @param macro String form of macro body
* @param argArray Array of strings, containing the
* #macro() arguments. the 0th is the name.
* @param sourceTemplate Name of the template that contains the velocimacro.
* @return True if added, false if rejected for some
* reason (either parameters or permission settings)
* @see RuntimeInstance#addVelocimacro(String, String, String[], String)
*/
public static boolean addVelocimacro( String name,
String macro,
String argArray[],
String sourceTemplate )
{
return ri.addVelocimacro( name, macro, argArray, sourceTemplate );
}
/**
* Checks to see if a VM exists
*
* @param vmName Name of the Velocimacro.
* @param templateName Template on which to look for the Macro.
* @return True if VM by that name exists, false if not
* @see RuntimeInstance#isVelocimacro(String, String)
*/
public static boolean isVelocimacro( String vmName, String templateName )
{
return ri.isVelocimacro( vmName, templateName );
}
/**
* tells the vmFactory to dump the specified namespace. This is to support
* clearing the VM list when in inline-VM-local-scope mode
* @param namespace Namespace to dump.
* @return True if namespace was dumped successfully.
* @see RuntimeInstance#dumpVMNamespace(String)
*/
public static boolean dumpVMNamespace( String namespace )
{
return ri.dumpVMNamespace( namespace );
}
/* --------------------------------------------------------------------
* R U N T I M E A C C E S S O R M E T H O D S
* --------------------------------------------------------------------
* These are the getXXX() methods that are a simple wrapper
* around the configuration object. This is an attempt
* to make a the Velocity Runtime the single access point
* for all things Velocity, and allow the Runtime to
* adhere as closely as possible the the Mediator pattern
* which is the ultimate goal.
* --------------------------------------------------------------------
*/
/**
* String property accessor method to hide the configuration implementation
* @param key property key
* @return value of key or null
* @see RuntimeInstance#getString(String)
*/
public static String getString(String key)
{
return ri.getString( key );
}
/**
* Int property accessor method to hide the configuration implementation.
*
* @param key Property key
* @return value
* @see RuntimeInstance#getInt(String)
*/
public static int getInt( String key )
{
return ri.getInt( key );
}
/**
* Int property accessor method to hide the configuration implementation.
*
* @param key property key
* @param defaultValue The default value.
* @return value
* @see RuntimeInstance#getInt(String, int)
*/
public static int getInt( String key, int defaultValue )
{
return ri.getInt( key, defaultValue );
}
/**
* Boolean property accessor method to hide the configuration implementation.
*
* @param key property key
* @param def The default value if property not found.
* @return value of key or default value
* @see RuntimeInstance#getBoolean(String, boolean)
*/
public static boolean getBoolean( String key, boolean def )
{
return ri.getBoolean( key, def );
}
/**
* Return the velocity runtime configuration object.
*
* @return ExtendedProperties configuration object which houses
* the velocity runtime properties.
* @see RuntimeInstance#getConfiguration()
*/
public static ExtendedProperties getConfiguration()
{
return ri.getConfiguration();
}
/**
* Return the Introspector for this RuntimeInstance
*
* @return Introspector object for this runtime instance
* @see RuntimeInstance#getIntrospector()
*/
public static Introspector getIntrospector()
{
return ri.getIntrospector();
}
/**
* Returns the event handlers for the application.
* @return The event handlers for the application.
* @see RuntimeInstance#getApplicationEventCartridge()
*/
public EventCartridge getEventCartridge()
{
return ri.getApplicationEventCartridge();
}
/**
* Gets the application attribute for the given key
*
* @see org.apache.velocity.runtime.RuntimeServices#getApplicationAttribute(Object)
* @param key
* @return The application attribute for the given key.
* @see RuntimeInstance#getApplicationAttribute(Object)
*/
public static Object getApplicationAttribute(Object key)
{
return ri.getApplicationAttribute(key);
}
/**
* Returns the Uberspect object for this Instance.
*
* @return The Uberspect object for this Instance.
* @see org.apache.velocity.runtime.RuntimeServices#getUberspect()
* @see RuntimeInstance#getUberspect()
*/
public static Uberspect getUberspect()
{
return ri.getUberspect();
}
/**
* @deprecated Use getRuntimeServices() instead.
* @return The RuntimeInstance used by this Singleton.
*/
public static RuntimeInstance getRuntimeInstance()
{
return ri;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -