01: /*
02: * Copyright (C) 2006 Joe Walnes.
03: * Copyright (C) 2006, 2007 XStream Committers.
04: * All rights reserved.
05: *
06: * The software in this package is published under the terms of the BSD
07: * style license a copy of which has been included with this distribution in
08: * the LICENSE.txt file.
09: *
10: * Created on 03. May 2006 by Mauro Talevi
11: */
12: package com.thoughtworks.xstream.mapper;
13:
14: /**
15: * Mapper that ensures that all names in the serialization stream are read in an XML friendly way.
16: * <ul>
17: * <li><b>_</b> (underscore) chars appearing in class names are replaced with <b>$<br> (dollar)</li>
18: * <li><b>_DOLLAR_</b> string appearing in field names are replaced with <b>$<br> (dollar)</li>
19: * <li><b>__</b> string appearing in field names are replaced with <b>_<br> (underscore)</li>
20: * <li><b>default</b> is the prefix for class names with no package.</li>
21: * </ul>
22: *
23: * @author Joe Walnes
24: * @author Mauro Talevi
25: */
26: public class XStream11XmlFriendlyMapper extends
27: AbstractXmlFriendlyMapper {
28:
29: public XStream11XmlFriendlyMapper(Mapper wrapped) {
30: super (wrapped);
31: }
32:
33: public Class realClass(String elementName) {
34: return super .realClass(unescapeClassName(elementName));
35: }
36:
37: public String realMember(Class type, String serialized) {
38: return unescapeFieldName(super .realMember(type, serialized));
39: }
40:
41: public String mapNameFromXML(String xmlName) {
42: return unescapeFieldName(xmlName);
43: }
44:
45: }
|