001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU General
007: * Public License Version 2 only ("GPL") or the Common Development and Distribution
008: * License("CDDL") (collectively, the "License"). You may not use this file except in
009: * compliance with the License. You can obtain a copy of the License at
010: * http://www.netbeans.org/cddl-gplv2.html or nbbuild/licenses/CDDL-GPL-2-CP. See the
011: * License for the specific language governing permissions and limitations under the
012: * License. When distributing the software, include this License Header Notice in
013: * each file and include the License file at nbbuild/licenses/CDDL-GPL-2-CP. Sun
014: * designates this particular file as subject to the "Classpath" exception as
015: * provided by Sun in the GPL Version 2 section of the License file that
016: * accompanied this code. If applicable, add the following below the License Header,
017: * with the fields enclosed by brackets [] replaced by your own identifying
018: * information: "Portions Copyrighted [year] [name of copyright owner]"
019: *
020: * Contributor(s):
021: *
022: * The Original Software is NetBeans. The Initial Developer of the Original Software
023: * is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun Microsystems, Inc. All
024: * Rights Reserved.
025: *
026: * If you wish your version of this file to be governed by only the CDDL or only the
027: * GPL Version 2, indicate your decision by adding "[Contributor] elects to include
028: * this software in this distribution under the [CDDL or GPL Version 2] license." If
029: * you do not indicate a single choice of license, a recipient has the option to
030: * distribute your version of this file under either the CDDL, the GPL Version 2 or
031: * to extend the choice of license to its licensees as provided above. However, if
032: * you add GPL Version 2 code and therefore, elected the GPL Version 2 license, then
033: * the option applies only if the new code is made subject to such option by the
034: * copyright holder.
035: */
036:
037: package org.netbeans.installer.sandbox.download;
038:
039: import java.util.Properties;
040:
041: /**
042: *
043: * @author Kirill Sorokin
044: */
045: public class DownloadOptions {
046: /////////////////////////////////////////////////////////////////////////////////
047: // Constants
048: // Pre download conditions
049: public static final String CHECK_EXISTANCE = "check.existance";
050: public static final String CHECK_SIZE = "check.size";
051: public static final String CHECK_LAST_MODIFIED = "check.last.modified";
052: public static final String CHECK_MD5 = "check.md5";
053: public static final String CHECK_CRC = "check.crc";
054:
055: // Post download conditions
056: public static final String VERIFY_MD5 = "verify.md5";
057: public static final String VERIFY_CRC = "verify.crc";
058:
059: public static final String MD5_SUM = "md5.sum";
060: public static final String CRC_SUM = "crc.sum";
061:
062: public static final String CLASSLOADER = "classloader";
063:
064: public static final String CACHING_ENABLED = "caching.enabled";
065:
066: public static final String IGNORE_PROXIES = "ignore.proxies";
067:
068: public static final String USERNAME = "username";
069: public static final String PASSWORD = "password";
070:
071: public static final String MAX_THREADS = "max.threads";
072:
073: public static final String MAX_ERRORS = "max.errors";
074:
075: public static final String MAX_SPEED = "max.speed";
076:
077: // defaults
078: public static final boolean DEFAULT_BOOLEAN = false;
079: public static final int DEFAULT_INT = 0;
080:
081: /////////////////////////////////////////////////////////////////////////////////
082: // Static
083: public static DownloadOptions getDefaults() {
084: DownloadOptions options = new DownloadOptions();
085:
086: options.put(CHECK_EXISTANCE, true);
087: options.put(CHECK_SIZE, true);
088: options.put(CHECK_LAST_MODIFIED, true);
089:
090: options.put(VERIFY_MD5, true);
091: options.put(VERIFY_CRC, true);
092:
093: options.put(CACHING_ENABLED, true);
094:
095: options.put(MAX_THREADS, 5);
096: options.put(MAX_ERRORS, 25);
097:
098: options.put(MAX_SPEED, -1);
099:
100: return options;
101: }
102:
103: /////////////////////////////////////////////////////////////////////////////////
104: // Instance
105: private Properties properties = new Properties();
106:
107: private DownloadOptions() {
108: }
109:
110: public void put(String name, Object value) {
111: properties.put(name, value);
112: }
113:
114: public Object get(String name) {
115: return properties.get(name);
116: }
117:
118: public boolean getBoolean(String name) {
119: Object value = get(name);
120:
121: if (value instanceof Boolean) {
122: return (Boolean) value;
123: } else {
124: return false;
125: }
126: }
127:
128: public int getInt(String name) {
129: Object value = get(name);
130:
131: if (value instanceof Integer) {
132: return (Integer) value;
133: } else {
134: return 0;
135: }
136: }
137:
138: public String getString(String name) {
139: Object value = get(name);
140:
141: if (value instanceof String) {
142: return (String) value;
143: } else {
144: return null;
145: }
146: }
147: }
|