KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > mapper > Mapper


1 /*
2 *
3 * Mapper.java -
4 * Copyright (C) 2003 Ecoo Team
5 * charoy@loria.fr
6 *
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */

22
23 package hero.mapper;
24
25 import hero.interfaces.BnRoleLocal;
26 import hero.util.HeroException;
27 import java.io.Serializable JavaDoc;
28 import java.util.Collection JavaDoc;
29
30 public abstract class Mapper implements Serializable JavaDoc{
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 JavaDoc name;
38     private int type;
39
40     public static Mapper make(String JavaDoc 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 JavaDoc name, int type) {
49     this.name=name;
50     this.type=type;
51     }
52
53     public String JavaDoc getName() {return this.name;}
54     public void setName(String JavaDoc 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 JavaDoc toXML() {
60     String JavaDoc result=new String JavaDoc();
61     result="<mapper name=\""+this.getName()+
62         "\" type=\""+this.getType()+"\"/>";
63     return result;
64     }
65
66     public abstract Collection JavaDoc execute(Object JavaDoc bean, int type, BnRoleLocal role, String JavaDoc userName) throws HeroException;
67
68 }
69
Popular Tags