• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java NoIndentWriter类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中org.stringtemplate.v4.NoIndentWriter的典型用法代码示例。如果您正苦于以下问题:Java NoIndentWriter类的具体用法?Java NoIndentWriter怎么用?Java NoIndentWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

NoIndentWriter类属于org.stringtemplate.v4包,在下文中一共展示了NoIndentWriter类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: generateCodeSetDetail

点赞 3

import org.stringtemplate.v4.NoIndentWriter; //导入依赖的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);
  }
}
 

开发者ID:FIXTradingCommunity,
项目名称:fix-orchestra,
代码行数:24,
代码来源:DocGenerator.java

示例2: generateComponentDetail

点赞 3

import org.stringtemplate.v4.NoIndentWriter; //导入依赖的package包/类
private void generateComponentDetail(File outputDir, ComponentType component) throws IOException {
  ST stComponentStart;
  if (component instanceof GroupType) {
    stComponentStart = stGroup.getInstanceOf("groupStart");
  } else {
    stComponentStart = stGroup.getInstanceOf("componentStart");
  }
  stComponentStart.add("component", component);
  ST stComponentEnd = stGroup.getInstanceOf("componentEnd");
  stComponentEnd.add("component", component);
  File outputFile = new File(outputDir, String.format("%s.html", component.getName()));
  List<Object> members = component.getComponentRefOrGroupRefOrFieldRef();

  try (OutputStreamWriter fileWriter =
      new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8")) {
    NoIndentWriter writer = new NoIndentWriter(fileWriter);
    stComponentStart.write(writer, templateErrorListener);
    generateMembers(members, writer);
    stComponentEnd.write(writer, templateErrorListener);
  }
}
 

开发者ID:FIXTradingCommunity,
项目名称:fix-orchestra,
代码行数:22,
代码来源:DocGenerator.java

示例3: generateUMLStateMachine

点赞 3

import org.stringtemplate.v4.NoIndentWriter; //导入依赖的package包/类
public void generateUMLStateMachine(File outputDir, StateMachineType stateMachine,
    STErrorListener errorListener) throws IOException {
  StringWriter stringWriter = new StringWriter();
  NoIndentWriter writer = new NoIndentWriter(stringWriter);

  ST stStates = stGroup.getInstanceOf("stateMachine");
  stStates.add("stateMachine", stateMachine);
  stStates.write(writer, errorListener);

  String umlString = stringWriter.toString();

  SourceStringReader reader = new SourceStringReader(umlString);
  File outputFile = new File(outputDir, String.format("%s.png", stateMachine.getName()));
  FileOutputStream png = new FileOutputStream(outputFile);
  String desc = reader.generateImage(png);
}
 

开发者ID:FIXTradingCommunity,
项目名称:fix-orchestra,
代码行数:17,
代码来源:ImgGenerator.java

示例4: generateUMLSequence

点赞 3

import org.stringtemplate.v4.NoIndentWriter; //导入依赖的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);
}
 

开发者ID:FIXTradingCommunity,
项目名称:fix-orchestra,
代码行数:23,
代码来源:ImgGenerator.java

示例5: generateResponses

点赞 3

import org.stringtemplate.v4.NoIndentWriter; //导入依赖的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);
      }
    }
  }
}
 

开发者ID:FIXTradingCommunity,
项目名称:fix-orchestra,
代码行数:22,
代码来源:ImgGenerator.java

示例6: onExchange

点赞 3

import org.stringtemplate.v4.NoIndentWriter; //导入依赖的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());
}
 

开发者ID:HydAu,
项目名称:Camel,
代码行数:27,
代码来源:StringTemplateEndpoint.java

示例7: generateActorDetail

点赞 2

import org.stringtemplate.v4.NoIndentWriter; //导入依赖的package包/类
private void generateActorDetail(File docDir, File imgDir, ActorType actor) throws IOException {
  File outputFile = new File(docDir, String.format("%s.html", actor.getName()));

  try (OutputStreamWriter fileWriter =
      new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8")) {
    NoIndentWriter writer = new NoIndentWriter(fileWriter);

    ST stActor = stGroup.getInstanceOf("actorStart");
    stActor.add("actor", actor);
    stActor.write(writer, templateErrorListener);

    List<Object> members = actor.getFieldOrFieldRefOrComponent();
    generateMembers(members, writer);

    ST stActor2 = stGroup.getInstanceOf("actorPart2");
    stActor2.add("actor", actor);
    stActor2.write(writer, templateErrorListener);

    List<Object> stateMachines = actor.getFieldOrFieldRefOrComponent().stream()
        .filter(o -> o instanceof StateMachineType).collect(Collectors.toList());

    for (Object stateMachine : stateMachines) {
      ST stStates = stGroup.getInstanceOf("stateMachine");
      stStates.add("states", stateMachine);
      stStates.write(writer, templateErrorListener);
      imgGenerator.generateUMLStateMachine(imgDir, (StateMachineType) stateMachine,
          templateErrorListener);
    }
  }
}
 

