• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
4 /*
5  **************************************************************************
6  * Copyright (C) 2008-2014, Google, International Business Machines
7  * Corporation and others. All Rights Reserved.
8  **************************************************************************
9  */
10 package android.icu.util;
11 
12 import java.io.InvalidObjectException;
13 import java.io.ObjectStreamException;
14 
15 
16 /**
17  * Measurement unit for time units.
18  * @see TimeUnit
19  * @author markdavis
20  */
21 public class TimeUnit extends MeasureUnit {
22     private static final long serialVersionUID = -2839973855554750484L;
23 
24     /**
25      * Here for serialization backward compatibility only.
26      */
27     private final int index;
28 
TimeUnit(String type, String code)29     TimeUnit(String type, String code) {
30         super(type, code);
31         index = 0;
32     }
33 
34     /**
35      * @return the available values
36      */
values()37     public static TimeUnit[] values() {
38         return new TimeUnit[] { SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR };
39     }
40 
writeReplace()41     private Object writeReplace() throws ObjectStreamException {
42         return new MeasureUnitProxy(type, subType);
43     }
44 
45     // For backward compatibility only
readResolve()46     private Object readResolve() throws ObjectStreamException {
47         // The old index field used to uniquely identify the time unit.
48         switch (index) {
49         case 6:
50             return SECOND;
51         case 5:
52             return MINUTE;
53         case 4:
54             return HOUR;
55         case 3:
56             return DAY;
57         case 2:
58             return WEEK;
59         case 1:
60             return MONTH;
61         case 0:
62             return YEAR;
63         default:
64             throw new InvalidObjectException("Bad index: " + index);
65         }
66     }
67 }
68