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 org
.apache
.log4j
.Logger
;
15 import org
.hibernate
.proxy
.HibernateProxy
;
17 import net
.sf
.json
.processors
.JsonBeanProcessorMatcher
;
18 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
19 import eu
.etaxonomy
.cdm
.model
.common
.OrderedTermBase
;
20 import eu
.etaxonomy
.cdm
.model
.common
.TermBase
;
21 import eu
.etaxonomy
.cdm
.model
.description
.FeatureNode
;
22 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
23 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
24 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
25 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
26 import eu
.etaxonomy
.cdm
.model
.name
.TypeDesignationBase
;
27 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
28 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
32 * can handle HibernateProxys
34 * @author a.kohlbecker
37 public class CdmProxyBeanProcessorMatcher
extends JsonBeanProcessorMatcher
{
39 public static final Logger logger
= Logger
.getLogger(CdmProxyBeanProcessorMatcher
.class);
42 * @see net.sf.json.processors.JsonBeanProcessorMatcher#getMatch(java.lang.Class, java.util.Set)
44 @SuppressWarnings("unchecked")
46 public Object
getMatch(Class target
, Set set
) {
49 if (HibernateProxy
.class.isAssignableFrom(target
)) {
50 if(logger
.isDebugEnabled()){
51 logger
.debug("Found HibernateProxy object of class " + target
.getClass() + " returning " + HibernateProxy
.class);
53 return HibernateProxy
.class;
55 if (Taxon
.class.isAssignableFrom(target
)) {
56 return DEFAULT
.getMatch(Taxon
.class, set
);
58 if (TaxonNameBase
.class.isAssignableFrom(target
)) {
59 return DEFAULT
.getMatch(TaxonNameBase
.class, set
);
61 if (TermBase
.class.isAssignableFrom(target
)) {
62 return DEFAULT
.getMatch(TermBase
.class, set
);
64 // if (NameRelationship.class.isAssignableFrom(target)) {
65 // return DEFAULT.getMatch(NameRelationship.class, set);
67 // if (TaxonRelationship.class.isAssignableFrom(target)) {
68 // return DEFAULT.getMatch(TaxonRelationship.class, set);
70 if (Media
.class.isAssignableFrom(target
)) {
71 return DEFAULT
.getMatch(Media
.class, set
);
73 if (ReferenceBase
.class.isAssignableFrom(target
)) {
74 return DEFAULT
.getMatch(ReferenceBase
.class, set
);
76 if (TypeDesignationBase
.class.isAssignableFrom(target
)) {
77 return DEFAULT
.getMatch(TypeDesignationBase
.class, set
);
80 return DEFAULT
.getMatch(target
, set
);