EMMA Coverage Report (generated Fri Aug 21 15:59:46 BST 2009)
[all classes][org.springframework.batch.core.job.flow]

COVERAGE SUMMARY FOR SOURCE FILE [FlowExecutionStatus.java]

nameclass, %method, %block, %line, %
FlowExecutionStatus.java100% (2/2)79%  (11/14)84%  (156/185)81%  (26.8/33)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FlowExecutionStatus100% (1/1)78%  (7/9)74%  (70/94)76%  (19/25)
hashCode (): int 0%   (0/1)0%   (0/4)0%   (0/1)
isFail (): boolean 0%   (0/1)0%   (0/6)0%   (0/1)
equals (Object): boolean 100% (1/1)26%  (5/19)33%  (2/6)
<static initializer> 100% (1/1)100% (25/25)100% (5/5)
FlowExecutionStatus (String): void 100% (1/1)100% (6/6)100% (3/3)
compareTo (FlowExecutionStatus): int 100% (1/1)100% (22/22)100% (6/6)
getName (): String 100% (1/1)100% (3/3)100% (1/1)
isStop (): boolean 100% (1/1)100% (6/6)100% (1/1)
toString (): String 100% (1/1)100% (3/3)100% (1/1)
     
class FlowExecutionStatus$Status100% (1/1)80%  (4/5)95%  (86/91)97%  (7.8/8)
valueOf (String): FlowExecutionStatus$Status 0%   (0/1)0%   (0/5)0%   (0/1)
<static initializer> 100% (1/1)100% (44/44)100% (2/2)
FlowExecutionStatus$Status (String, int): void 100% (1/1)100% (5/5)100% (1/1)
match (String): FlowExecutionStatus$Status 100% (1/1)100% (21/21)100% (5/5)
values (): FlowExecutionStatus$Status [] 100% (1/1)100% (16/16)100% (1/1)

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 */
16package org.springframework.batch.core.job.flow;
17 
18 
19/**
20 * This class is used as a holder for a BatchStatus/ExitStatus pair.
21 * 
22 * @author Dan Garrette
23 * @author Dave Syer
24 * @since 2.0
25 */
26public class FlowExecutionStatus implements Comparable<FlowExecutionStatus> {
27 
28        /**
29         * Special well-known status value.
30         */
31        public static final FlowExecutionStatus COMPLETED = new FlowExecutionStatus(Status.COMPLETED.toString());
32 
33        /**
34         * Special well-known status value.
35         */
36        public static final FlowExecutionStatus STOPPED = new FlowExecutionStatus(Status.STOPPED.toString());
37 
38        /**
39         * Special well-known status value.
40         */
41        public static final FlowExecutionStatus FAILED = new FlowExecutionStatus(Status.FAILED.toString());
42 
43        /**
44         * Special well-known status value.
45         */
46        public static final FlowExecutionStatus UNKNOWN = new FlowExecutionStatus(Status.UNKNOWN.toString());
47 
48        private final String name;
49 
50        private enum Status {
51 
52                COMPLETED, STOPPED, FAILED, UNKNOWN;
53 
54                static Status match(String value) {
55                        for (int i = 0; i < values().length; i++) {
56                                Status status = values()[i];
57                                if (value.startsWith(status.toString())) {
58                                        return status;
59                                }
60                        }
61                        // Default match should be the lowest priority
62                        return COMPLETED;
63                }
64 
65        };
66 
67        /**
68         * @param status
69         */
70        public FlowExecutionStatus(String status) {
71                this.name = status;
72        }
73        
74        /**
75         * @return true if the status starts with "STOPPED"
76         */
77        public boolean isStop() {
78                return name.startsWith(STOPPED.getName());
79        }
80 
81        /**
82         * @return true if the status starts with "FAILED"
83         */
84        public boolean isFail() {
85                return name.startsWith(FAILED.getName());
86        }
87        
88        /**
89         * Create an ordering on {@link FlowExecutionStatus} instances by comparing
90         * their statuses.
91         * 
92         * @see Comparable#compareTo(Object)
93         * 
94         * @param other
95         * @return negative, zero or positive as per the contract
96         */
97        public int compareTo(FlowExecutionStatus other) {
98                Status one = Status.match(this.name);
99                Status two = Status.match(other.name);
100                int comparison = one.compareTo(two);
101                if (comparison == 0) {
102                        return this.name.compareTo(other.name);
103                }
104                return comparison;
105        }
106 
107        /**
108         * Check the equality of the statuses.
109         * 
110         * @see java.lang.Object#equals(java.lang.Object)
111         */
112        @Override
113        public boolean equals(Object object) {
114                if (object == this) {
115                        return true;
116                }
117                if (!(object instanceof FlowExecutionStatus)) {
118                        return false;
119                }
120                FlowExecutionStatus other = (FlowExecutionStatus) object;
121                return name.equals(other.name);
122        }
123        
124        @Override
125        public int hashCode() {
126                return name.hashCode();
127        }
128 
129        /**
130         * @see Object#toString()
131         */
132        @Override
133        public String toString() {
134                return name;
135        }
136 
137        /**
138         * @return the name of this status
139         */
140        public String getName() {
141                return name;
142        }
143 
144}

[all classes][org.springframework.batch.core.job.flow]
EMMA 2.0.5312 (C) Vladimir Roubtsov