MCPcopy Create free account
hub / github.com/beanshell/beanshell / getTemplate

Method getTemplate

src/bsh/servlet/SimpleTemplate.java:78–100  ·  view source on GitHub ↗

Get a template by name, with caching. Note: this should be updated to search the resource path first, etc. Create a new instance of a template from the specified file. The file text is cached so lookup is fast. Failure to find the file is also cached so the read will not happen twice.

( String file )

Source from the content-addressed store, hash-verified

76
77 */
78 public static SimpleTemplate getTemplate( String file )
79 {
80 String templateText = (String)templateData.get( file );
81
82 if ( templateText == null || !cacheTemplates ) {
83 try {
84 FileReader fr = new FileReader( file );
85 templateText = SimpleTemplate.getStringFromStream( fr );
86 templateData.put( file, templateText );
87 } catch ( IOException e ) {
88 // Not found
89 templateData.put( file, NO_TEMPLATE );
90 }
91 } else
92 // Quick check prevents trying each time
93 if ( templateText.equals( NO_TEMPLATE ) )
94 return null;
95
96 if ( templateText == null )
97 return null;
98 else
99 return new SimpleTemplate( templateText );
100 }
101
102 public static String getStringFromStream( InputStream ins )
103 throws IOException

Callers

nothing calls this directly

Calls 4

getStringFromStreamMethod · 0.95
getMethod · 0.65
putMethod · 0.65
equalsMethod · 0.45

Tested by

no test coverage detected