Format body with proper indents using SAX.
@param body Response body
@return New properly formatted body
@throws IOException If fails
176438
private static byte[] transform(final InputStream body) throws IOException {
        final SAXSource source = new SAXSource(new InputSource(body));
        final ByteArrayOutputStream result = new ByteArrayOutputStream();
        try {
            final XMLReader xmlreader = SAXParserFactory.newInstance()
                .newSAXParser().getXMLReader();
            source.setXMLReader(xmlreader);
            xmlreader.setFeature(
                RsPrettyXml.LOAD_EXTERNAL_DTD, false
            );
            final String yes = "yes";
            final Transformer transformer = TransformerFactory.newInstance()
                .newTransformer();
            // @checkstyle MultipleStringLiteralsCheck (2 line)
            transformer.setOutputProperty(
                OutputKeys.OMIT_XML_DECLARATION, yes
            );
            RsPrettyXml.prepareDocType(body, transformer);
            transformer.setOutputProperty(OutputKeys.INDENT, yes);
            transformer.transform(source, new StreamResult(result));
        } catch (final TransformerException
            | ParserConfigurationException
            | SAXException ex) {
            throw new IOException(ex);
        }
        return result.toByteArray();
    }
307922
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {

      out.write("public interface " + getClassName(def) + " extends Serializable, Referenceable");
      writeLeftCurlyBracket(out, 0);
      int indent = 1;

      writeConnection(def, out, indent);
      writeRightCurlyBracket(out, 0);
   }
634143
public static HtmlTree DT(Content body) {
        HtmlTree htmltree = new HtmlTree(HtmlTag.DT, nullCheck(body));
        return htmltree;
    }
