Format an open MBean composite data attribute.

@param cd the composite data attribute
@param indent the current indent level of the formatted report

@return the formatted composite data
346505
String getFormattedCompositeData(CompositeData cd, String indent) {
        StringBuilder sb = new StringBuilder();
        indent += INDENT;
        CompositeType type = cd.getCompositeType();
        for (String key : type.keySet()) {
            sb.append("\n").append(indent);
            sb.append(key).append(": ");
            OpenType<?> openType = type.getType(key);
            if (openType instanceof SimpleType) {
                sb.append(cd.get(key));
            } else if (openType instanceof CompositeType) {
                CompositeData nestedData = (CompositeData) cd.get(key);
                sb.append(getFormattedCompositeData(nestedData, indent));
            } else if (openType instanceof TabularType) {
                TabularData tabularData = (TabularData) cd.get(key);
                sb.append(tabularData);
            }
        }
        return String.valueOf(sb);
    }
787893
public Integer getIndent() {
		if (!"yes".equals(get(OutputKeys.INDENT))) {
			return null;
		}

		String value = get(INDENT_AMT);
		return (value == null) ? null : Integer.valueOf(value);
	}
95038
public String getPkgName(ClassDoc cd) {
        String pkgName = cd.containingPackage().name();
        if (pkgName.length() > 0) {
            pkgName += ".";
            return pkgName;
        }
        return "";
    }
1265033
public static String jsonNameVal(final String indent, 
                                   final String name, 
                                   final String val) {
    StringBuilder sb = new StringBuilder();

    sb.append(indent);
    sb.append("\"");
    sb.append(name);
    sb.append("\": ");

    if (val != null) {
      sb.append(jsonEncode(val));
    }

    return sb.toString();
  }
1253572
public static String encode(byte[] bytes, String indentation) {
        int length = bytes.length;
        if (length == 0) return "";  // empty byte array
        String encoded = Base64.encodeBase64String(bytes).replaceAll("\\s", "");  // remove all white space
        StringBuilder result = new StringBuilder();
        if (indentation != null) result.append(indentation);
        result.append(encoded.charAt(0));
        for (int c = 1; c < encoded.length(); c++) {
            if (c % 80 == 0) {
                // format to indented 80 character blocks
                result.append("\n");
                if (indentation != null) result.append(indentation);
            }
            result.append(encoded.charAt(c));
        }
        return result.toString();
    }
