All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.jhonnymertz.wkhtmltopdf.wrapper.params.Params Maven / Gradle / Ivy

Go to download

A Java based wrapper for the wkhtmltopdf command line tool. As the name implies, it uses WebKit to convert HTML documents to PDFs.

There is a newer version: 1.3.1-RELEASE
Show newest version
package com.github.jhonnymertz.wkhtmltopdf.wrapper.params;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

/**
 * The type Params.
 */
public class Params {

    private Collection params;

    /**
     * Instantiates a new Params.
     */
    public Params() {
        this.params = new ArrayList<>();
    }

    /**
     * Add.
     *
     * @param param  the param
     * @param params the params
     */
    public void add(final Param param, final Param... params) {
        this.params.add(param);
        this.params.addAll(Arrays.asList(params));
    }

    /**
     * Gets params as string list.
     *
     * @return the params as string list
     */
    public List getParamsAsStringList() {
        List commandLine = new ArrayList<>();

        for (Param p : params) {
            commandLine.add(p.getKey());

            for (String value : p.getValues()) {
                if (value != null) {
                    commandLine.add(value);
                }
            }
        }

        return commandLine;
    }

    @Override
    public String toString() {
        return StringUtils.join(params, "");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy