EMMA Coverage Report (generated Wed Dec 05 01:17:39 CET 2012)
[all classes][org.jdtaus.banking.ri.blzdirectory]

COVERAGE SUMMARY FOR SOURCE FILE [AbstractPropertiesBankfileProvider.java]

nameclass, %method, %block, %line, %
AbstractPropertiesBankfileProvider.java100% (1/1)67%  (6/9)39%  (90/231)43%  (15/35)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractPropertiesBankfileProvider100% (1/1)67%  (6/9)39%  (90/231)43%  (15/35)
getDateOfValidity (int): Date 0%   (0/1)0%   (0/63)0%   (0/8)
getProperties (): Properties 0%   (0/1)0%   (0/11)0%   (0/3)
setProperties (Properties): void 0%   (0/1)0%   (0/4)0%   (0/2)
getDateOfExpiration (int): Date 100% (1/1)52%  (33/63)57%  (4.6/8)
getBankfileCount (): int 100% (1/1)55%  (12/22)50%  (2/4)
getBankfileLocation (int): String 100% (1/1)58%  (28/48)76%  (4.6/6)
<static initializer> 100% (1/1)80%  (12/15)80%  (0.8/1)
AbstractPropertiesBankfileProvider (): void 100% (1/1)100% (3/3)100% (2/2)
getLastModifiedMillis (): long 100% (1/1)100% (2/2)100% (1/1)

1/*
2 *  jDTAUS Banking RI Bankleitzahlenverzeichnis
3 *  Copyright (C) 2005 Christian Schulte
4 *  <cs@schulte.it>
5 *
6 *  This library is free software; you can redistribute it and/or
7 *  modify it under the terms of the GNU Lesser General Public
8 *  License as published by the Free Software Foundation; either
9 *  version 2.1 of the License, or any later version.
10 *
11 *  This library is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 *  Lesser General Public License for more details.
15 *
16 *  You should have received a copy of the GNU Lesser General Public
17 *  License along with this library; if not, write to the Free Software
18 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 *
20 */
21package org.jdtaus.banking.ri.blzdirectory;
22 
23import java.io.IOException;
24import java.text.NumberFormat;
25import java.text.ParseException;
26import java.text.SimpleDateFormat;
27import java.util.Date;
28import java.util.Properties;
29 
30/**
31 * {@code BankfileProvider} implementation backed by a properties file.
32 *
33 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
34 * @version $JDTAUS: AbstractPropertiesBankfileProvider.java 8661 2012-09-27 11:29:58Z schulte $
35 *
36 * @see BankfileBankleitzahlenVerzeichnis
37 */
38public abstract class AbstractPropertiesBankfileProvider implements BankfileProvider
39{
40 
41    /** Key of the bankfileCount property. */
42    private static final String BANKFILE_COUNT_PROPERTY = "BankleitzahlenVerzeichnis.bankfileCount";
43 
44    /** Prefix of bank file properties. */
45    private static final String BANKFILE_PREFIX = "BankleitzahlenDatei.";
46 
47    /** Properties backing the instance. */
48    private Properties properties;
49 
50    /** Creates a new {@code AbstractPropertiesBankfileProvider} instance. */
51    public AbstractPropertiesBankfileProvider()
52    {
53        super();
54    }
55 
56    public long getLastModifiedMillis() throws IOException
57    {
58        return 0L;
59    }
60 
61    public final int getBankfileCount() throws IOException
62    {
63        try
64        {
65            final String value = this.getProperties().getProperty( BANKFILE_COUNT_PROPERTY, Integer.toString( 0 ) );
66            return NumberFormat.getIntegerInstance().parse( value ).intValue();
67        }
68        catch ( final ParseException e )
69        {
70            throw (IOException) new IOException( e.getMessage() ).initCause( e );
71        }
72    }
73 
74    /**
75     * Gets a bankfile resource location.
76     *
77     * @param index The index of the bankfile resource location to get.
78     *
79     * @return The bankfile resource location at {@code index}.
80     *
81     * @throws IndexOutOfBoundsException if {@code index} is negative or greater or equal to the value returned by
82     * method {@code getBankfileCount()}.
83     * @throws IOException if getting the bankfile resource location fails.
84     */
85    public String getBankfileLocation( final int index ) throws IOException
86    {
87        if ( index < 0 || index >= this.getBankfileCount() )
88        {
89            throw new IndexOutOfBoundsException( Integer.toString( index ) );
90        }
91 
92        final String propertyKey = BANKFILE_PREFIX + index + ".location";
93        final String location = this.getProperties().getProperty( propertyKey );
94        assert location != null : "Property '" + propertyKey + "' not found.";
95        return location;
96    }
97 
98    public final Date getDateOfValidity( final int index ) throws IOException
99    {
100        if ( index < 0 || index >= this.getBankfileCount() )
101        {
102            throw new IndexOutOfBoundsException( Integer.toString( index ) );
103        }
104 
105        try
106        {
107            final String propertyKey = BANKFILE_PREFIX + index + ".dateOfValidity";
108            final String value = this.getProperties().getProperty( propertyKey );
109            assert value != null : "Property '" + propertyKey + "' not found.";
110            return new SimpleDateFormat( "yyyyMMdd" ).parse( value );
111        }
112        catch ( final ParseException e )
113        {
114            throw (IOException) new IOException( e.getMessage() ).initCause( e );
115        }
116    }
117 
118    public final Date getDateOfExpiration( final int index ) throws IOException
119    {
120        if ( index < 0 || index >= this.getBankfileCount() )
121        {
122            throw new IndexOutOfBoundsException( Integer.toString( index ) );
123        }
124 
125        try
126        {
127            final String propertyKey = BANKFILE_PREFIX + index + ".dateOfExpiration";
128            final String value = this.getProperties().getProperty( propertyKey );
129            assert value != null : "Property '" + propertyKey + "' not found.";
130            return new SimpleDateFormat( "yyyyMMdd" ).parse( value );
131        }
132        catch ( final ParseException e )
133        {
134            throw (IOException) new IOException( e.getMessage() ).initCause( e );
135        }
136    }
137 
138    /**
139     * Gets the properties of the instance.
140     *
141     * @return The properties of the instance.
142     *
143     *  @throws IOException if getting the properties fails.
144     */
145    public Properties getProperties() throws IOException
146    {
147        if ( this.properties == null )
148        {
149            this.properties = new Properties();
150        }
151 
152        return this.properties;
153    }
154 
155    /**
156     * Sets the properties of the instance.
157     *
158     * @param value The new properties of the instance or {@code null}.
159     */
160    public void setProperties( final Properties value )
161    {
162        this.properties = value;
163    }
164 
165}

[all classes][org.jdtaus.banking.ri.blzdirectory]
EMMA 2.1.5320 (stable) (C) Vladimir Roubtsov