3 * Copyright (C) 2009 EDIT European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.remote
.json
.processor
.matcher
;
14 import net
.sf
.json
.processors
.JsonBeanProcessorMatcher
;
16 import org
.apache
.log4j
.Logger
;
17 import org
.hibernate
.proxy
.HibernateProxy
;
19 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
20 import eu
.etaxonomy
.cdm
.model
.common
.TermBase
;
21 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
22 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
23 import eu
.etaxonomy
.cdm
.model
.name
.TypeDesignationBase
;
24 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
28 * can handle HibernateProxys
30 * @author a.kohlbecker
33 public class CdmProxyBeanProcessorMatcher
extends JsonBeanProcessorMatcher
{
35 public static final Logger logger
= Logger
.getLogger(CdmProxyBeanProcessorMatcher
.class);
38 * @see net.sf.json.processors.JsonBeanProcessorMatcher#getMatch(java.lang.Class, java.util.Set)
40 @SuppressWarnings("unchecked")
42 public Object
getMatch(Class target
, Set set
) {
45 if (HibernateProxy
.class.isAssignableFrom(target
)) {
46 if(logger
.isDebugEnabled()){
47 logger
.debug("Found HibernateProxy object of class " + target
.getClass() + " returning " + HibernateProxy
.class);
49 return HibernateProxy
.class;
51 if (Taxon
.class.isAssignableFrom(target
)) {
52 return DEFAULT
.getMatch(Taxon
.class, set
);
54 if (TaxonNameBase
.class.isAssignableFrom(target
)) {
55 return DEFAULT
.getMatch(TaxonNameBase
.class, set
);
57 if (TermBase
.class.isAssignableFrom(target
)) {
58 return DEFAULT
.getMatch(TermBase
.class, set
);
60 if (TeamOrPersonBase
.class.isAssignableFrom(target
)) {
61 return DEFAULT
.getMatch(TeamOrPersonBase
.class, set
);
63 if (Media
.class.isAssignableFrom(target
)) {
64 return DEFAULT
.getMatch(Media
.class, set
);
66 if (Reference
.class.isAssignableFrom(target
)) {
67 return DEFAULT
.getMatch(Reference
.class, set
);
69 if (TypeDesignationBase
.class.isAssignableFrom(target
)) {
70 return DEFAULT
.getMatch(TypeDesignationBase
.class, set
);
73 return DEFAULT
.getMatch(target
, set
);