001: /*
002: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
004: *
005: * This program is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU General Public License version
007: * 2 only, as published by the Free Software Foundation.
008: *
009: * This program is distributed in the hope that it will be useful, but
010: * WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * General Public License version 2 for more details (a copy is
013: * included at /legal/license.txt).
014: *
015: * You should have received a copy of the GNU General Public License
016: * version 2 along with this work; if not, write to the Free Software
017: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
018: * 02110-1301 USA
019: *
020: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
021: * Clara, CA 95054 or visit www.sun.com if you need additional
022: * information or have any questions.
023: */
024:
025: package com.sun.jumpimpl.module.download;
026:
027: import com.sun.jump.module.download.*;
028: import java.io.IOException;
029: import java.io.InputStream;
030:
031: import java.net.URL;
032:
033: public class DownloadDestinationImpl implements JUMPDownloadDestination {
034:
035: // Begin Destination implementation
036: byte[] buffer;
037: int bufferIndex = 0;
038: JUMPDownloadDescriptor descriptor = null;
039: String jarFile = null;
040:
041: public DownloadDestinationImpl(JUMPDownloadDescriptor descriptor) {
042: this .descriptor = descriptor;
043: buffer = new byte[descriptor.getSize()];
044: }
045:
046: public byte[] getBuffer() {
047: return buffer;
048: }
049:
050: public JUMPDownloadDescriptor getDescriptor() {
051: return descriptor;
052: }
053:
054: public String getJarFile() {
055: return jarFile;
056: }
057:
058: public void acceptMimeType(String mimeType)
059: throws JUMPDownloadException {
060: trace("saying we handle mimetype " + mimeType);
061: return;
062: }
063:
064: public void start(URL sourceURL, String mimeType)
065: throws JUMPDownloadException, IOException {
066: trace("download is about to start from " + sourceURL
067: + ", of type " + mimeType);
068: return;
069: }
070:
071: public int receive(InputStream in, int desiredLength)
072: throws JUMPDownloadException, IOException {
073: trace("receiving data ");
074:
075: int numRead = in.read(buffer, bufferIndex, desiredLength);
076: if (numRead > 0) {
077: bufferIndex += numRead;
078: }
079: return numRead;
080:
081: }
082:
083: public URL finish() throws JUMPDownloadException, IOException {
084:
085: trace("download succeeded. save the results");
086:
087: return null;
088: }
089:
090: public void abort() {
091: trace("download aborted");
092: return;
093: }
094:
095: public int getMaxChunkSize() {
096: trace("saying we'll take any chunksize");
097: return 0;
098: }
099:
100: static void trace(String s) {
101: if (false) {
102: System.out.println(s);
103: }
104: return;
105: }
106: // End Destination implementation
107:
108: }
|