blob: a161bf790690a3a3802cf8c3360b602101307bc8 [file] [log] [blame]
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package signature.io.html;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.antlr.stringtemplate.StringTemplate;
import org.antlr.stringtemplate.StringTemplateGroup;
import org.antlr.stringtemplate.language.DefaultTemplateLexer;
public class TemplateStore {
private static StringTemplateGroup group = initialize();
private static StringTemplateGroup initialize() {
InputStream modelStream = TemplateStore.class.getClassLoader()
.getResourceAsStream("model/model.stg");
InputStreamReader modelReader = new InputStreamReader(modelStream);
StringTemplateGroup modelGroup = new StringTemplateGroup(modelReader,
DefaultTemplateLexer.class);
InputStream stream = TemplateStore.class.getClassLoader()
.getResourceAsStream("delta/deltas.stg");
InputStreamReader reader = new InputStreamReader(stream);
StringTemplateGroup deltaGroup = new StringTemplateGroup(reader,
DefaultTemplateLexer.class);
StringTemplateGroup group = new StringTemplateGroup("signature", null,
DefaultTemplateLexer.class);
group.setSuperGroup(deltaGroup);
deltaGroup.setSuperGroup(modelGroup);
return group;
}
private TemplateStore() {/* no instances allowed */
}
public static StringTemplate getStringTemplate(String name) {
return group.getInstanceOf(name);
}
}