1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.apache.xmlrpc.serializer; |
17 |
|
|
18 |
|
import org.xml.sax.Attributes; |
19 |
|
import org.xml.sax.ContentHandler; |
20 |
|
import org.xml.sax.SAXException; |
21 |
|
import org.xml.sax.helpers.AttributesImpl; |
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
110 |
public abstract class TypeSerializerImpl implements TypeSerializer { |
27 |
1 |
protected static final Attributes ZERO_ATTRIBUTES = new AttributesImpl(); |
28 |
|
|
29 |
|
|
30 |
|
public static final String VALUE_TAG = "value"; |
31 |
|
|
32 |
|
protected void write(ContentHandler pHandler, String pTagName, String pValue) throws SAXException { |
33 |
507 |
write(pHandler, pTagName, pValue.toCharArray()); |
34 |
507 |
} |
35 |
|
|
36 |
|
protected void write(ContentHandler pHandler, String pTagName, char[] pValue) throws SAXException { |
37 |
507 |
pHandler.startElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG, ZERO_ATTRIBUTES); |
38 |
507 |
if (pTagName != null) { |
39 |
395 |
pHandler.startElement("", pTagName, pTagName, ZERO_ATTRIBUTES); |
40 |
|
} |
41 |
507 |
pHandler.characters(pValue, 0, pValue.length); |
42 |
507 |
if (pTagName != null) { |
43 |
395 |
pHandler.endElement("", pTagName, pTagName); |
44 |
|
} |
45 |
507 |
pHandler.endElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG); |
46 |
507 |
} |
47 |
|
|
48 |
|
protected void write(ContentHandler pHandler, String pLocalName, String pQName, |
49 |
|
String pValue) throws SAXException { |
50 |
129 |
pHandler.startElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG, ZERO_ATTRIBUTES); |
51 |
129 |
pHandler.startElement(XmlRpcWriter.EXTENSIONS_URI, pLocalName, pQName, ZERO_ATTRIBUTES); |
52 |
129 |
char[] value = pValue.toCharArray(); |
53 |
129 |
pHandler.characters(value, 0, value.length); |
54 |
129 |
pHandler.endElement(XmlRpcWriter.EXTENSIONS_URI, pLocalName, pQName); |
55 |
129 |
pHandler.endElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG); |
56 |
129 |
} |
57 |
|
} |