/*
* jFin, open source derivatives trade processing
*
* Copyright (C) 2005, 2006, 2007 Morgan Brown Consultancy Ltd.
*
* This file is part of jFin.
*
* jFin is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* jFin is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public License along
* with jFin; if not, write to the Free Software Foundation, Inc., 51 Franklin
* St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jfin.date.holiday.financialcalendarimpl;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.TreeMap;
public class HolidayFile
{
private TreeMap entries;
public HolidayFile()
{
entries = new TreeMap();
}
public HolidayFile(File f, InfoFile infoFile) throws IOException
{
this();
load(f, infoFile);
}
public void load(File f, InfoFile infoFile) throws IOException
{
BufferedReader reader = new BufferedReader(new FileReader(f));
// Discard the first line, contains column headings
String line = reader.readLine();
while (( line = reader.readLine() ) != null)
{
HolidayFileEntry holidayFileEntry = new HolidayFileEntry(line,
infoFile);
entries.put(holidayFileEntry.getReference(), holidayFileEntry);
}
}
/**
* Add an entry to the info file. The entry is keyed by its code.
*
* @param entry
*/
public void addEntry(HolidayFileEntry entry)
{
entries.put(entry.getReference(), entry);
}
/**
* Retrieves an entry based upon its code.
*
* @param code
* The code to search for
* @return The entry for the given code, or null if the code is not found
*/
public HolidayFileEntry getEntryByReference(String code)
{
return entries.get(code);
}
}
Ads help maintain this website.