Revision 023f6f1e src/gr/ebs/gss/server/domain/dto/StatsDTO.java

b/src/gr/ebs/gss/server/domain/dto/StatsDTO.java
33 33
	private Long fileCount = 0L;
34 34
	private Long fileSize = 0L;
35 35
	private Long quotaLeftSize = 0L;
36
	private Long bandwithQuotaUsed=0L;
36 37

  
37 38
	public StatsDTO() {
38 39

  
......
98 99
		quotaLeftSize = aQuotaLeftSize;
99 100
	}
100 101

  
102

  
103

  
104
	/**
105
	 * Retrieve the bandwithQuotaUsed.
106
	 *
107
	 * @return the bandwithQuotaUsed
108
	 */
109
	public Long getBandwithQuotaUsed() {
110
		return bandwithQuotaUsed;
111
	}
112

  
113

  
114
	/**
115
	 * Modify the bandwithQuotaUsed.
116
	 *
117
	 * @param aBandwithQuotaUsed the bandwithQuotaUsed to set
118
	 */
119
	public void setBandwithQuotaUsed(Long aBandwithQuotaUsed) {
120
		bandwithQuotaUsed = aBandwithQuotaUsed;
121
	}
122

  
101 123
	public String getFileSizeAsString() {
102 124
		if (fileSize < 1024)
103 125
			return String.valueOf(fileSize) + " B";
......
118 140
		return getSize(quotaLeftSize , (1024D*1024D*1024D)) + " GB";
119 141
	}
120 142

  
143
	public String getBandwithQuotaUsedAsString() {
144
		if (bandwithQuotaUsed < 1024)
145
			return String.valueOf(bandwithQuotaUsed) + " B";
146
		else if (bandwithQuotaUsed <= 1024*1024)
147
			return getSize(bandwithQuotaUsed, 1024D) + " KB";
148
		else if (bandwithQuotaUsed <= 1024*1024*1024)
149
			return getSize(bandwithQuotaUsed,(1024D*1024D)) + " MB";
150
		return getSize(bandwithQuotaUsed , (1024D*1024D*1024D)) + " GB";
151
	}
152

  
121 153
	private String getSize(Long size, Double division){
122 154
		Double res = Double.valueOf(size.toString())/division;
123 155
		NumberFormat nf = NumberFormat.getFormat("######.#");
......
127 159
	public long percentOfFreeSpace(){
128 160
		return quotaLeftSize*100/(fileSize+quotaLeftSize);
129 161
	}
130

  
131 162
}

Also available in: Unified diff