![JAR search and dependency download from the Maven repository](/logo.png)
net.objectlab.kit.datecalc.jdk.DateKitCalculatorsFactory Maven / Gradle / Ivy
/*
* $Id: DateKitCalculatorsFactory.java 184 2006-09-17 09:42:49Z 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.jdk;
import java.util.Date;
import net.objectlab.kit.datecalc.common.AbstractKitCalculatorsFactory;
import net.objectlab.kit.datecalc.common.DateCalculator;
import net.objectlab.kit.datecalc.common.HolidayHandlerType;
import net.objectlab.kit.datecalc.common.IMMDateCalculator;
import net.objectlab.kit.datecalc.common.PeriodCountCalculator;
/**
* The default factory for getting Jdk Date
based calculators.
*
* @author Benoit Xhenseval
* @author $LastChangedBy: marchy $
* @version $Revision: 184 $ $Date: 2006-09-17 10:42:49 +0100 (Sun, 17 Sep 2006) $
*
*/
public class DateKitCalculatorsFactory extends AbstractKitCalculatorsFactory {
private static final DateKitCalculatorsFactory DEFAULT = new DateKitCalculatorsFactory();
private static final PeriodCountCalculator PCC = new DatePeriodCountCalculator();
private static final DateIMMDateCalculator IMMDC = new DateIMMDateCalculator();
public static DateKitCalculatorsFactory getDefaultInstance() {
return DEFAULT;
}
/*
* (non-Javadoc)
*
* @see net.objectlab.kit.datecalc.jdk.JdkDateCalculatorFactory#getDateCalculator(java.lang.String,
* java.lang.String)
*/
public DateCalculator getDateCalculator(final String name, final String holidayHandlerType) {
final DateDateCalculator cal = new DateDateCalculator();
cal.setName(name);
setHolidays(name, cal);
if (holidayHandlerType == null) {
return cal;
} else if (HolidayHandlerType.FORWARD.equals(holidayHandlerType)) {
cal.setHolidayHandler(new DateForwardHandler());
} else if (HolidayHandlerType.BACKWARD.equals(holidayHandlerType)) {
cal.setHolidayHandler(new DateBackwardHandler());
} else if (HolidayHandlerType.MODIFIED_FOLLLOWING.equals(holidayHandlerType)) {
cal.setHolidayHandler(new DateModifiedFollowingHandler());
} else if (HolidayHandlerType.MODIFIED_PRECEEDING.equals(holidayHandlerType)) {
cal.setHolidayHandler(new DateModifiedPreceedingHandler());
} else {
throw new IllegalArgumentException("Unsupported HolidayHandler: " + holidayHandlerType);
}
return cal;
}
/*
* (non-Javadoc)
*
* @see net.objectlab.kit.datecalc.jdk.JdkDateCalculatorFactory#getPeriodCountCalculator()
*/
public PeriodCountCalculator getPeriodCountCalculator() {
return PCC;
}
public IMMDateCalculator getIMMDateCalculator() {
return IMMDC;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy