MCPcopy Create free account
hub / github.com/antlr/codebuff / loadTemplateFile

Method loadTemplateFile

output/java/1.4.13/STGroupDir.java:157–180  ·  view source on GitHub ↗

Load .st as relative file name relative to root by prefix.

(String prefix, String unqualifiedFileName)

Source from the content-addressed store, hash-verified

155 /** Load .st as relative file name relative to root by {@code prefix}. */
156
157 public CompiledST loadTemplateFile(String prefix, String unqualifiedFileName) {
158 if ( verbose ) System.out.println("loadTemplateFile("+unqualifiedFileName+") in groupdir "+"from "+root +
159" prefix=" +
160prefix);
161 URL f;
162 try {
163 f = new URL(root+prefix+unqualifiedFileName);
164 }
165 catch (MalformedURLException me) {
166 errMgr.runTimeError(null, null, ErrorType.INVALID_TEMPLATE_NAME, me, root+unqualifiedFileName);
167 return null;
168 }
169 ANTLRInputStream fs;
170 try {
171 fs = new ANTLRInputStream(f.openStream(), encoding);
172 fs.name = unqualifiedFileName;
173 }
174 catch (IOException ioe) {
175 if ( verbose ) System.out.println(root+"/"+unqualifiedFileName+" doesn't exist");
176 //errMgr.IOError(null, ErrorType.NO_SUCH_TEMPLATE, ioe, unqualifiedFileName);
177 return null;
178 }
179 return loadTemplateFile(prefix, unqualifiedFileName, fs);
180 }
181
182 @Override
183 public String getName() {

Callers 1

loadMethod · 0.95

Calls 2

runTimeErrorMethod · 0.65
openStreamMethod · 0.45

Tested by

no test coverage detected