555039
function getJavadoc(text, indentSize) {
    if (!text) {
        text = '';
    }
    if (text.includes('"')) {
        text = text.replace(/"/g, '\\"');
    }
    let javadoc = `${_.repeat(' ', indentSize)}/**`;
    const rows = text.split('\n');
    for (let i = 0; i < rows.length; i++) {
        javadoc = `${javadoc}\n${_.repeat(' ', indentSize)} * ${rows[i]}`;
    }
    javadoc = `${javadoc}\n${_.repeat(' ', indentSize)} */`;
    return javadoc;
}
909087
private static char[] getIndent(int indentSize, Map<Integer, char[]> indentCache) {
        char[] indent = indentCache.get(indentSize);
        if (indent == null) {
            indent = new char[indentSize];
            Arrays.fill(indent, SPACE);
            indentCache.put(indentSize, indent);
        }

        return indent;
    }
179776
public static String generate(ClientConfig clientConfig, int indent) {
        Preconditions.isNotNull(clientConfig, "ClientConfig");

        StringBuilder xml = new StringBuilder();
        xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
        XmlGenerator gen = new XmlGenerator(xml);

        gen.open("hazelcast-client", "xmlns", "http://www.hazelcast.com/schema/client-config",
                "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance",
                "xsi:schemaLocation", "http://www.hazelcast.com/schema/client-config "
                        + "http://www.hazelcast.com/schema/client-config/hazelcast-client-config-4.0.xsd");

        //GroupConfig
        group(gen, clientConfig.getGroupConfig());
        //InstanceName
        gen.node("instance-name", clientConfig.getInstanceName());
        //attributes
        gen.appendLabels(clientConfig.getLabels());
        //Properties
        gen.appendProperties(clientConfig.getProperties());
        //Network
        network(gen, clientConfig.getNetworkConfig());
        //ExecutorPoolSize
        if (clientConfig.getExecutorPoolSize() > 0) {
            gen.node("executor-pool-size", clientConfig.getExecutorPoolSize());
        }
        //Security
        security(gen, clientConfig.getSecurityConfig());
        //Listeners
        listener(gen, clientConfig.getListenerConfigs());
        //Serialization
        serialization(gen, clientConfig.getSerializationConfig());
        //Native
        nativeMemory(gen, clientConfig.getNativeMemoryConfig());
        //ProxyFactories
        proxyFactory(gen, clientConfig.getProxyFactoryConfigs());
        //LoadBalancer
        loadBalancer(gen, clientConfig.getLoadBalancer());
        //NearCache
        nearCaches(gen, clientConfig.getNearCacheConfigMap());
        //QueryCaches
        queryCaches(gen, clientConfig.getQueryCacheConfigs());
        //ConnectionStrategy
        ClientConnectionStrategyConfig connectionStrategy = clientConfig.getConnectionStrategyConfig();
        gen.node("connection-strategy", null, "async-start", connectionStrategy.isAsyncStart(),
                "reconnect-mode", connectionStrategy.getReconnectMode());
        //UserCodeDeployment
        userCodeDeployment(gen, clientConfig.getUserCodeDeploymentConfig());
        //FlakeIdGenerator
        flakeIdGenerator(gen, clientConfig.getFlakeIdGeneratorConfigMap());

        //close HazelcastClient
        gen.close();

        return format(xml.toString(), indent);
    }
538482
@Nonnull
  public final XMLWriterSettings setIndent (@Nonnull final EXMLSerializeIndent eIndent)
  {
    m_eIndent = ValueEnforcer.notNull (eIndent, "Indent");
    return this;
  }
909555
static public String encode(byte[] bytes, String indentation) {
        StringBuilder result = new StringBuilder();
        int length = bytes.length;
        if (length == 0) return "";  // empty byte array
        if (indentation != null) result.append(indentation);
        encodeBytes(bytes[0], bytes[0], 0, result);
        for (int i = 1; i < length; i++) {
            if (i % 50 == 0) {
                // format to indented 80 character blocks
                result.append("\n");
                if (indentation != null) result.append(indentation);
            }
            encodeBytes(bytes[i - 1], bytes[i], i, result);
        }
        encodeLastByte(bytes[length - 1], length - 1, result);
        return result.toString();
    }
16277
public String nextCDATA() throws JSONException {
        char         c;
        int          i;
        StringBuffer sb = new StringBuffer();
        for (;;) {
            c = next();
            if (c == 0) {
                throw syntaxError("Unclosed CDATA");
            }
            sb.append(c);
            i = sb.length() - 3;
            if (i >= 0 && sb.charAt(i) == ']' &&
                          sb.charAt(i + 1) == ']' && sb.charAt(i + 2) == '>') {
                sb.setLength(i);
                return sb.toString();
            }
        }
    }
543854
@Override
	public void getModelDescription(StringBuilder out, int indent) {
		indent=0;
		if(!this.unorderedRulesOption.isSet()){
			StringUtils.appendIndented(out, indent, "Method Ordered");
			StringUtils.appendNewline(out);
		}else{
			StringUtils.appendIndented(out, indent, "Method Unordered");
			StringUtils.appendNewline(out);
		}
		if(this.DriftDetectionOption.isSet()){
			StringUtils.appendIndented(out, indent, "Change Detection OFF");
			StringUtils.appendNewline(out);
		}else{
			StringUtils.appendIndented(out, indent, "Change Detection ON");
			StringUtils.appendNewline(out);
		}
		if(this.noAnomalyDetectionOption.isSet()){
			StringUtils.appendIndented(out, indent, "Anomaly Detection OFF");
			StringUtils.appendNewline(out);
		}else{
			StringUtils.appendIndented(out, indent, "Anomaly Detection ON");
			StringUtils.appendNewline(out);
		}
		StringUtils.appendIndented(out, indent, "Number of Rules: " + (this.ruleSet.size()+1));
		StringUtils.appendNewline(out);		
	}
1359752
public String format(String comment, int indentLevel, CommentLocation commentLocation) {

        // Return if there's nothing to do
        if (comment == null) {
            return null;
        }

        final StringBuilder indentString = new StringBuilder();
        for (int i = 0; i < indentLevel; i++) {
            indentString.append("    ");
        }

        // Comment ends with newline
        boolean endsWithNewline = (comment.endsWith("\r\n") || comment.endsWith("\n"));

        List<String> matchList = new ArrayList<String>();
        Matcher regexMatcher = commentFormattingRegex.matcher(comment);
        while (regexMatcher.find()) {
            matchList.add(regexMatcher.group());
        }

        StringBuilder builder = new StringBuilder();

        for (int i = 0; i < matchList.size(); i++) {

            String indent;
            String newline;

            if (commentLocation.equals(CommentLocation.END)) {
                indent = " ";
                newline = "";
            } else {
                indent = indentString.toString();
                newline = "\n";
            }

            // We need to handle the last newline
            if (i == 0) {
                builder.append(indent + matchList.get(i).trim() + newline);
            } else if (i == matchList.size() - 1) {
                builder.append(indent + " " + matchList.get(i).trim() + (endsWithNewline ? newline : ""));
            } else {
                builder.append(indent + " " + matchList.get(i).trim() + newline);
            }
        }

        return builder.toString();
    }
628187
@Override
	public String toJSONString(int indentFactor) throws JSONException {
		final StringWriter w = new StringWriter();
		return this.write(w, indentFactor, 0).toString();
	}
118317
private String formatCdnaCoords() {
        if (cdnaStart.equals(cdnaEnd)) {
            return cdnaStart.toString();
        } else {
            return cdnaStart.toString() + "_" + cdnaEnd.toString();
        }
    }
495352
public static Red5 from(CompositeData cd) {
        Red5 instance = null;
        if (cd.containsKey("connection")) {
            Object cn = cd.get("connection");
            if (cn != null && cn instanceof IConnection) {
                instance = new Red5((IConnection) cn);
            } else {
                instance = new Red5();
            }
        } else {
            instance = new Red5();
        }
        return instance;
    }
329614
@Override
   void writeHashCode(Definition def, Writer out, int indent) throws IOException
   {
      writeIndent(out, indent);
      out.write("/** \n");
      writeIndent(out, indent);
      out.write(" * Returns a hash code value for the object.\n");
      writeIndent(out, indent);
      out.write(" * @return A hash code value for this object.\n");
      writeIndent(out, indent);
      out.write(" */\n");

      writeIndent(out, indent);
      out.write("@Override\n");
      writeIndent(out, indent);
      out.write("public int hashCode()");
      writeLeftCurlyBracket(out, indent);
      writeWithIndent(out, indent + 1, "int result = 17;\n");
      for (int i = 0; i < getConfigProps(def).size(); i++)
      {
         writeWithIndent(out, indent + 1, "if (" + getConfigProps(def).get(i).getName() + " != null)\n");
         writeWithIndent(out, indent + 2,
               "result += 31 * result + 7 * " + getConfigProps(def).get(i).getName() + ".hashCode();\n");
         writeIndent(out, indent + 1);

         out.write("else\n");
         writeWithIndent(out, indent + 2, "result += 31 * result + 7;\n");
      }
      writeWithIndent(out, indent + 1, "return result;");
      writeRightCurlyBracket(out, indent);
      writeEol(out);
   }