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

Method loadTemplateFile

output/java/1.4.17/STGroupDir.java:158–184  ·  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

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

Callers 1

loadMethod · 0.95

Calls 2

runTimeErrorMethod · 0.65
openStreamMethod · 0.45

Tested by

no test coverage detected