/**
 *
 */
package com.softcorporation.util.net;

import java.io.File;

import com.softcorporation.util.StringUtil;

/**
 * Client request
 * 
 * @author Vadim Permakoff
 *
 */
public class ClientRequest {

	private String url;
    private File file;
    private String encoding;
    private String content;
    private boolean calcChksum;

    /**
     * Constructor
     * @param url The url
     */
    public ClientRequest(final String url) {
        this.url = url;
    }

    /**
     * Constructor
     * @param url The url
     * @param encoding The encoding
     */
    public ClientRequest(final String url, final String encoding) {
        this.url = url;
        this.encoding = encoding;
    }

    /**
     * Constructor
     * @param url The url
     * @param file The output file
     */
    public ClientRequest(final String url, final File file) {
        this.url = url;
        this.file = file;
    }

    /**
     * Calculate checksum
     * @return true if calculate
     */
    public boolean isCalcChksum() {
        return calcChksum;
    }

    /**
     * Set calculate checksum
     * @param calcChksum true if calculate
     */
    public void setCalcChksum(final boolean calcChksum) {
        this.calcChksum = calcChksum;
    }

    /**
     * Get url
     * @return url
     */
    public String getUrl() {
        return url;
    }

    /**
     * Set url
     * @param url String
     */
    public void setUrl(final String url) {
        this.url = url;
    }

    /**
     * Get file
     * @return file
     */
    public File getFile() {
        return file;
    }

    /**
     * Set file
     * @param file File
     */
    public void setFile(final File file) {
        this.file = file;
    }

    /**
     * Get encoding
     * @return encoding
     */
    public String getEncoding() {
        return encoding;
    }

    /**
     * Set encoding
     * @param encoding String
     */
    public void setEncoding(final String encoding) {
        this.encoding = encoding;
    }

    /**
     * Get content
     * @return content
     */
    public String getContent() {
        return content;
    }

    /**
     * Set content
     * @param content String
     */
    public void setContent(final String content) {
        this.content = content;
    }

    /**
     * Creates a printable representation of this object.
     * 
     * @return The string representing this object.
     */
    @Override
    public String toString() {
        StringBuilder buf = new StringBuilder(64);
        buf.append("ClientRequest:{url:\"");
        buf.append(url);
        buf.append("\", file:\"");
        buf.append(file);
        buf.append("\", encoding:\"");
        buf.append(encoding);
        buf.append("\", content:\"");
        buf.append(StringUtil.shorten(content));
        buf.append("\"}");
        return buf.toString();
    }

}