View Javadoc

1   /*
2    * Copyright 2006-2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.batch.item.xml.stax;
18  
19  import javax.xml.namespace.NamespaceContext;
20  import javax.xml.stream.XMLEventReader;
21  import javax.xml.stream.XMLEventWriter;
22  import javax.xml.stream.XMLStreamException;
23  import javax.xml.stream.events.XMLEvent;
24  
25  /**
26   * Delegates all functionality to the wrapped writer allowing
27   * subclasses to override only the methods they want to change.
28   * 
29   * @author Robert Kasanicky
30   */
31  abstract class AbstractEventWriterWrapper implements XMLEventWriter {
32  	
33  	protected XMLEventWriter wrappedEventWriter;
34  
35  	public AbstractEventWriterWrapper(XMLEventWriter wrappedEventWriter) {
36  		this.wrappedEventWriter = wrappedEventWriter;
37  	}
38  
39      @Override
40  	public void add(XMLEvent event) throws XMLStreamException {
41  		wrappedEventWriter.add(event);
42  	}
43  
44      @Override
45  	public void add(XMLEventReader reader) throws XMLStreamException {
46  		wrappedEventWriter.add(reader);
47  	}
48  
49      @Override
50  	public void close() throws XMLStreamException {
51  		wrappedEventWriter.close();
52  	}
53  
54      @Override
55  	public void flush() throws XMLStreamException {
56  		wrappedEventWriter.flush();
57  	}
58  
59      @Override
60  	public NamespaceContext getNamespaceContext() {
61  		return wrappedEventWriter.getNamespaceContext();
62  	}
63  
64      @Override
65  	public String getPrefix(String uri) throws XMLStreamException {
66  		return wrappedEventWriter.getPrefix(uri);
67  	}
68  
69      @Override
70  	public void setDefaultNamespace(String uri) throws XMLStreamException {
71  		wrappedEventWriter.setDefaultNamespace(uri);
72  	}
73  
74      @Override
75  	public void setNamespaceContext(NamespaceContext context) throws XMLStreamException {
76  		wrappedEventWriter.setNamespaceContext(context);
77  	}
78  
79      @Override
80  	public void setPrefix(String prefix, String uri) throws XMLStreamException {
81  		wrappedEventWriter.setPrefix(prefix, uri);
82  	}
83  }