dangsn
2024-12-26 4e9ff2ce6a830bb2340d7c8612c72eea0c5a553e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package com.vci.client.volumn;
 
/**
 * <p>Title: </p>
 * <p>Description: 记录文件传输过程中的一些参数</p>
 * <p>Copyright: Copyright (c) 2011</p>
 * <p>Company: VCI</p>
 * @author Administrator
 * @time 2011-7-3
 * @version 1.0
 */
public class TransFileInfo {
 
    private static long totalSendedSize = 0;//已经发送了多少字节.
    private static Object synObject1 = new Object();
 
    private static long totalSendedTime = 0;//发送花了多少时间 单位为毫秒.
    private static Object synObject2 = new Object();
 
    private static long totalReceivedSize = 0;//已经接收了多少字节.
    private static Object synObject3 = new Object();
 
    private static long totalReceivedTime = 0;//接收花了多少时间 单位为毫秒.
    private static Object synObject4 = new Object();
 
    private static long totalFileNum = 0;//总文件数
    private static long currentFileNum = 0;//当前传输的第多少个文件
    private static String filePath = "";//文件路径
    private static long fileLength = 0;//文件长度
    
    public static void setFileLength(long length){
        fileLength = length;
    }
    
    public static long getFileLength(){
        return fileLength;
    }
 
    public static void setFilePath(String path){
        filePath = path;
    }
    
    public static String getFilePath(){
        return filePath;
    }
    
    public static void setTotalFileNum(long fileNum) {
        totalFileNum = fileNum;
    }
    
    public static long getTotalFileNum() {
        return totalFileNum;
    }
    
    public static void startCurrentFileTrans() {
        currentFileNum ++;
        if(currentFileNum >= totalFileNum){
            currentFileNum = totalFileNum;
        }
    }
    
    public static void setCurrentFileTrans(long curNum){
        currentFileNum = curNum;
    }
 
    public static long getCurrentFileNum() {
        return currentFileNum;
    }
    public static void setTotalReceivedTime(long receivedTime) {
        synchronized (synObject4) {
            totalReceivedTime += receivedTime;
        }
    }
 
    public static long getTotalReceivedTime() {
        synchronized (synObject4) {
            return totalReceivedTime;
        }
    }
 
    public static void setTotalReceivedSize(long receivedSize) {
        synchronized (synObject3) {
            totalReceivedSize += receivedSize;
        }
    }
 
    public static long getTotalReceivedSize() {
        synchronized (synObject3) {
            return totalReceivedSize;
        }
    }
 
    public static void setTotalSendedSize(long sendedSize) {
        synchronized (synObject1) {
            totalSendedSize += sendedSize;
        }
    }
 
    public static long getTotalSendedSize() {
        synchronized (synObject1) {
            return totalSendedSize;
        }
    }
 
    public static void setTotalSendedTime(long sendedTime) {
        synchronized (synObject2) {
            totalSendedTime += sendedTime;
        }
    }
 
    public static long getTotalSendedTime() {
        synchronized (synObject2) {
            return totalSendedTime;
        }
    }
    
    /**
     * 清空上次传输的数据
     */
    public static void clearSendedData() {
        totalReceivedSize = 0;
        totalSendedSize = 0;
        filePath = "";
        fileLength = 0;
    }
}