001: /**
002: * $RCSfile$
003: * $Revision: 1217 $
004: * $Date: 2005-04-11 18:11:06 -0300 (Mon, 11 Apr 2005) $
005: *
006: * Copyright (C) 1999-2006 Jive Software. All rights reserved.
007: *
008: * This software is published under the terms of the GNU Public License (GPL),
009: * a copy of which is included in this distribution.
010: */package org.jivesoftware.openfire.filetransfer;
011:
012: import org.jivesoftware.util.cache.Cacheable;
013: import org.jivesoftware.util.cache.CacheSizes;
014:
015: import java.io.Serializable;
016:
017: /**
018: * Contains all of the meta information associated with a file transfer.
019: *
020: * @author Alexander Wenckus
021: */
022: public class FileTransfer implements Cacheable, Serializable {
023: private String sessionID;
024:
025: private String initiator;
026:
027: private String target;
028:
029: private String fileName;
030:
031: private long fileSize;
032:
033: private String mimeType;
034:
035: private FileTransferProgress progress;
036:
037: public FileTransfer(String initiator, String target,
038: String sessionID, String fileName, long fileSize,
039: String mimeType) {
040: this .initiator = initiator;
041: this .target = target;
042: this .sessionID = sessionID;
043: this .fileName = fileName;
044: this .fileSize = fileSize;
045: this .mimeType = mimeType;
046: }
047:
048: public String getSessionID() {
049: return sessionID;
050: }
051:
052: public void setSessionID(String sessionID) {
053: this .sessionID = sessionID;
054: }
055:
056: public String getInitiator() {
057: return initiator;
058: }
059:
060: public void setInitiator(String initiator) {
061: this .initiator = initiator;
062: }
063:
064: public String getTarget() {
065: return target;
066: }
067:
068: public void setTarget(String target) {
069: this .target = target;
070: }
071:
072: public String getFileName() {
073: return fileName;
074: }
075:
076: public void setFileName(String fileName) {
077: this .fileName = fileName;
078: }
079:
080: public long getFileSize() {
081: return fileSize;
082: }
083:
084: public void setFileSize(long fileSize) {
085: this .fileSize = fileSize;
086: }
087:
088: public String getMimeType() {
089: return mimeType;
090: }
091:
092: public void setMimeType(String mimeType) {
093: this .mimeType = mimeType;
094: }
095:
096: public FileTransferProgress getProgress() {
097: return progress;
098: }
099:
100: public void setProgress(FileTransferProgress progress) {
101: this .progress = progress;
102: }
103:
104: public int getCachedSize() {
105: // Approximate the size of the object in bytes by calculating the size
106: // of each field.
107: int size = 0;
108: size += CacheSizes.sizeOfObject(); // overhead of object
109: size += CacheSizes.sizeOfString(initiator);
110: size += CacheSizes.sizeOfString(target);
111: size += CacheSizes.sizeOfString(sessionID);
112: size += CacheSizes.sizeOfString(fileName);
113: size += CacheSizes.sizeOfString(mimeType);
114: size += CacheSizes.sizeOfLong(); // File size
115: size += CacheSizes.sizeOfObject(); // Progress
116: return size;
117: }
118: }
|