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

Method load

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

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

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