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

Method load

output/java/1.4.13/STGroupDir.java:117–153  ·  view source on GitHub ↗

Load a template from directory or group file. Group file is given precedence over directory with same name. name is always fully-qualified.

(String name)

Source from the content-addressed store, hash-verified

115 */
116
117 @Override
118 protected CompiledST load(String name) {
119 if ( verbose ) System.out.println("STGroupDir.load("+name+")");
120 String parent = Misc.getParent(name); // must have parent; it's fully-qualified
121 String prefix = Misc.getPrefix(name);
122// if (parent.isEmpty()) {
123// // no need to check for a group file as name has no parent
124// return loadTemplateFile("/", name+TEMPLATE_FILE_EXTENSION); // load t.st file
125// }
126 URL groupFileURL;
127 try { // see if parent of template name is a group file
128 groupFileURL = new URL(root+parent+GROUP_FILE_EXTENSION);
129 }
130 catch (MalformedURLException e) {
131 errMgr.internalError(null, "bad URL: "+root+parent+GROUP_FILE_EXTENSION, e);
132 return null;
133 }
134 InputStream is = null;
135 try {
136 is = groupFileURL.openStream();
137 }
138 catch (IOException ioe) {
139 // must not be in a group file
140 String unqualifiedName = Misc.getFileName(name);
141 return loadTemplateFile(prefix, unqualifiedName+TEMPLATE_FILE_EXTENSION); // load t.st file
142 }
143 finally { // clean up
144 try {
145 if ( is!=null ) is.close();
146 }
147 catch (IOException ioe) {
148 errMgr.internalError(null, "can't close template file stream "+name, ioe);
149 }
150 }
151 loadGroupFile(prefix, root+parent+GROUP_FILE_EXTENSION);
152 return rawGetTemplate(name);
153 }
154
155 /** Load .st as relative file name relative to root by {@code prefix}. */
156

Callers

nothing calls this directly

Calls 9

getParentMethod · 0.95
getPrefixMethod · 0.95
getFileNameMethod · 0.95
loadTemplateFileMethod · 0.95
internalErrorMethod · 0.65
openStreamMethod · 0.45
closeMethod · 0.45
loadGroupFileMethod · 0.45
rawGetTemplateMethod · 0.45

Tested by

no test coverage detected