1 package org.apache.velocity.runtime; 2 3 18 19 import java.io.Reader ; 20 21 import java.util.Properties ; 22 23 import org.apache.velocity.Template; 24 25 26 import org.apache.velocity.runtime.parser.ParseException; 27 import org.apache.velocity.runtime.parser.node.SimpleNode; 28 29 import org.apache.velocity.runtime.directive.Directive; 30 31 import org.apache.velocity.runtime.resource.ContentResource; 32 33 import org.apache.velocity.exception.ResourceNotFoundException; 34 import org.apache.velocity.exception.ParseErrorException; 35 36 import org.apache.commons.collections.ExtendedProperties; 37 38 90 public class Runtime implements RuntimeConstants 91 { 92 93 107 public synchronized static void init() 108 throws Exception 109 { 110 RuntimeSingleton.init(); 111 } 112 113 120 public static void setProperty(String key, Object value) 121 { 122 RuntimeSingleton.setProperty( key, value ); 123 } 124 125 135 public static void setConfiguration( ExtendedProperties configuration) 136 { 137 RuntimeSingleton.setConfiguration( configuration ); 138 } 139 140 159 public static void addProperty(String key, Object value) 160 { 161 RuntimeSingleton.addProperty( key, value ); 162 } 163 164 170 public static void clearProperty(String key) 171 { 172 RuntimeSingleton.clearProperty( key ); 173 } 174 175 182 public static Object getProperty( String key ) 183 { 184 return RuntimeSingleton.getProperty( key ); 185 } 186 187 193 public static void init(Properties p) throws Exception 194 { 195 RuntimeSingleton.init(p); 196 } 197 198 204 public static void init(String configurationFile) 205 throws Exception 206 { 207 RuntimeSingleton.init( configurationFile ); 208 } 209 210 211 226 public static SimpleNode parse( Reader reader, String templateName ) 227 throws ParseException 228 { 229 return RuntimeSingleton.parse( reader, templateName ); 230 } 231 232 239 public static SimpleNode parse( Reader reader, String templateName, boolean dumpNamespace ) 240 throws ParseException 241 { 242 return RuntimeSingleton.parse( reader, templateName, dumpNamespace ); 243 } 244 245 246 260 public static Template getTemplate(String name) 261 throws ResourceNotFoundException, ParseErrorException, Exception 262 { 263 return RuntimeSingleton.getTemplate( name ); 264 } 265 266 278 public static Template getTemplate(String name, String encoding) 279 throws ResourceNotFoundException, ParseErrorException, Exception 280 { 281 return RuntimeSingleton.getTemplate( name, encoding ); 282 } 283 284 294 public static ContentResource getContent(String name) 295 throws ResourceNotFoundException, ParseErrorException, Exception 296 { 297 return RuntimeSingleton.getContent( name ); 298 } 299 300 310 public static ContentResource getContent( String name, String encoding ) 311 throws ResourceNotFoundException, ParseErrorException, Exception 312 { 313 return RuntimeSingleton.getContent( name, encoding ); 314 } 315 316 317 326 public static String getLoaderNameForResource( String resourceName ) 327 { 328 return RuntimeSingleton.getLoaderNameForResource( resourceName ); 329 } 330 331 332 337 public static void warn(Object message) 338 { 339 RuntimeSingleton.warn( message ); 340 } 341 342 347 public static void info(Object message) 348 { 349 RuntimeSingleton.info( message ); 350 } 351 352 357 public static void error(Object message) 358 { 359 RuntimeSingleton.error( message ); 360 } 361 362 367 public static void debug(Object message) 368 { 369 RuntimeSingleton.debug( message ); 370 } 371 372 381 public static String getString( String key, String defaultValue) 382 { 383 return RuntimeSingleton.getString( key, defaultValue ); 384 } 385 386 393 public static Directive getVelocimacro( String vmName, String templateName ) 394 { 395 return RuntimeSingleton.getVelocimacro( vmName, templateName ); 396 } 397 398 408 public static boolean addVelocimacro( String name, 409 String macro, 410 String argArray[], 411 String sourceTemplate ) 412 { 413 return RuntimeSingleton.addVelocimacro( name, macro, argArray, sourceTemplate ); 414 } 415 416 422 public static boolean isVelocimacro( String vmName, String templateName ) 423 { 424 return RuntimeSingleton.isVelocimacro( vmName, templateName ); 425 } 426 427 431 public static boolean dumpVMNamespace( String namespace ) 432 { 433 return RuntimeSingleton.dumpVMNamespace( namespace ); 434 } 435 436 447 448 453 public static String getString(String key) 454 { 455 return RuntimeSingleton.getString( key ); 456 } 457 458 464 public static int getInt( String key ) 465 { 466 return RuntimeSingleton.getInt( key ); 467 } 468 469 476 public static int getInt( String key, int defaultValue ) 477 { 478 return RuntimeSingleton.getInt( key, defaultValue ); 479 } 480 481 488 public static boolean getBoolean( String key, boolean def ) 489 { 490 return RuntimeSingleton.getBoolean( key, def ); 491 } 492 493 499 public static ExtendedProperties getConfiguration() 500 { 501 return RuntimeSingleton.getConfiguration(); 502 } 503 } 504 | Popular Tags |