1 22 23 package hero.mapper; 24 25 import hero.interfaces.BnRoleLocal; 26 import hero.util.HeroException; 27 import java.io.Serializable ; 28 import java.util.Collection ; 29 30 public abstract class Mapper implements Serializable { 31 32 33 public static final int LDAP=0; 34 public static final int PROPERTIES=1; 35 public static final int CUSTOM=2; 36 37 private String name; 38 private int type; 39 40 public static Mapper make(String name, int type) throws HeroException { 41 if (type==LDAP) {return new LdapMapper(name,type);} 42 if (type==PROPERTIES) {return new PropertiesMapper(name,type);} 43 if (type==CUSTOM) {return new CustomMapper(name,type);} 44 45 throw new HeroException("Wrong Mapper Type " + type); 46 } 47 48 protected Mapper(String name, int type) { 49 this.name=name; 50 this.type=type; 51 } 52 53 public String getName() {return this.name;} 54 public void setName(String name) {this.name=name;} 55 56 public int getType() {return this.type;} 57 public void setType(int type) {this.type=type;} 58 59 public String toXML() { 60 String result=new String (); 61 result="<mapper name=\""+this.getName()+ 62 "\" type=\""+this.getType()+"\"/>"; 63 return result; 64 } 65 66 public abstract Collection execute(Object bean, int type, BnRoleLocal role, String userName) throws HeroException; 67 68 } 69 | Popular Tags |