1 21 22 27 28 package javax.mail; 29 30 import java.util.Vector ; 31 32 43 44 public class Quota { 45 46 51 public static class Resource { 52 53 public String name; 54 55 public long usage; 56 57 public long limit; 58 59 67 public Resource(String name, long usage, long limit) { 68 this.name = name; 69 this.usage = usage; 70 this.limit = limit; 71 } 72 } 73 74 77 public String quotaRoot; 78 79 82 public Quota.Resource [] resources; 83 84 90 public Quota(String quotaRoot) { 91 this.quotaRoot = quotaRoot; 92 } 93 94 100 public void setResourceLimit(String name, long limit) { 101 if (resources == null) { 102 resources = new Quota.Resource [1]; 103 resources[0] = new Quota.Resource (name, 0, limit); 104 return; 105 } 106 for (int i = 0; i < resources.length; i++) { 107 if (resources[i].name.equalsIgnoreCase(name)) { 108 resources[i].limit = limit; 109 return; 110 } 111 } 112 Quota.Resource [] ra = new Quota.Resource [resources.length + 1]; 113 System.arraycopy(resources, 0, ra, 0, resources.length); 114 ra[ra.length - 1] = new Quota.Resource (name, 0, limit); 115 resources = ra; 116 } 117 } 118 | Popular Tags |