EMMA Coverage Report (generated Tue May 06 07:28:24 PDT 2008)
[all classes][org.springframework.batch.item.xml.stax]

COVERAGE SUMMARY FOR SOURCE FILE [EventSequence.java]

nameclass, %method, %block, %line, %
EventSequence.java100% (1/1)100% (8/8)99%  (79/80)99%  (14.9/15)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class EventSequence100% (1/1)100% (8/8)99%  (79/80)99%  (14.9/15)
peek (): XMLEvent 100% (1/1)93%  (13/14)92%  (0.9/1)
EventSequence (): void 100% (1/1)100% (5/5)100% (3/3)
addEvent (XMLEvent): void 100% (1/1)100% (6/6)100% (2/2)
clear (): void 100% (1/1)100% (3/3)100% (2/2)
hasNext (): boolean 100% (1/1)100% (12/12)100% (1/1)
init (): void 100% (1/1)100% (19/19)100% (3/3)
nextEvent (): XMLEvent 100% (1/1)100% (17/17)100% (1/1)
reset (): void 100% (1/1)100% (4/4)100% (2/2)

1package org.springframework.batch.item.xml.stax;
2 
3import java.util.ArrayList;
4import java.util.List;
5 
6import javax.xml.stream.events.XMLEvent;
7 
8/**
9 * Holds a list of XML events, typically corresponding to a single record.
10 *  
11 * @author tomas.slanina
12 */
13class EventSequence {
14        
15        private static final int BEFORE_BEGINNING = -1;
16        
17        private List events;
18        
19        private int currentIndex;
20        
21        /**
22         * Creates instance of this class.
23         *
24         */
25        public EventSequence() {
26                init();
27        }
28        
29        /**
30         * Adds event to the list of stored events.
31         * 
32         * @param event
33         */
34        public void addEvent(XMLEvent event) {
35                events.add(event);
36        }
37        
38        /**
39         * Gets next XMLEvent from cache and moves cursor to next event.
40         * If cache contains no more events, null is returned.
41         */
42        public XMLEvent nextEvent() {
43                return (hasNext()) ? (XMLEvent)events.get(++currentIndex) :null;
44         }
45        
46        /**
47         * Gets next XMLEvent from cache but cursor remains on the same position.
48         * If cache contains no more events, null is returned.
49         */
50        public XMLEvent peek() {
51                return (hasNext()) ? (XMLEvent)events.get(currentIndex+1) :null;
52        }
53        
54        /**
55         * Removes events from the internal cache.
56         *
57         */
58        public void clear() {
59                init();
60        }
61        
62        /**
63         * Resets cursor to the cache start.
64         *
65         */
66        public void reset() {
67                currentIndex = BEFORE_BEGINNING;
68        }
69        
70        /**
71         * Check if there are more events. Returns true if there are more events and
72         * false otherwise.
73         * 
74         * @return true if the event reader has more events, false otherwise
75         */
76        public boolean hasNext() {
77                return currentIndex + 1 < events.size();
78        }
79        
80        private void init() {
81                events = (events != null) ? new ArrayList(events.size())
82                        : new ArrayList(1000);
83                
84                reset();
85        }
86        
87        
88}

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