]> git.argeo.org Git - lgpl/argeo-commons.git/blob - eclipse/rap/org.eclipse.rwt.widgets.upload/src/org/eclipse/rwt/widgets/upload/servlet/FileUploadStorageItem.java
4434b42d4a3a3cdb59146b0bf31c4b624e8151b2
[lgpl/argeo-commons.git] / eclipse / rap / org.eclipse.rwt.widgets.upload / src / org / eclipse / rwt / widgets / upload / servlet / FileUploadStorageItem.java
1 /*******************************************************************************
2 * Copyright (c) 2002-2006 Innoopract Informationssysteme GmbH.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Innoopract Informationssysteme GmbH - initial API and implementation
10 ******************************************************************************/
11
12 package org.eclipse.rwt.widgets.upload.servlet;
13
14 import java.io.InputStream;
15
16
17 /**
18 * This Pojo is used to store a file reference and a progress listener.
19 * It is used for communication between service handler and rap application.
20 * Due to the asynchronous nature of ServiceHandler-requests and access from
21 * the UIThread to instances of this class, all members are access
22 * synchronized.
23 *
24 * @author stefan.roeck
25 */
26 public class FileUploadStorageItem {
27 private InputStream fileInputStream;
28 private String contentType;
29 private String uploadProcessId;
30 private long bytesRead;
31 private long contentLength;
32 private Exception exception;
33
34
35 public FileUploadStorageItem() {
36 reset();
37 }
38
39 public synchronized InputStream getFileInputStream() {
40 return this.fileInputStream;
41 }
42
43 public synchronized void setFileInputStream( final InputStream fileInputStream ) {
44 this.fileInputStream = fileInputStream;
45 }
46
47 public synchronized void setContentType( final String contentType ) {
48 this.contentType = contentType;
49 }
50
51 public synchronized String getContentType() {
52 return this.contentType;
53 }
54
55 public synchronized void setUploadProcessId( final String uploadProcessId ) {
56 this.uploadProcessId = uploadProcessId;
57 }
58
59 public synchronized String getUploadProcessId() {
60 return this.uploadProcessId;
61 }
62
63 public synchronized void updateProgress(final long bytesRead, final long contentLength) {
64 this.bytesRead = bytesRead;
65 this.contentLength = contentLength;
66 }
67
68 public synchronized long getBytesRead() {
69 return bytesRead;
70 }
71
72 public synchronized long getContentLength() {
73 return contentLength;
74 }
75
76 public synchronized void reset() {
77 contentLength = -1;
78 bytesRead = -1;
79 contentType = null;
80 fileInputStream = null;
81 exception = null;
82 }
83
84 public synchronized void setException( Exception e ) {
85 this.exception = e;
86 }
87
88 public synchronized Exception getException() {
89 return exception;
90 }
91 }