|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
MetadataDeserializerFactory.java | 0% | 0% | 0% | 0% |
|
1 |
package org.codehaus.ivory.serialize;
|
|
2 |
|
|
3 |
import java.util.HashMap;
|
|
4 |
import java.util.Map;
|
|
5 |
|
|
6 |
import javax.xml.namespace.QName;
|
|
7 |
|
|
8 |
import org.apache.axis.description.TypeDesc;
|
|
9 |
import org.apache.axis.encoding.Deserializer;
|
|
10 |
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
|
|
11 |
import org.apache.axis.encoding.ser.EnumSerializer;
|
|
12 |
import org.apache.axis.utils.BeanPropertyDescriptor;
|
|
13 |
|
|
14 |
/**
|
|
15 |
* DeserializerFactory which uses MetaBeanUtils.
|
|
16 |
*
|
|
17 |
* @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
|
|
18 |
* @since May 21, 2003
|
|
19 |
*/
|
|
20 |
public class MetadataDeserializerFactory extends BeanDeserializerFactory |
|
21 |
{ |
|
22 |
|
|
23 | 0 |
public MetadataDeserializerFactory(Class javaType, QName xmlType)
|
24 |
{ |
|
25 | 0 |
super(javaType, xmlType);
|
26 |
} |
|
27 |
|
|
28 |
/**
|
|
29 |
* Get a list of the bean properties
|
|
30 |
*/
|
|
31 | 0 |
public static Map getProperties(Class javaType, TypeDesc typeDesc) |
32 |
{ |
|
33 | 0 |
Map propertyMap = null;
|
34 |
|
|
35 | 0 |
if (typeDesc != null) |
36 |
{ |
|
37 | 0 |
propertyMap = typeDesc.getPropertyDescriptorMap(); |
38 |
} |
|
39 |
else
|
|
40 |
{ |
|
41 | 0 |
BeanPropertyDescriptor[] pd = MetaBeanUtils.getPd(javaType, null);
|
42 | 0 |
propertyMap = new HashMap();
|
43 |
// loop through properties and grab the names for later
|
|
44 | 0 |
for (int i = 0; i < pd.length; i++) |
45 |
{ |
|
46 | 0 |
BeanPropertyDescriptor descriptor = pd[i]; |
47 | 0 |
propertyMap.put(descriptor.getName(), descriptor); |
48 |
} |
|
49 |
} |
|
50 |
|
|
51 | 0 |
return propertyMap;
|
52 |
} |
|
53 |
/**
|
|
54 |
* Optimize construction of a BeanDeserializer by caching the
|
|
55 |
* type descriptor and property map.
|
|
56 |
*/
|
|
57 | 0 |
protected Deserializer getGeneralPurpose(String mechanismType)
|
58 |
{ |
|
59 | 0 |
if (javaType == null || xmlType == null) |
60 |
{ |
|
61 | 0 |
return super.getGeneralPurpose(mechanismType); |
62 |
} |
|
63 |
|
|
64 | 0 |
if (deserClass == EnumSerializer.class) |
65 |
{ |
|
66 | 0 |
return super.getGeneralPurpose(mechanismType); |
67 |
} |
|
68 |
|
|
69 | 0 |
return new MetadataDeserializer( |
70 |
javaType, |
|
71 |
xmlType, |
|
72 |
typeDesc, |
|
73 |
propertyMap); |
|
74 |
} |
|
75 |
|
|
76 |
} |
|
77 |
|
|