开发者ID:FIXTradingCommunity,
项目名称:fix-orchestra,
代码行数:31,
代码来源:DocGenerator.java

示例8: generateMembers

点赞 2

import org.stringtemplate.v4.NoIndentWriter; //导入依赖的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);
    }
  }
}
 

开发者ID:FIXTradingCommunity,
项目名称:fix-orchestra,
代码行数:28,
代码来源:DocGenerator.java

示例9: generateMessageDetail

点赞 2

import org.stringtemplate.v4.NoIndentWriter; //导入依赖的package包/类
private void generateMessageDetail(File messagesDocDir, File messagesImgDir, MessageType message)
    throws IOException {
  ST stMessageStart = stGroup.getInstanceOf("messageStart");
  ST stMessagePart2 = stGroup.getInstanceOf("messagePart2");
  ST stMessageEnd = stGroup.getInstanceOf("messageEnd");
  stMessageStart.add("message", message);
  stMessagePart2.add("message", message);
  stMessageEnd.add("message", message);
  File outputFile = new File(messagesDocDir,
      String.format("%s-%s.html", message.getName(), message.getScenario()));

  List<ResponseType> responses = null;
  final Responses responses2 = message.getResponses();
  if (responses2 != null) {
    responses = responses2.getResponse();
  }
  List<Object> members = message.getStructure().getComponentOrComponentRefOrGroup();

  try (OutputStreamWriter fileWriter =
      new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8")) {
    NoIndentWriter writer = new NoIndentWriter(fileWriter);
    stMessageStart.write(writer, templateErrorListener);
    if (responses != null) {
      generateResponses(responses, writer);
      File imgFile = new File(messagesImgDir,
          String.format("%s-%s.png", message.getName(), message.getScenario()));
      try (OutputStreamWriter imgFileWriter =
          new OutputStreamWriter(new FileOutputStream(imgFile), "UTF-8")) {
        FlowType flow = getFlow(message.getFlow());
        imgGenerator.generateUMLSequence(messagesImgDir, message, flow, responses,
            templateErrorListener);
      }
    }
    stMessagePart2.write(writer, templateErrorListener);
    generateMembers(members, writer);
    stMessageEnd.write(writer, templateErrorListener);
  }
}
 

开发者ID:FIXTradingCommunity,
项目名称:fix-orchestra,
代码行数:39,
代码来源:DocGenerator.java

示例10: generateResponses

点赞 2

import org.stringtemplate.v4.NoIndentWriter; //导入依赖的package包/类
private void generateResponses(List<ResponseType> responseList, NoIndentWriter writer) {
  for (ResponseType response : responseList) {
    List<Object> responses = response.getMessageRefOrAssignOrTrigger();
    for (Object responseRef : responses) {
      if (responseRef instanceof MessageRefType) {
        MessageRefType messageRef = (MessageRefType) responseRef;
        ST st = stGroup.getInstanceOf("messageResponse");
        st.add("message", messageRef.getName());
        st.add("scenario", messageRef.getScenario());
        st.add("when", response.getWhen());
        st.write(writer, templateErrorListener);
      }
    }
  }
}
 

开发者ID:FIXTradingCommunity,
项目名称:fix-orchestra,
代码行数:16,
代码来源:DocGenerator.java

示例11: render

点赞 2

import org.stringtemplate.v4.NoIndentWriter; //导入依赖的package包/类
private void render(ST template, File file) throws IOException {
    file.getParentFile().mkdirs();
    try (final OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file), "utf-8")) {
        final StringWriter sw = new StringWriter();
        template.write(new NoIndentWriter(sw));
        out.write(sw.toString());
    }
}
 

开发者ID:nidi3,
项目名称:raml-doc,
代码行数:9,
代码来源:Generator.java

示例12: createSTWriter

点赞 2

import org.stringtemplate.v4.NoIndentWriter; //导入依赖的package包/类
private final STWriter createSTWriter(final Writer writer) {
    if (outputHtmlIndented) {
        return new AutoIndentWriter(writer); // README is this even needed when STFastGroupDir reads with and without indentation?
    } else {
        return new NoIndentWriter(writer);//no indents for less HTML as a result
    }
}
 

开发者ID:MTDdk,
项目名称:jawn,
代码行数:8,
代码来源:StringTemplateTemplateEngine.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)