EMMA Coverage Report (generated Fri Jan 30 13:20:29 EST 2009)
[all classes][org.springframework.batch.item.xml.stax]

COVERAGE SUMMARY FOR SOURCE FILE [DefaultTransactionalEventReader.java]

nameclass, %method, %block, %line, %
DefaultTransactionalEventReader.java100% (1/1)88%  (7/8)86%  (54/63)84%  (12.6/15)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DefaultTransactionalEventReader100% (1/1)88%  (7/8)86%  (54/63)84%  (12.6/15)
afterPropertiesSet (): void 0%   (0/1)0%   (0/4)0%   (0/2)
peek (): XMLEvent 100% (1/1)67%  (8/12)66%  (0.7/1)
hasNext (): boolean 100% (1/1)92%  (11/12)91%  (0.9/1)
DefaultTransactionalEventReader (XMLEventReader): void 100% (1/1)100% (9/9)100% (3/3)
nextEvent (): XMLEvent 100% (1/1)100% (14/14)100% (3/3)
onCommit (): void 100% (1/1)100% (4/4)100% (2/2)
onRollback (): void 100% (1/1)100% (4/4)100% (2/2)
remove (): void 100% (1/1)100% (4/4)100% (1/1)

1package org.springframework.batch.item.xml.stax;
2 
3import java.util.NoSuchElementException;
4 
5import javax.xml.stream.XMLEventReader;
6import javax.xml.stream.XMLStreamException;
7import javax.xml.stream.events.XMLEvent;
8 
9import org.springframework.beans.factory.InitializingBean;
10import org.springframework.util.Assert;
11 
12/**
13 * Class used to wrap XMLEventReader. Events from wrapped reader are stored in
14 * {@link EventSequence} to support transactions.
15 * 
16 * @deprecated no longer used, to be removed in 2.0
17 *
18 * @author Tomas Slanina
19 * @author Robert Kasanicky
20 */
21public class DefaultTransactionalEventReader extends AbstractEventReaderWrapper implements TransactionalEventReader, InitializingBean {
22 
23        private EventSequence recorder = new EventSequence();
24 
25 
26        /**
27         * Creates instance of this class and wraps XMLEventReader.
28         *
29         * @param wrappedReader event reader to be wrapped.
30         */
31        public DefaultTransactionalEventReader(XMLEventReader wrappedReader) {
32                super(wrappedReader);
33        }
34 
35        public void afterPropertiesSet() throws Exception {
36                Assert.notNull(wrappedEventReader);
37        }
38 
39        /**
40         * Callback on transaction rollback.
41         */
42        public void onRollback() {
43                recorder.reset();
44        }
45 
46        /**
47         * Callback on transacion commit.
48         *
49         */
50        public void onCommit() {
51                recorder.clear();
52        }
53 
54 
55        /**
56         * Check if there are more events. Returns true if there are more events and
57         * false otherwise.
58         *
59         * @return true if the event reader has more events, false otherwise
60         */
61        public boolean hasNext() {
62                return recorder.hasNext() || wrappedEventReader.hasNext();
63        }
64 
65        /**
66         * Get the next XMLEvent
67         *
68         * @see XMLEvent
69         * @throws XMLStreamException if there is an error with the underlying XML.
70         * @throws NoSuchElementException iteration has no more elements.
71         */
72        public XMLEvent nextEvent() throws XMLStreamException {
73                if (!recorder.hasNext()) {
74                        recorder.addEvent(wrappedEventReader.nextEvent());
75                }
76                return recorder.nextEvent();
77        }
78 
79        /**
80         * Check the next XMLEvent without reading it from the stream. Returns null
81         * if the stream is at EOF or has no more XMLEvents. A call to peek() will
82         * be equal to the next return of next().
83         *
84         * @see XMLEvent
85         * @throws XMLStreamException
86         */
87        public XMLEvent peek() throws XMLStreamException {
88                return (recorder.hasNext()) ? recorder.peek() : wrappedEventReader.peek();
89        }
90 
91 
92        /**
93         * In this implementation throws UnsupportedOperationException.
94         */
95        public void remove() {
96                throw new UnsupportedOperationException();
97        }
98}

[all classes][org.springframework.batch.item.xml.stax]
EMMA 2.0.5312 (C) Vladimir Roubtsov