<commit_before>package org.rundeck.api.util;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Properties;
import java.util.Map.Entry;
import org.apache.commons.lang.StringUtils;

/**
 * Utility class for RunDeck arguments
 * 
 * @author <NAME>
 */
public class ArgsUtil {

    /**
     * Generates and url-encode a RunDeck "argString" representing the given options. Format of the argString is
     * <code>"-key1 value1 -key2 'value 2 with spaces'"</code>
     * 
     * @param options to be converted
     * @return an url-encoded string. null if options is null, empty if there are no valid options.
     * @see #generateArgString(Properties)
     */
    public static String generateUrlEncodedArgString(Properties options) {
        String argString = generateArgString(options);
        if (StringUtils.isBlank(argString)) {
            return argString;
        }

        try {
            return URLEncoder.encode(argString, "UTF8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * Generates a RunDeck "argString" representing the given options. Format of the argString is<commit_msg>oops, should be UTF-8, not UTF8<commit_after>package org.rundeck.api.util;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Properties;
import java.util.Map.Entry;
import org.apache.commons.lang.StringUtils;

/**
 * Utility class for RunDeck arguments
 * 
 * @author <NAME>
 */
public class ArgsUtil {

    /**
     * Generates and url-encode a RunDeck "argString" representing the given options. Format of the argString is
     * <code>"-key1 value1 -key2 'value 2 with spaces'"</code>
     * 
     * @param options to be converted
     * @return an url-encoded string. null if options is null, empty if there are no valid options.
     * @see #generateArgString(Properties)
     */
    public static String generateUrlEncodedArgString(Properties options) {
        String argString = generateArgString(options);
        if (StringUtils.isBlank(argString)) {
            return argString;
        }

        try {
            return URLEncoder.encode(argString, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * Generates a RunDeck "argString" representing the given options. Format of the argString is
{'fraction_non_alphanumeric': 0.09332787556283258, 'fraction_numerical': 0.004911993450675399, 'mean_word_length': 2.9041533546325877, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '522483', 'n_tokens_mistral': 701, 'n_tokens_neox': 686, 'n_words': 208}