EMMA Coverage Report (generated Sat Jan 08 08:46:59 EST 2011)
[all classes][net.sourceforge.finmodel.rules]

COVERAGE SUMMARY FOR SOURCE FILE [PeriodicRule.java]

nameclass, %method, %block, %line, %
PeriodicRule.java100% (1/1)50%  (6/12)69%  (80/116)62%  (23/37)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PeriodicRule100% (1/1)50%  (6/12)69%  (80/116)62%  (23/37)
getAmount (): BigDecimal 0%   (0/1)0%   (0/3)0%   (0/1)
getFreq (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getPeriod (): Period 0%   (0/1)0%   (0/3)0%   (0/1)
setAmount (BigDecimal): void 0%   (0/1)0%   (0/4)0%   (0/2)
setFreq (String): void 0%   (0/1)0%   (0/8)0%   (0/3)
setStubType (StubType): void 0%   (0/1)0%   (0/15)0%   (0/6)
PeriodicRule (): void 100% (1/1)100% (6/6)100% (3/3)
getFrequency (): Frequency 100% (1/1)100% (3/3)100% (1/1)
getSchedule (): List 100% (1/1)100% (40/40)100% (7/7)
getStubType (): StubType 100% (1/1)100% (3/3)100% (1/1)
setFrequency (Frequency): void 100% (1/1)100% (19/19)100% (7/7)
setPeriod (Period): void 100% (1/1)100% (9/9)100% (4/4)

1package net.sourceforge.finmodel.rules;
2 
3import java.math.BigDecimal;
4import java.util.ArrayList;
5import java.util.Calendar;
6import java.util.List;
7 
8import org.jfin.date.Frequency;
9import org.jfin.date.Period;
10import org.jfin.date.ScheduleException;
11import org.jfin.date.ScheduleGenerator;
12import org.jfin.date.StubType;
13 
14public class PeriodicRule extends RuleImpl implements Rule {
15        public static final long serialVersionUID = 1L;
16        private String freq;
17        private Frequency frequency;
18        private StubType stubType = StubType.SHORT_FIRST;
19        private Period period;
20        private List<Calendar> schedule;
21        
22        public PeriodicRule() {
23                super();
24        }
25        
26        public void setFrequency(Frequency frequency) {
27                Frequency oldFreq = this.frequency;
28                this.frequency = frequency;
29                if (oldFreq != frequency) {
30                        notifyScheduleChange();
31                        schedule = null;
32                }
33                
34                this.freq = frequency.getTenorDescriptor();
35        }
36 
37        public Frequency getFrequency() {
38                return frequency;
39        }
40 
41        public void setAmount(BigDecimal amount) {
42                this.amount = amount;
43        }
44        
45        public BigDecimal getAmount() {
46                return this.amount;
47        }
48        
49        /**
50         * @param freq the freq to set
51         */
52        protected void setFreq(String freq) {
53                this.freq = freq;
54                setFrequency( Frequency.valueOf(freq) );
55        }
56 
57        /**
58         * @return the freq
59         */
60        protected String getFreq() {
61                return freq;
62        }
63        public void setStubType(StubType stubType) {
64                StubType oldStubType = this.stubType;
65                this.stubType = stubType;
66                if (oldStubType != stubType) {
67                        notifyScheduleChange();
68                        schedule = null;
69                }
70        }
71 
72        public StubType getStubType() {
73                return stubType;
74        }
75 
76        public void setPeriod(Period period) {
77                this.period = period;
78                notifyScheduleChange();
79                schedule = null;
80        }
81 
82        public Period getPeriod() {
83                return this.period;
84        }
85        
86        /**
87         * Returns a list of days for which this rule can generate a Transaction.
88         */
89        public List<Calendar> getSchedule() throws ScheduleException {
90                if (schedule == null) {
91                        List<Period> periods = ScheduleGenerator.generateSchedule(period.getStartCalendar(), period.getEndCalendar(), 
92                                        getFrequency(), getStubType());
93                        schedule = new ArrayList<Calendar>();
94                        for (Period period: periods) {
95                                schedule.add(period.getStartCalendar());
96                        }
97                } 
98                return schedule;
99        }
100}

[all classes][net.sourceforge.finmodel.rules]
EMMA 2.1.5320 (stable) (C) Vladimir Roubtsov