|
|||||||||||||||||||
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 | |||||||||||||||
MetadataSerializerFactory.java | 0% | 0% | 0% | 0% |
|
1 |
package org.codehaus.ivory.serialize;
|
|
2 |
|
|
3 |
import javax.xml.namespace.QName;
|
|
4 |
import javax.xml.rpc.JAXRPCException;
|
|
5 |
|
|
6 |
import org.apache.axis.description.TypeDesc;
|
|
7 |
import org.apache.axis.encoding.Serializer;
|
|
8 |
import org.apache.axis.encoding.ser.BaseSerializerFactory;
|
|
9 |
import org.apache.axis.encoding.ser.EnumSerializer;
|
|
10 |
import org.apache.axis.utils.BeanPropertyDescriptor;
|
|
11 |
import org.apache.axis.utils.JavaUtils;
|
|
12 |
|
|
13 |
/**
|
|
14 |
* @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
|
|
15 |
* @since May 21, 2003
|
|
16 |
*/
|
|
17 |
public class MetadataSerializerFactory extends BaseSerializerFactory |
|
18 |
{ |
|
19 |
protected TypeDesc typeDesc = null; |
|
20 |
protected BeanPropertyDescriptor[] propertyDescriptor = null; |
|
21 |
|
|
22 | 0 |
public MetadataSerializerFactory(Class javaType, QName xmlType)
|
23 |
{ |
|
24 | 0 |
super(MetadataSerializer.class, xmlType, javaType); |
25 |
// Sometimes an Enumeration class is registered as a Bean.
|
|
26 |
// If this is the case, silently switch to the EnumSerializer
|
|
27 | 0 |
if (JavaUtils.isEnumClass(javaType))
|
28 |
{ |
|
29 | 0 |
serClass = EnumSerializer.class;
|
30 |
} |
|
31 |
|
|
32 | 0 |
typeDesc = TypeDesc.getTypeDescForClass(javaType); |
33 |
|
|
34 | 0 |
if (typeDesc != null) |
35 |
{ |
|
36 | 0 |
propertyDescriptor = typeDesc.getPropertyDescriptors(); |
37 |
} |
|
38 |
else
|
|
39 |
{ |
|
40 | 0 |
propertyDescriptor = MetaBeanUtils.getPd(javaType, null);
|
41 |
} |
|
42 |
} |
|
43 |
|
|
44 | 0 |
public javax.xml.rpc.encoding.Serializer getSerializerAs(
|
45 |
String mechanismType) |
|
46 |
throws JAXRPCException
|
|
47 |
{ |
|
48 | 0 |
return (Serializer) super.getSerializerAs(mechanismType); |
49 |
} |
|
50 |
|
|
51 |
/**
|
|
52 |
* Optimize construction of a BeanSerializer by caching the
|
|
53 |
* type and property descriptors.
|
|
54 |
*/
|
|
55 | 0 |
protected Serializer getGeneralPurpose(String mechanismType)
|
56 |
{ |
|
57 | 0 |
if (javaType == null || xmlType == null) |
58 |
{ |
|
59 | 0 |
return super.getGeneralPurpose(mechanismType); |
60 |
} |
|
61 |
|
|
62 | 0 |
if (serClass == EnumSerializer.class) |
63 |
{ |
|
64 | 0 |
return super.getGeneralPurpose(mechanismType); |
65 |
} |
|
66 |
|
|
67 | 0 |
return new MetadataSerializer( |
68 |
javaType, |
|
69 |
xmlType, |
|
70 |
typeDesc, |
|
71 |
propertyDescriptor); |
|
72 |
} |
|
73 |
} |
|
74 |
|
|