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

Method loadTemplateFile

output/java/1.4.19/STGroupDir.java:159–186  ·  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

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

Callers 1

loadMethod · 0.95

Calls 2

runTimeErrorMethod · 0.65
openStreamMethod · 0.45

Tested by

no test coverage detected