1 /* GENERATED SOURCE. DO NOT MODIFY. */ 2 // © 2016 and later: Unicode, Inc. and others. 3 // License & terms of use: http://www.unicode.org/copyright.html#License 4 /* 5 ****************************************************************************** 6 * Copyright (C) 2007-2010, International Business Machines Corporation and * 7 * others. All Rights Reserved. * 8 ****************************************************************************** 9 */ 10 11 package ohos.global.icu.impl.duration; 12 13 import java.util.Collection; 14 15 import ohos.global.icu.impl.duration.impl.PeriodFormatterDataService; 16 import ohos.global.icu.impl.duration.impl.ResourceBasedPeriodFormatterDataService; 17 18 /** 19 * An implementation of PeriodFormatterService that constructs a 20 * BasicPeriodFormatterFactory. 21 * @hide exposed on OHOS 22 */ 23 public class BasicPeriodFormatterService implements PeriodFormatterService { 24 private static BasicPeriodFormatterService instance; 25 private PeriodFormatterDataService ds; 26 27 /** 28 * Return the default service instance. This uses the default data service. 29 * 30 * @return an BasicPeriodFormatterService 31 */ getInstance()32 public static BasicPeriodFormatterService getInstance() { 33 if (instance == null) { 34 PeriodFormatterDataService ds = ResourceBasedPeriodFormatterDataService 35 .getInstance(); 36 instance = new BasicPeriodFormatterService(ds); 37 } 38 return instance; 39 } 40 41 /** 42 * Construct a BasicPeriodFormatterService using the given 43 * PeriodFormatterDataService. 44 * 45 * @param ds the data service to use 46 */ BasicPeriodFormatterService(PeriodFormatterDataService ds)47 public BasicPeriodFormatterService(PeriodFormatterDataService ds) { 48 this.ds = ds; 49 } 50 51 @Override newDurationFormatterFactory()52 public DurationFormatterFactory newDurationFormatterFactory() { 53 return new BasicDurationFormatterFactory(this); 54 } 55 56 @Override newPeriodFormatterFactory()57 public PeriodFormatterFactory newPeriodFormatterFactory() { 58 return new BasicPeriodFormatterFactory(ds); 59 } 60 61 @Override newPeriodBuilderFactory()62 public PeriodBuilderFactory newPeriodBuilderFactory() { 63 return new BasicPeriodBuilderFactory(ds); 64 } 65 66 @Override getAvailableLocaleNames()67 public Collection<String> getAvailableLocaleNames() { 68 return ds.getAvailableLocales(); 69 } 70 } 71