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.Parser; 27 import org.apache.velocity.runtime.parser.ParseException; 28 import org.apache.velocity.runtime.parser.node.SimpleNode; 29 30 import org.apache.velocity.runtime.directive.Directive; 31 32 import org.apache.velocity.runtime.resource.ContentResource; 33 34 import org.apache.velocity.exception.ResourceNotFoundException; 35 import org.apache.velocity.exception.ParseErrorException; 36 37 import org.apache.commons.collections.ExtendedProperties; 38 39 import org.apache.velocity.util.introspection.Introspector; 40 import org.apache.velocity.util.introspection.Uberspect; 41 42 93 public class RuntimeSingleton implements RuntimeConstants 94 { 95 private static RuntimeInstance ri = new RuntimeInstance(); 96 97 111 public synchronized static void init() 112 throws Exception 113 { 114 ri.init(); 115 } 116 117 120 public static RuntimeServices getRuntimeServices() 121 { 122 return ri; 123 } 124 125 126 133 public static void setProperty(String key, Object value) 134 { 135 ri.setProperty( key, value ); 136 } 137 138 148 public static void setConfiguration( ExtendedProperties configuration) 149 { 150 ri.setConfiguration( configuration ); 151 } 152 153 172 public static void addProperty(String key, Object value) 173 { 174 ri.addProperty( key, value ); 175 } 176 177 183 public static void clearProperty(String key) 184 { 185 ri.clearProperty( key ); 186 } 187 188 195 public static Object getProperty( String key ) 196 { 197 return ri.getProperty( key ); 198 } 199 200 206 public static void init(Properties p) throws Exception 207 { 208 ri.init(p); 209 } 210 211 217 public static void init(String configurationFile) 218 throws Exception 219 { 220 ri.init( configurationFile ); 221 } 222 223 228 private static Parser createNewParser() 229 { 230 return ri.createNewParser(); 231 } 232 233 248 public static SimpleNode parse( Reader reader, String templateName ) 249 throws ParseException 250 { 251 return ri.parse( reader, templateName ); 252 } 253 254 261 public static SimpleNode parse( Reader reader, String templateName, boolean dumpNamespace ) 262 throws ParseException 263 { 264 return ri.parse( reader, templateName, dumpNamespace ); 265 } 266 267 268 282 public static Template getTemplate(String name) 283 throws ResourceNotFoundException, ParseErrorException, Exception 284 { 285 return ri.getTemplate( name ); 286 } 287 288 300 public static Template getTemplate(String name, String encoding) 301 throws ResourceNotFoundException, ParseErrorException, Exception 302 { 303 return ri.getTemplate( name, encoding ); 304 } 305 306 316 public static ContentResource getContent(String name) 317 throws ResourceNotFoundException, ParseErrorException, Exception 318 { 319 return ri.getContent( name ); 320 } 321 322 332 public static ContentResource getContent( String name, String encoding ) 333 throws ResourceNotFoundException, ParseErrorException, Exception 334 { 335 return ri.getContent( name, encoding ); 336 } 337 338 339 348 public static String getLoaderNameForResource( String resourceName ) 349 { 350 return ri.getLoaderNameForResource( resourceName ); 351 } 352 353 354 359 public static void warn(Object message) 360 { 361 ri.warn( message ); 362 } 363 364 369 public static void info(Object message) 370 { 371 ri.info( message ); 372 } 373 374 379 public static void error(Object message) 380 { 381 ri.error( message ); 382 } 383 384 389 public static void debug(Object message) 390 { 391 ri.debug( message ); 392 } 393 394 403 public static String getString( String key, String defaultValue) 404 { 405 return ri.getString( key, defaultValue ); 406 } 407 408 415 public static Directive getVelocimacro( String vmName, String templateName ) 416 { 417 return ri.getVelocimacro( vmName, templateName ); 418 } 419 420 430 public static boolean addVelocimacro( String name, 431 String macro, 432 String argArray[], 433 String sourceTemplate ) 434 { 435 return ri.addVelocimacro( name, macro, argArray, sourceTemplate ); 436 } 437 438 444 public static boolean isVelocimacro( String vmName, String templateName ) 445 { 446 return ri.isVelocimacro( vmName, templateName ); 447 } 448 449 453 public static boolean dumpVMNamespace( String namespace ) 454 { 455 return ri.dumpVMNamespace( namespace ); 456 } 457 458 469 470 475 public static String getString(String key) 476 { 477 return ri.getString( key ); 478 } 479 480 486 public static int getInt( String key ) 487 { 488 return ri.getInt( key ); 489 } 490 491 498 public static int getInt( String key, int defaultValue ) 499 { 500 return ri.getInt( key, defaultValue ); 501 } 502 503 510 public static boolean getBoolean( String key, boolean def ) 511 { 512 return ri.getBoolean( key, def ); 513 } 514 515 521 public static ExtendedProperties getConfiguration() 522 { 523 return ri.getConfiguration(); 524 } 525 526 531 public static Introspector getIntrospector() 532 { 533 return ri.getIntrospector(); 534 } 535 536 539 public static Object getApplicationAttribute(Object key) 540 { 541 return ri.getApplicationAttribute(key); 542 } 543 544 547 public static Uberspect getUberspect() 548 { 549 return ri.getUberspect(); 550 } 551 552 555 public static RuntimeInstance getRuntimeInstance() 556 { 557 return ri; 558 } 559 } 560 | Popular Tags |