1 13 14 19 package org.ejbca.ui.web.admin.rainterface; 20 21 import java.io.Serializable ; 22 import java.util.Vector ; 23 24 25 32 public class AddedUserMemory implements Serializable { 33 public static final int MEMORY_SIZE = 100; 36 38 41 public AddedUserMemory() { 42 memory = new Vector (); 43 } 44 45 50 public void addUser(UserView user) { 51 memory.add(user); 52 53 while (memory.size() > MEMORY_SIZE) { 54 memory.remove(0); 55 } 56 } 57 58 65 public UserView[] getUsers(int size) { 66 int endindex = memory.size() - size; 67 int tempsize = size; 68 UserView[] returnval; 69 70 if (endindex < 0) { 71 endindex = 0; 72 } 73 74 if (size > memory.size()) { 75 tempsize = memory.size(); 76 } 77 78 returnval = new UserView[tempsize]; 79 80 int j = 0; 81 82 for (int i = memory.size() - 1; i >= endindex; i--) { 83 returnval[j] = (UserView) memory.elementAt(i); 84 j++; 85 } 86 87 return returnval; 88 } 89 90 95 public void changeUser(UserView user) { 96 int i; 97 98 for (i = 0; i < memory.size(); i++) { 100 if (((UserView) memory.elementAt(i)).getUsername().equals(user.getUsername())) { 101 memory.set(i, user); 102 103 break; 104 } 105 } 106 } 107 108 private Vector memory = null; 110 } 111 | Popular Tags |