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
.common
.TermBase
;
20 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
21 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
22 import eu
.etaxonomy
.cdm
.model
.name
.TypeDesignationBase
;
23 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
27 * can handle HibernateProxys
29 * @author a.kohlbecker
32 public class CdmProxyBeanProcessorMatcher
extends JsonBeanProcessorMatcher
{
34 public static final Logger logger
= Logger
.getLogger(CdmProxyBeanProcessorMatcher
.class);
37 * @see net.sf.json.processors.JsonBeanProcessorMatcher#getMatch(java.lang.Class, java.util.Set)
39 @SuppressWarnings("unchecked")
41 public Object
getMatch(Class target
, Set set
) {
44 if (HibernateProxy
.class.isAssignableFrom(target
)) {
45 if(logger
.isDebugEnabled()){
46 logger
.debug("Found HibernateProxy object of class " + target
.getClass() + " returning " + HibernateProxy
.class);
48 return HibernateProxy
.class;
50 if (Taxon
.class.isAssignableFrom(target
)) {
51 return DEFAULT
.getMatch(Taxon
.class, set
);
53 if (TaxonNameBase
.class.isAssignableFrom(target
)) {
54 return DEFAULT
.getMatch(TaxonNameBase
.class, set
);
56 if (TermBase
.class.isAssignableFrom(target
)) {
57 return DEFAULT
.getMatch(TermBase
.class, set
);
59 // if (NameRelationship.class.isAssignableFrom(target)) {
60 // return DEFAULT.getMatch(NameRelationship.class, set);
62 // if (TaxonRelationship.class.isAssignableFrom(target)) {
63 // return DEFAULT.getMatch(TaxonRelationship.class, set);
65 if (Media
.class.isAssignableFrom(target
)) {
66 return DEFAULT
.getMatch(Media
.class, set
);
68 if (Reference
.class.isAssignableFrom(target
)) {
69 return DEFAULT
.getMatch(Reference
.class, set
);
71 if (TypeDesignationBase
.class.isAssignableFrom(target
)) {
72 return DEFAULT
.getMatch(TypeDesignationBase
.class, set
);
75 return DEFAULT
.getMatch(target
, set
);