EMMA Coverage Report (generated Thu Jan 20 11:39:44 EST 2011)
[all classes][com.hammurapi.extract]

COVERAGE SUMMARY FOR SOURCE FILE [Constant.java]

nameclass, %method, %block, %line, %
Constant.java100% (1/1)90%  (9/10)78%  (116/148)74%  (24.6/33)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Constant100% (1/1)90%  (9/10)78%  (116/148)74%  (24.6/33)
Constant (): void 0%   (0/1)0%   (0/5)0%   (0/2)
compareTo (Extractor): ComparisonResult 100% (1/1)60%  (21/35)62%  (3.7/6)
equals (Object): boolean 100% (1/1)76%  (28/37)69%  (9/13)
hashCode (): int 100% (1/1)89%  (17/19)97%  (3.9/4)
toString (): String 100% (1/1)94%  (32/34)94%  (0.9/1)
Constant (Object): void 100% (1/1)100% (8/8)100% (3/3)
extractInternal (Object, Map, Object []): Object 100% (1/1)100% (3/3)100% (1/1)
getValue (): Object 100% (1/1)100% (3/3)100% (1/1)
isContextDependent (): boolean 100% (1/1)100% (2/2)100% (1/1)
parameterIndices (): Set 100% (1/1)100% (2/2)100% (1/1)

1package com.hammurapi.extract;
2 
3import java.util.Collections;
4import java.util.Map;
5import java.util.Set;
6 
7/**
8 * Constants don't extract any data from sources, but may extract
9 * data from context.
10 * @author Pavel Vlasov.
11 *
12 * @param <V>
13 * @param <C>
14 */
15public class Constant<T, V, C> extends ExtractorBase<T, V, C> {
16        
17        private V value;
18        
19        protected Constant() {
20                super(0,null);
21        }
22 
23        public V getValue() {
24                return value;
25        }
26 
27        public Constant(V value) {
28                super(0,null);
29                this.value = value;
30        }
31 
32        protected V extractInternal(C context, Map<C, Map<Extractor<T, ? super V, C>, ? super V>> cache, T... obj) {
33                return value;
34        }
35 
36        public Set<Integer> parameterIndices() {                
37                return Collections.emptySet();
38        }
39 
40        @Override
41        public int hashCode() {
42                final int prime = 31;
43                int result = 1;
44                result = prime * result + ((value == null) ? 0 : value.hashCode());
45                return result;
46        }
47 
48        @SuppressWarnings("unchecked")
49        @Override
50        public boolean equals(Object obj) {
51                if (this == obj)
52                        return true;
53                if (obj == null)
54                        return false;
55                if (getClass() != obj.getClass())
56                        return false;
57                Constant other = (Constant) obj;
58                if (value == null) {
59                        if (other.value != null)
60                                return false;
61                } else if (!value.equals(other.value))
62                        return false;
63                return true;
64        }
65 
66        public boolean isContextDependent() {
67                return false;
68        }
69        
70        @Override
71        public String toString() {
72                return getClass().getName()+"("+(value==null ? "null" : value + "["+value.getClass()+"]")+")";
73        }
74        
75        @Override
76        public ComparisonResult compareTo(Extractor<T, V, C> other) {
77                if (other instanceof Constant) {
78                        Object otherValue = ((Constant) other).value;
79                        if (value==null) {
80                                return otherValue==null ? ComparisonResult.EQUAL_NM : ComparisonResult.UNEQUAL_NM; 
81                        }
82                        
83                        // TODO - Number promotion and comparison.
84                        
85                        return value.equals(otherValue) ? ComparisonResult.EQUAL_NM : value instanceof Boolean ? ComparisonResult.OPPOSITE_NM : ComparisonResult.UNEQUAL_NM;
86                }
87                return super.compareTo(other);
88        }
89 
90}

[all classes][com.hammurapi.extract]
EMMA 2.0.5312 EclEmma Fix 2 (C) Vladimir Roubtsov