|
From: <ma...@us...> - 2006-08-27 08:57:22
|
Revision: 66 Author: marchy Date: 2006-08-27 01:56:27 -0700 (Sun, 27 Aug 2006) ViewCVS: http://svn.sourceforge.net/objectlabkit/?rev=66&view=rev Log Message: ----------- Putting in common functionality into an abstract class Modified Paths: -------------- trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/DateCalculatorFactory.java Added Paths: ----------- trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/AbstractDateCalculatorFactory.java Added: trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/AbstractDateCalculatorFactory.java =================================================================== --- trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/AbstractDateCalculatorFactory.java (rev 0) +++ trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/AbstractDateCalculatorFactory.java 2006-08-27 08:56:27 UTC (rev 66) @@ -0,0 +1,55 @@ +/* + * $Id: DefaultDateCalculatorFactory.java 64 2006-08-26 10:41:51Z marchy $ + * + * Copyright 2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package net.objectlab.kit.datecalc.common; + +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +/** + * TODO javadoc + * + * @author marchi + * @author $LastChangedBy$ + * @version $Revision$ $Date$ + * + */ +public abstract class AbstractDateCalculatorFactory<E> implements DateCalculatorFactory<E> { + + protected final ConcurrentMap<String, Set<E>> holidays = new ConcurrentHashMap<String, Set<E>>(); + + public abstract DateCalculator<E> getDateCalculator(String name, String holidayHandlerType); + + public abstract PeriodCountCalculator<E> getPeriodCountCalculator(); + + /** + * Use this method to register a set of holidays for a given calendar, it + * will replace any existing set. It won't update any existing + * DateCalculator as these should not be amended whilst in existence (we + * could otherwise get inconsistent results). + * + * @param name + * the calendar name to register these holidays under. + * @param holidays + * the set of holidays (non-working days). + */ + public void registerHolidays(final String name, final Set<E> holidays) { + this.holidays.put(name, holidays); + } + +} Modified: trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/DateCalculatorFactory.java =================================================================== --- trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/DateCalculatorFactory.java 2006-08-27 08:55:31 UTC (rev 65) +++ trunk/datecalc-common/src/main/java/net/objectlab/kit/datecalc/common/DateCalculatorFactory.java 2006-08-27 08:56:27 UTC (rev 66) @@ -28,7 +28,7 @@ * new DateCalculator to get the new set. * * @author Benoit Xhenseval - * @author $LastEditedBy$ + * @author $LastChangedBy$ * @version $Revision$ $Date$ */ public interface DateCalculatorFactory<E> { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |