1
2
3
4
5
6
7
8 package it.imolinfo.jbi4ejb.runtime;
9
10 import it.imolinfo.jbi4ejb.Logger;
11 import it.imolinfo.jbi4ejb.LoggerFactory;
12
13 import javax.xml.namespace.QName;
14
15 import org.codehaus.xfire.MessageContext;
16 import org.codehaus.xfire.aegis.MessageReader;
17 import org.codehaus.xfire.aegis.MessageWriter;
18 import org.codehaus.xfire.aegis.type.Type;
19 import org.codehaus.xfire.fault.XFireFault;
20
21
22
23
24 public class ByteType extends Type {
25
26
27
28
29 private static final Logger LOG = LoggerFactory.getLogger(ByteType.class);
30
31
32
33
34
35
36 public ByteType() {
37 setNillable(true);
38 setSchemaType(new QName("http://www.w3.org/2001/XMLSchema","byte"));
39 setTypeClass(byte.class);
40 }
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 public Object readObject(MessageReader reader, MessageContext context)
62 throws XFireFault {
63
64 LOG.debug(">>>>> ByteType.readObject - begin:" + reader.getValue());
65
66 String value = reader.getValue();
67
68 if (value == null || "".equals(value)){
69 LOG.debug("<<<<< ByteType.readObject - end: the value is null.");
70 return null;
71 }
72
73 LOG.debug("<<<<< ByteType.readObject - end: the value is " + value);
74 return new Byte(value);
75 }
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95 public void writeObject(Object object,
96 MessageWriter writer,
97 MessageContext context) throws XFireFault {
98 String objectString = "";
99 if (object != null) {
100 objectString = object.toString();
101 }
102
103 if (LOG.isDebugEnabled()) {
104 String debugMsg = ">>>>> ByteType.writeObject - begin: object=" + object
105 + "; class=" + objectString;
106 LOG.debug(debugMsg);
107 }
108
109 writer.writeValue(objectString);
110
111 LOG.debug("<<<<< ByteType.writeObject - end");
112 }
113
114 }