Home | History | Annotate | Download | only in duration
      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-2009, International Business Machines Corporation and   *
      7 * others. All Rights Reserved.                                               *
      8 ******************************************************************************
      9 */
     10 
     11 package android.icu.impl.duration;
     12 
     13 import java.util.TimeZone;
     14 
     15 /**
     16  * @hide Only a subset of ICU is exposed in Android
     17  */
     18 public interface PeriodBuilderFactory {
     19 
     20   /**
     21    * Sets the time units available for use.  Default is all units.
     22    * @param minUnit the smallest time unit available for use
     23    * @param maxUnit the largest time unit available for use
     24    * @return this factory
     25    */
     26   PeriodBuilderFactory setAvailableUnitRange(TimeUnit minUnit,
     27                          TimeUnit maxUnit);
     28 
     29   /**
     30    * Sets whether the time unit is available for use.
     31    * @param unit the time unit
     32    * @param available true if the unit is available for use
     33    * @return this factory
     34    */
     35   PeriodBuilderFactory setUnitIsAvailable(TimeUnit unit, boolean available);
     36 
     37   /**
     38    * Sets the maximum value for the largest available time unit (as
     39    * set in setUnits).  Periods that represent a longer duration than
     40    * this will be pinned to this value of that time unit and return
     41    * true for 'isMoreThan'.  Default is no limit.  Setting a value of
     42    * zero restores the default.
     43    */
     44   PeriodBuilderFactory setMaxLimit(float maxLimit);
     45 
     46   /**
     47    * Sets the minimum value for the smallest available time unit (as
     48    * set in setUnits).  Periods that represent a shorter duration than
     49    * this will be pinned to this value of that time unit and return
     50    * true for 'isLessThan'.  Default is no limit.  Setting a value of
     51    * zero restores the default.
     52    */
     53   PeriodBuilderFactory setMinLimit(float minLimit);
     54 
     55   /**
     56    * Sets whether units with a value of zero are represented in a
     57    * period when 'gaps' appear between time units, e.g.
     58    * '2 hours, 0 minutes, and 33 seconds'.  Default is to
     59    * not represent these explicitly ('2 hours and 33 seconds').
     60    */
     61   PeriodBuilderFactory setAllowZero(boolean allow);
     62 
     63   /**
     64    * Sets whether weeks are used with other units, or only when
     65    * weeks are the only unit.  For example '3 weeks and 2 days'
     66    * versus '23 days'.  Default is to use them alone only.
     67    */
     68   PeriodBuilderFactory setWeeksAloneOnly(boolean aloneOnly);
     69 
     70   /**
     71    * Sets whether milliseconds are allowed.  This is only examined
     72    * when milliseconds are an available field. The default is to allow
     73    * milliseconds to display normally.
     74    * <p>
     75    * This is intended to be used to set locale-specific behavior.  Typically clients will
     76    * not call this API and instead call {@link #setLocale}.
     77    *
     78    * @param allow whether milliseconds should be allowed.
     79    * @return a builder
     80    */
     81    PeriodBuilderFactory setAllowMilliseconds(boolean allow);
     82 
     83   /**
     84    * Sets the locale for the factory.  Setting the locale can adjust
     85    * the values for some or all of the other properties to reflect
     86    * language or cultural conventions.  Default is to use
     87    * the default locale.
     88    */
     89   PeriodBuilderFactory setLocale(String localeName);
     90 
     91   /**
     92    * Sets the time zone for the factory.  This can affect the timezone
     93    * used for date computations.
     94    * @param timeZone the timeZone
     95    * @return a builder
     96    */
     97   PeriodBuilderFactory setTimeZone(TimeZone timeZone);
     98  /**
     99    * Returns a builder that represents durations in terms of the single
    100    * given TimeUnit.  If the factory settings don't make the given unit
    101    * available, this will return null.
    102    *
    103    * @param unit the single TimeUnit with which to represent times
    104    * @return a builder
    105    */
    106   PeriodBuilder getFixedUnitBuilder(TimeUnit unit);
    107 
    108   /**
    109    * Returns a builder that represents durations in terms of the
    110    * single largest period less than or equal to the duration.
    111    *
    112    * @return a builder
    113    */
    114   PeriodBuilder getSingleUnitBuilder();
    115 
    116   /**
    117    * Returns a builder that formats the largest one or two time units,
    118    * starting with the largest period less than or equal to the duration.
    119    * It formats two periods if the first period has a count &lt; 2
    120    * and the next period has a count &gt;= 1.
    121    *
    122    * @return a builder
    123    */
    124   PeriodBuilder getOneOrTwoUnitBuilder();
    125 
    126   /**
    127    * Returns a builder that formats up to the given number of time units,
    128    * starting with the largest unit less than or equal to the
    129    * duration.
    130    *
    131    * @return a builder
    132    */
    133   PeriodBuilder getMultiUnitBuilder(int unitCount);
    134 }
    135 
    136