1 16 package org.apache.cocoon.portal.tools.model; 17 18 import java.util.ArrayList ; 19 import java.util.Iterator ; 20 21 25 public class User { 26 27 private String name; 28 private ArrayList roles = new ArrayList (); 29 30 public User(String name, String role) { 31 this.name = name; 32 this.roles.add(role); 33 } 34 35 public User(String name, ArrayList roles) { 36 this.name = name; 37 this.roles = roles; 38 } 39 40 public User(String name, String [] roles) { 41 this.name = name; 42 for(int i = 0; i < roles.length; i++) { 43 this.roles.add(roles[i]); 44 } 45 } 46 47 48 public String getName() { 49 return this.name; 50 } 51 52 public void setName(String name) { 53 this.name = name; 54 } 55 56 public ArrayList getRoles() { 57 return this.roles; 58 } 59 60 public boolean hasRole(String role) { 61 for(Iterator it = roles.iterator(); it.hasNext();) { 62 if(((String ) it.next()).equals(role)) { 63 return true; 64 } 65 } 66 return false; 67 } 68 69 } 70 | Popular Tags |