本文整理匯總了Java中org.stringtemplate.v4.ST.write方法的典型用法代碼示例。如果您正苦於以下問題:Java ST.write方法的具體用法?Java ST.write怎麽用?Java ST.write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.stringtemplate.v4.ST
的用法示例。
在下文中一共展示了ST.write方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: write
import org.stringtemplate.v4.ST; //導入方法依賴的package包/類
public void write(ST code, String fileName) {
try {
// long start = System.currentTimeMillis();
Writer w = tool.getOutputFileWriter(g, fileName);
STWriter wr = new AutoIndentWriter(w);
wr.setLineWidth(lineWidth);
code.write(wr);
w.close();
// long stop = System.currentTimeMillis();
}
catch (IOException ioe) {
tool.errMgr.toolError(ErrorType.CANNOT_WRITE_FILE,
ioe,
fileName);
}
}
示例2: generateFeature
import org.stringtemplate.v4.ST; //導入方法依賴的package包/類
private void generateFeature(AutoIndentWriter writer, Repository repository, FlowType flow,
ActorType actor) {
final STGroupFile stFeatureGroup = new STGroupFile("templates/feature.stg");
ST st = stFeatureGroup.getInstanceOf("feature");
st.add("repository", repository);
st.add("flow", flow);
st.add("actor", actor);
st.write(writer, errorListener);
repository.getMessages().getMessage().stream()
.filter(m -> flow.getName().equals(m.getFlow())).forEach(message -> {
Responses responses = message.getResponses();
if (responses != null)
responses.getResponse().forEach(response -> generateFeatureScenario(writer, stFeatureGroup, repository, actor, message, response));
});
}
示例3: generateFeatureScenario
import org.stringtemplate.v4.ST; //導入方法依賴的package包/類
private void generateFeatureScenario(AutoIndentWriter writer, STGroupFile stFeatureGroup, Repository repository, ActorType actor,
MessageType message, ResponseType response) {
ST st = stFeatureGroup.getInstanceOf("scenario");
st.add("actor", actor);
st.add("message", message);
st.add("response", response);
st.write(writer, errorListener);
List<Object> messageElements = message.getStructure().getComponentOrComponentRefOrGroup();
generateFeatureMessageElements(writer, stFeatureGroup, messageElements);
List<Object> actions = response.getMessageRefOrAssignOrTrigger();
for (Object action : actions) {
if (action instanceof MessageRefType) {
MessageRefType messageRef = (MessageRefType) action;
ST stMessage = stFeatureGroup.getInstanceOf("messageRef");
stMessage.add("actor", actor);
stMessage.add("messageRef", messageRef);
stMessage.write(writer, errorListener);
MessageType responseMessage = findMessage(messageRef.getName(), messageRef.getScenario());
List<Object> responseMessageElements =
responseMessage.getStructure().getComponentOrComponentRefOrGroup();
generateFeatureMessageElements(writer, stFeatureGroup, responseMessageElements);
}
}
}
示例4: onExchange
import org.stringtemplate.v4.ST; //導入方法依賴的package包/類
@Override
protected void onExchange(Exchange exchange) throws Exception {
StringWriter buffer = new StringWriter();
@SuppressWarnings("unchecked")
Map<String, Object> variableMap = exchange.getIn().getHeader(StringTemplateConstants.STRINGTEMPLATE_VARIABLE_MAP, Map.class);
if (variableMap == null) {
variableMap = ExchangeHelper.createVariableMap(exchange);
}
// getResourceAsInputStream also considers the content cache
String text = exchange.getContext().getTypeConverter().mandatoryConvertTo(String.class, getResourceAsInputStream());
ST template = new ST(text, delimiterStart, delimiterStop);
for (Map.Entry<String, Object> entry : variableMap.entrySet()) {
template.add(entry.getKey(), entry.getValue());
}
log.debug("StringTemplate is writing using attributes: {}", variableMap);
template.write(new NoIndentWriter(buffer));
// now lets output the results to the exchange
Message out = exchange.getOut();
out.setBody(buffer.toString());
out.setHeaders(exchange.getIn().getHeaders());
out.setHeader(StringTemplateConstants.STRINGTEMPLATE_RESOURCE_URI, getResourceUri());
out.setAttachments(exchange.getIn().getAttachments());
}
示例5: generateCodeSetDetail
import org.stringtemplate.v4.ST; //導入方法依賴的package包/類
private void generateCodeSetDetail(File outputDir, CodeSetType codeSet) throws IOException {
File outputFile = new File(outputDir, String.format("%s.html", codeSet.getName()));
try (OutputStreamWriter fileWriter =
new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8")) {
NoIndentWriter writer = new NoIndentWriter(fileWriter);
ST stCodesetStart = stGroup.getInstanceOf("codeSetStart");
stCodesetStart.add("codeSet", codeSet);
stCodesetStart.write(writer, templateErrorListener);
List<CodeType> codeList = codeSet.getCode();
for (CodeType code : codeList) {
ST stCode = stGroup.getInstanceOf("code");
stCode.add("code", code);
stCode.add("supported", supportedMap.get(code.getSupported()));
stCode.write(writer, templateErrorListener);
}
ST stCodesetEnd = stGroup.getInstanceOf("codeSetEnd");
stCodesetEnd.add("codeSet", codeSet);
stCodesetEnd.write(writer, templateErrorListener);
}
}
示例6: generateResponses
import org.stringtemplate.v4.ST; //導入方法依賴的package包/類
private void generateResponses(List<ResponseType> responseList, NoIndentWriter writer,
STErrorListener errorListener) {
for (int i = 0; i < responseList.size(); i++) {
ResponseType response = responseList.get(i);
List<Object> responses = response.getMessageRefOrAssignOrTrigger();
for (int j = 0; j < responses.size(); j++) {
Object responseRef = responses.get(j);
if (responseRef instanceof MessageRefType) {
MessageRefType messageRef = (MessageRefType) responseRef;
ST st = stGroup.getInstanceOf("messageResponse");
st.add("messageName", messageRef.getName());
st.add("scenarioName", messageRef.getScenario());
st.add("async", response.getSync() == Synchronization.ASYNCHRONOUS);
st.add("name", response.getName());
st.add("isFirstAlt", i == 0 && responseList.size() > 1 && j == 0);
st.add("isAlt", (i != 0) && responseList.size() > 1 && j == 0);
st.write(writer, errorListener);
}
}
}
}
示例7: generateUMLSequence
import org.stringtemplate.v4.ST; //導入方法依賴的package包/類
public void generateUMLSequence(File outputDir, MessageType message, FlowType flow,
List<ResponseType> responseList, STErrorListener errorListener) throws IOException {
StringWriter stringWriter = new StringWriter();
NoIndentWriter writer = new NoIndentWriter(stringWriter);
ST stSequence = stGroup.getInstanceOf("sequence");
stSequence.add("message", message);
stSequence.add("flow", flow);
stSequence.write(writer, errorListener);
generateResponses(responseList, writer, errorListener);
ST stEnd = stGroup.getInstanceOf("sequenceEnd");
stEnd.add("message", message);
stEnd.write(writer, errorListener);
String umlString = stringWriter.toString();
SourceStringReader reader = new SourceStringReader(umlString);
File outputFile =
new File(outputDir, String.format("%s-%s.png", message.getName(), message.getScenario()));
FileOutputStream png = new FileOutputStream(outputFile);
String desc = reader.generateImage(png);
}
示例8: generateActorsList
import org.stringtemplate.v4.ST; //導入方法依賴的package包/類
private void generateActorsList(File outputDir, List<ActorType> actorList) throws IOException {
ST st = stGroup.getInstanceOf("actors");
st.add("actors", actorList);
st.add("title", "All Actors");
File outputFile = new File(outputDir, "AllActors.html");
st.write(outputFile, templateErrorListener, encoding);
}
示例9: generateAllComponentsList
import org.stringtemplate.v4.ST; //導入方法依賴的package包/類
private void generateAllComponentsList(File outputDir, List<ComponentType> componentList)
throws IOException {
ST st = stGroup.getInstanceOf("components");
st.add("components", componentList);
st.add("title", "All Components");
File outputFile = new File(outputDir, "AllComponents.html");
st.write(outputFile, templateErrorListener, encoding);
}
示例10: generateAllMessageList
import org.stringtemplate.v4.ST; //導入方法依賴的package包/類
private void generateAllMessageList(File outputDir, List<MessageType> messageList)
throws IOException {
ST st = stGroup.getInstanceOf("messages");
st.add("messages", messageList);
st.add("title", "All Messages");
File outputFile = new File(outputDir, "AllMessages.html");
st.write(outputFile, templateErrorListener, encoding);
}
示例11: generateCodeSetList
import org.stringtemplate.v4.ST; //導入方法依賴的package包/類
private void generateCodeSetList(File outputDir, List<CodeSetType> codeSetList)
throws IOException {
ST st = stGroup.getInstanceOf("codeSets");
st.add("codeSets", codeSetList);
st.add("title", "All Code Sets");
File outputFile = new File(outputDir, "AllCodeSets.html");
st.write(outputFile, templateErrorListener, encoding);
}
示例12: generateMessageListByFlow
import org.stringtemplate.v4.ST; //導入方法依賴的package包/類
private void generateMessageListByFlow(File outputDir, FlowType flow,
List<MessageType> messageList) throws IOException {
ST st = stGroup.getInstanceOf("messages");
final List<MessageType> filteredMessageList = messageList.stream()
.filter(m -> flow.getName().equals(m.getFlow())).collect(Collectors.toList());
st.add("messages", filteredMessageList);
st.add("title", String.format("%s Messages", flow.getName()));
File outputFile = new File(outputDir, String.format("%sMessages.html", flow.getName()));
st.write(outputFile, templateErrorListener, encoding);
}
示例13: generateFieldsList
import org.stringtemplate.v4.ST; //導入方法依賴的package包/類
private void generateFieldsList(File outputDir, List<FieldType> fieldList) throws IOException {
ST st = stGroup.getInstanceOf("fields");
st.add("fields", fieldList);
st.add("title", "All Fields");
File outputFile = new File(outputDir, "AllFields.html");
st.write(outputFile, templateErrorListener, encoding);
}
示例14: generateCategories
import org.stringtemplate.v4.ST; //導入方法依賴的package包/類
private void generateCategories(File outputDir, String title, List<CategoryType> categoriesList)
throws IOException {
ST st = stGroup.getInstanceOf("categories");
st.add("title", title);
st.add("categories", categoriesList);
File outputFile = new File(outputDir, "MessageCategories.html");
st.write(outputFile, templateErrorListener, encoding);
}
示例15: generateMembers
import org.stringtemplate.v4.ST; //導入方法依賴的package包/類
private void generateMembers(List<Object> members, NoIndentWriter writer) {
for (Object member : members) {
if (member instanceof FieldRefType) {
FieldType field = getField(((FieldRefType) member).getId().intValue());
ST stField = stGroup.getInstanceOf("fieldMember");
stField.add("field", field);
if (((FieldRefType) member).getSupported() == SupportType.SUPPORTED) {
stField.add("presence", getFieldPresence((FieldRefType) member));
} else {
stField.add("presence", supportedMap.get(((FieldRefType) member).getSupported()));
}
stField.add("assign", ((FieldRefType) member).getAssign());
stField.write(writer, templateErrorListener);
} else if (member instanceof ComponentRefType) {
ComponentType component = getComponent(((ComponentRefType) member).getId().intValue());
ST stComponent = stGroup.getInstanceOf("componentMember");
stComponent.add("component", component);
if (((ComponentRefType) member).getSupported() == SupportType.SUPPORTED) {
stComponent.add("presence",
((ComponentRefType) member).getPresence().value().toLowerCase());
} else {
stComponent.add("presence", supportedMap.get(((ComponentRefType) member).getSupported()));
}
stComponent.write(writer, templateErrorListener);
}
}
}