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 04. June 2006 by Mauro Talevi
11: */
12: package com.thoughtworks.xstream.io.xml;
13:
14: import com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter;
15: import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
16:
17: /**
18: * Abstract base implementation of HierarchicalStreamWriter that provides common functionality
19: * to all XML-based writers.
20: *
21: * @author Mauro Talevi
22: * @since 1.2
23: */
24: public abstract class AbstractXmlWriter implements
25: ExtendedHierarchicalStreamWriter, XmlFriendlyWriter {
26:
27: private XmlFriendlyReplacer replacer;
28:
29: protected AbstractXmlWriter() {
30: this (new XmlFriendlyReplacer());
31: }
32:
33: protected AbstractXmlWriter(XmlFriendlyReplacer replacer) {
34: this .replacer = replacer;
35: }
36:
37: public void startNode(String name, Class clazz) {
38: startNode(name);
39: }
40:
41: /**
42: * Escapes XML name (node or attribute) to be XML-friendly
43: *
44: * @param name the unescaped XML name
45: * @return An escaped name with original characters replaced
46: */
47: public String escapeXmlName(String name) {
48: return replacer.escapeName(name);
49: }
50:
51: public HierarchicalStreamWriter underlyingWriter() {
52: return this;
53: }
54:
55: }
|