<commit_before>package com.xasecure.audit.provider;

import java.io.File;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.rmi.dgc.VMID;
import java.text.SimpleDateFormat;

import org.apache.log4j.helpers.LogLog;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class MiscUtil {
	public static final String TOKEN_HOSTNAME     = "%hostname%";
	public static final String TOKEN_JVM_INSTANCE = "%jvm-instance%";
	public static final String TOKEN_TIME_START   = "%time:";
	public static final String TOKEN_TIME_END     = "%";
	public static final String ESCAPE_STR         = "\\";

	static VMID sJvmID = new VMID();

	public static String LINE_SEPARATOR = System.getProperty("line.separator");

	private static Gson sGsonBuilder = null;

	static {
		try {
			sGsonBuilder = new GsonBuilder().create();
		} catch(Throwable excp) {
		}
	}

	public static String replaceTokens(String str, long time) {
		if(str == null) {
			return str;
		}

		str = replaceHostname(str);
		str = replaceJvmInstance(str);
		str = replaceTime(str, time);

		return str;
	}

	public static String replaceHostname(String str) {
		if(!str.contains(TOKEN_HOSTNAME)) {
			return str;
		}
<commit_msg>ARGUS-5: fix per review comments.<commit_after>package com.xasecure.audit.provider;

import java.io.File;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.rmi.dgc.VMID;
import java.text.SimpleDateFormat;

import org.apache.log4j.helpers.LogLog;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class MiscUtil {
	public static final String TOKEN_HOSTNAME     = "%hostname%";
	public static final String TOKEN_JVM_INSTANCE = "%jvm-instance%";
	public static final String TOKEN_TIME_START   = "%time:";
	public static final String TOKEN_TIME_END     = "%";
	public static final String ESCAPE_STR         = "\\";

	static VMID sJvmID = new VMID();

	public static String LINE_SEPARATOR = System.getProperty("line.separator");

	private static Gson sGsonBuilder = null;

	static {
		try {
			sGsonBuilder = new GsonBuilder().create();
		} catch(Throwable excp) {
			LogLog.warn("failed to create GsonBuilder object. stringigy() will return obj.toString(), instead of Json", excp);
		}
	}

	public static String replaceTokens(String str, long time) {
		if(str == null) {
			return str;
		}

		str = replaceHostname(str);
		str = replaceJvmInstance(str);
		str = replaceTime(str, time);

		return str;
	}

	public static String replaceHostname(String str) {
		if(!str.contains(TOKEN_HOSTNAME)) {
			return str;
		}

{'fraction_non_alphanumeric': 0.11012364760432766, 'fraction_numerical': 0.00115919629057187, 'mean_word_length': 4.262195121951219, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4230751', 'n_tokens_mistral': 915, 'n_tokens_neox': 856, 'n_words': 215}