27649
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {
      int indent = 1;
      out.write("public interface " + getClassName(def));
      writeLeftCurlyBracket(out, 0);
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Receive message\n");
      writeWithIndent(out, indent, " * @param msg String.\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent, "public void onMessage(String msg);");

      writeRightCurlyBracket(out, 0);
   }
761763
public static HtmlTree CAPTION(Content body) {
        HtmlTree htmltree = new HtmlTree(HtmlTag.CAPTION, nullCheck(body));
        return htmltree;
    }
218131
private final void writeIndentation() throws IOException {

        // Write indentation only if there is any
        if (_indentation.length() > 0) {
            int count = _elementStackSize - 1;
            for (int i = 0; i < count; i++) {
                _out.write(_indentation);
            }
        }
    }
309389
private String getRequestBody(ServletRequest request) throws IOException {

        final StringBuilder sb = new StringBuilder();

        String line = request.getReader().readLine();
        while (null != line) {
            sb.append(line);
            line = request.getReader().readLine();
        }

        return sb.toString();
    }
334440
public PactDslRequestWithoutPath body(JSONObject body) {
        requestBody = OptionalBody.body(body.toString().getBytes());
        if (!requestHeaders.containsKey(CONTENT_TYPE)) {
            requestHeaders.put(CONTENT_TYPE, Collections.singletonList(ContentType.APPLICATION_JSON.toString()));
        }
        return this;
    }
29680
public String formatStringAsJavadoc(String input) {

        if (input == null) {
            return null;
        }

        final StringBuilder finalComment = new StringBuilder("/**\n");
        Matcher regexMatcher = commentFormattingRegex.matcher(input);
        while (regexMatcher.find()) {
            finalComment.append("* ");
            finalComment.append(regexMatcher.group());
        }
        finalComment.append("\n*/\n");

        return finalComment.toString();
    }
777596
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {
      int indent = 1;

      out.write("public interface " + getClassName(def));
      writeLeftCurlyBracket(out, 0);

      if (def.getMcfDefs().get(getNumOfMcf()).isDefineMethodInConnection())
      {
         if (def.getMcfDefs().get(getNumOfMcf()).getMethods().size() > 0)
         {
            for (MethodForConnection method : def.getMcfDefs().get(getNumOfMcf()).getMethods())
            {
               writeMethodSignature(out, indent, method);
               out.write(";\n");
            }
         }
      }
      else
      {
         writeSimpleMethodSignature(out, indent, " * Call me", "public void callMe();");
      }

      writeEol(out);
      writeSimpleMethodSignature(out, indent, " * Close", "public void close();");

      writeRightCurlyBracket(out, 0);
   }
946810
public static Event withBody(Object body, Map<String, String> headers) {
    Event event = new SimpleEvent(body);

//    if (body == null) {
//      body = null;
//    }
//    event.setBody(body);

    if (headers != null) {
      event.setHeaders(new HashMap<String, String>(headers));
    }

    return event;
  }
794462
public IPromise postStuff1(JsonObject body, HeaderMap headerValues ) {
        headerValues.forEach( hv -> {
            Log.Info(this,""+hv.getHeaderName());
            hv.forEach( s -> {
                Log.Info(this,"    "+s);
            });
        });
        Log.Info(this,""+body);
        return resolve(new Pair(202,body.toString()));
    }
844528
@Override
   public void writeXmlBody(Definition def, Writer out) throws IOException
   {
      writeConnectorVersion(out);

      int indent = 1;
      writeIndent(out, indent);
      out.write("<display-name>Display Name</display-name>");
      writeEol(out);
      writeIndent(out, indent);
      out.write("<vendor-name>Red Hat Inc</vendor-name>");
      writeEol(out);
      writeIndent(out, indent);
      out.write("<spec-version>1.0</spec-version>");
      writeEol(out);
      writeIndent(out, indent);
      out.write("<eis-type>Test RA</eis-type>");
      writeEol(out);
      writeIndent(out, indent);
      out.write("<version>0.1</version>");
      writeEol(out);

      writeIndent(out, indent);
      out.write("<resourceadapter>");
      writeEol(out);

      writeOutbound(def, out, indent + 1);

      writeIndent(out, indent);
      out.write("</resourceadapter>");
      writeEol(out);
      out.write("</connector>");
      writeEol(out);
   }
949315
public void setBody(CharSequence body) {
        String bodyString;
        if (body != null) {
            bodyString = body.toString();
        } else {
            bodyString = null;
        }
        setBody(bodyString);
    }
1261448
public MailBuilder content(Body body) {
        return text(body.text()).html(body.html());
    }
1080049
public static HtmlTree CODE(Content body) {
        HtmlTree htmltree = new HtmlTree(HtmlTag.CODE, nullCheck(body));
        return htmltree;
    }
336734
@Override
   public void writeClassBody(Definition def, Writer out) throws IOException
   {
      int indent = 1;
      out.write("public class " + getClassName(def) + " implements ManagedConnection");
      writeLeftCurlyBracket(out, 0);
      writeEol(out);

      writeWithIndent(out, indent, "/** The logger */\n");
      writeWithIndent(out, indent, "private static Logger log = Logger.getLogger(" + getSelfClassName(def) + ");\n\n");

      writeWithIndent(out, indent, "/** The logwriter */\n");
      writeWithIndent(out, indent, "private PrintWriter logwriter;\n\n");

      writeWithIndent(out, indent, "/** ManagedConnectionFactory */\n");
      writeWithIndent(out, indent, "private " + def.getMcfDefs().get(getNumOfMcf()).getMcfClass() + " mcf;\n\n");

      writeWithIndent(out, indent, "/** Listeners */\n");
      writeWithIndent(out, indent, "private List<ConnectionEventListener> listeners;\n\n");

      writeWithIndent(out, indent, "/** Connections */\n");
      if (def.getMcfDefs().get(getNumOfMcf()).isUseCciConnection())
         writeWithIndent(out, indent,
               "private Set<" + def.getMcfDefs().get(getNumOfMcf()).getCciConnClass() + "> connections;\n\n");
      else
         writeWithIndent(out, indent,
               "private Set<" + def.getMcfDefs().get(getNumOfMcf()).getConnImplClass() + "> connections;\n\n");

      if (def.isSupportEis())
      {
         writeWithIndent(out, indent, "/** Socket */\n");
         writeWithIndent(out, indent, "private Socket socket;\n\n");
      }

      //constructor
      writeWithIndent(out, indent, "/**\n");
      writeWithIndent(out, indent, " * Default constructor\n");
      writeWithIndent(out, indent, " * @param mcf mcf\n");
      writeWithIndent(out, indent, " */\n");

      writeWithIndent(out, indent,
            "public " + getClassName(def) + "(" + def.getMcfDefs().get(getNumOfMcf()).getMcfClass() + " mcf)");
      if (def.isSupportEis())
      {
         out.write(" throws ResourceException");
      }
      writeLeftCurlyBracket(out, indent);
      writeWithIndent(out, indent + 1, "this.mcf = mcf;\n");
      writeWithIndent(out, indent + 1, "this.logwriter = null;\n");
      writeWithIndent(out, indent + 1,
            "this.listeners = Collections.synchronizedList(new ArrayList<ConnectionEventListener>(1));\n");
      if (def.getMcfDefs().get(getNumOfMcf()).isUseCciConnection())
         writeWithIndent(out, indent + 1,
               "this.connections = new HashSet<" + def.getMcfDefs().get(getNumOfMcf()).getCciConnClass() + ">();");
      else
         writeWithIndent(out, indent + 1,
               "this.connections = new HashSet<" + def.getMcfDefs().get(getNumOfMcf()).getConnImplClass() + ">();");

      if (def.isSupportEis())
      {
         writeEol(out);
         writeWithIndent(out, indent + 1, "this.socket = null; // TODO: Initialize me");
      }

      writeRightCurlyBracket(out, indent);
      writeEol(out);

      writeConnection(def, out, indent);
      writeLifecycle(def, out, indent);
      writeConnectionEventListener(def, out, indent);
      writeLogWriter(def, out, indent);
      writeTransaction(def, out, indent);
      writeMetaData(def, out, indent);
      writeMethod(def, out, indent);

      writeRightCurlyBracket(out, 0);
   }