com.ibm.icu.impl.duration.BasicPeriodFormatterService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of icu4j Show documentation
Show all versions of icu4j Show documentation
International Component for Unicode for Java (ICU4J) is a mature, widely used Java library
providing Unicode and Globalization support
/*
******************************************************************************
* Copyright (C) 2007-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
package com.ibm.icu.impl.duration;
import java.util.Collection;
import com.ibm.icu.impl.duration.impl.PeriodFormatterDataService;
import com.ibm.icu.impl.duration.impl.ResourceBasedPeriodFormatterDataService;
/**
* An implementation of PeriodFormatterService that constructs a
* BasicPeriodFormatterFactory.
*/
public class BasicPeriodFormatterService implements PeriodFormatterService {
private static BasicPeriodFormatterService instance;
private PeriodFormatterDataService ds;
/**
* Return the default service instance. This uses the default data service.
*
* @return an BasicPeriodFormatterService
*/
public static BasicPeriodFormatterService getInstance() {
if (instance == null) {
PeriodFormatterDataService ds = ResourceBasedPeriodFormatterDataService
.getInstance();
instance = new BasicPeriodFormatterService(ds);
}
return instance;
}
/**
* Construct a BasicPeriodFormatterService using the given
* PeriodFormatterDataService.
*
* @param ds the data service to use
*/
public BasicPeriodFormatterService(PeriodFormatterDataService ds) {
this.ds = ds;
}
public DurationFormatterFactory newDurationFormatterFactory() {
return new BasicDurationFormatterFactory(this);
}
public PeriodFormatterFactory newPeriodFormatterFactory() {
return new BasicPeriodFormatterFactory(ds);
}
public PeriodBuilderFactory newPeriodBuilderFactory() {
return new BasicPeriodBuilderFactory(ds);
}
public Collection getAvailableLocaleNames() {
return ds.getAvailableLocales();
}
}