001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.data.imagery;
003
004import java.util.Collections;
005import java.util.Map;
006
007/**
008 * Class containing all options that are passed from Layer to TileJob
009 *
010 * @author Wiktor Niesiobedzki
011 * @since 13733
012 */
013public class TileJobOptions {
014
015    final int connectTimeout;
016    final int readTimeout;
017    final Map<String, String> headers;
018    final long minimumExpiryTime;
019
020    /**
021     * Options constructor
022     *
023     * @param connectTimeout in milliseconds
024     * @param readTimeout in milliseconds
025     * @param headers http headers
026     * @param minimumExpiryTime in seconds
027     */
028    public TileJobOptions(int connectTimeout, int readTimeout, Map<String, String> headers, long minimumExpiryTime) {
029        this.connectTimeout = connectTimeout;
030        this.readTimeout = readTimeout;
031        this.headers = Collections.unmodifiableMap(headers == null ? Collections.emptyMap() : headers);
032        this.minimumExpiryTime = minimumExpiryTime;
033    }
034
035    /**
036     * Returns socket connection timeout in milliseconds.
037     * @return socket connection timeout in milliseconds
038     */
039    public int getConnectionTimeout() {
040        return connectTimeout;
041    }
042
043    /**
044     * Returns socket read timeout in milliseconds.
045     * @return socket read timeout in milliseconds
046     */
047    public int getReadTimeout() {
048        return readTimeout;
049    }
050
051    /**
052     * Returns unmodifiable map with headers to be sent to tile server.
053     * @return unmodifiable map with headers to be sent to tile server
054     */
055    public Map<String, String> getHeaders() {
056        return headers;
057    }
058
059    /**
060     * Returns minimum cache expire time in seconds for downloaded tiles.
061     * @return minimum cache expire time in seconds for downloaded tiles
062     */
063    public long getMinimumExpiryTime() {
064        return minimumExpiryTime;
065    }
066}