home *** CD-ROM | disk | FTP | other *** search
/ Popular Software (Premium Edition) / mycd.iso / INTERNET / NETSCAP4.06 / CP32E406.EXE / nav40.z / java40.jar / java / util / Calendar.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-08-13  |  6.1 KB  |  305 lines

  1. package java.util;
  2.  
  3. import java.io.Serializable;
  4. import java.text.DateFormat;
  5.  
  6. public abstract class Calendar implements Serializable, Cloneable {
  7.    public static final int ERA = 0;
  8.    public static final int YEAR = 1;
  9.    public static final int MONTH = 2;
  10.    public static final int WEEK_OF_YEAR = 3;
  11.    public static final int WEEK_OF_MONTH = 4;
  12.    public static final int DATE = 5;
  13.    public static final int DAY_OF_MONTH = 5;
  14.    public static final int DAY_OF_YEAR = 6;
  15.    public static final int DAY_OF_WEEK = 7;
  16.    public static final int DAY_OF_WEEK_IN_MONTH = 8;
  17.    public static final int AM_PM = 9;
  18.    public static final int HOUR = 10;
  19.    public static final int HOUR_OF_DAY = 11;
  20.    public static final int MINUTE = 12;
  21.    public static final int SECOND = 13;
  22.    public static final int MILLISECOND = 14;
  23.    public static final int ZONE_OFFSET = 15;
  24.    public static final int DST_OFFSET = 16;
  25.    public static final int FIELD_COUNT = 17;
  26.    public static final int SUNDAY = 1;
  27.    public static final int MONDAY = 2;
  28.    public static final int TUESDAY = 3;
  29.    public static final int WEDNESDAY = 4;
  30.    public static final int THURSDAY = 5;
  31.    public static final int FRIDAY = 6;
  32.    public static final int SATURDAY = 7;
  33.    public static final int JANUARY = 0;
  34.    public static final int FEBRUARY = 1;
  35.    public static final int MARCH = 2;
  36.    public static final int APRIL = 3;
  37.    public static final int MAY = 4;
  38.    public static final int JUNE = 5;
  39.    public static final int JULY = 6;
  40.    public static final int AUGUST = 7;
  41.    public static final int SEPTEMBER = 8;
  42.    public static final int OCTOBER = 9;
  43.    public static final int NOVEMBER = 10;
  44.    public static final int DECEMBER = 11;
  45.    public static final int UNDECIMBER = 12;
  46.    // $FF: renamed from: AM int
  47.    public static final int field_0 = 0;
  48.    // $FF: renamed from: PM int
  49.    public static final int field_1 = 1;
  50.    protected int[] fields;
  51.    protected boolean[] isSet;
  52.    transient boolean userSetZoneOffset;
  53.    transient boolean userSetDSTOffset;
  54.    protected long time;
  55.    protected boolean isTimeSet;
  56.    protected boolean areFieldsSet;
  57.    transient boolean areAllFieldsSet;
  58.    private boolean lenient;
  59.    private TimeZone zone;
  60.    private int firstDayOfWeek;
  61.    private int minimalDaysInFirstWeek;
  62.    private static Locale localeCache;
  63.    private static int firstDayOfWeekCache;
  64.    private static int minimalDaysInFirstWeekCache;
  65.    static final long serialVersionUID = -1807547505821590642L;
  66.  
  67.    protected Calendar() {
  68.       this(TimeZone.getDefault(), Locale.getDefault());
  69.    }
  70.  
  71.    protected Calendar(TimeZone var1, Locale var2) {
  72.       this.lenient = true;
  73.       this.fields = new int[17];
  74.       this.isSet = new boolean[17];
  75.       this.userSetZoneOffset = false;
  76.       this.userSetDSTOffset = false;
  77.       this.zone = var1;
  78.       this.setWeekCountData(var2);
  79.    }
  80.  
  81.    public static synchronized Calendar getInstance() {
  82.       return new GregorianCalendar();
  83.    }
  84.  
  85.    public static synchronized Calendar getInstance(TimeZone var0) {
  86.       return new GregorianCalendar(var0, Locale.getDefault());
  87.    }
  88.  
  89.    public static synchronized Calendar getInstance(Locale var0) {
  90.       return new GregorianCalendar(TimeZone.getDefault(), var0);
  91.    }
  92.  
  93.    public static synchronized Calendar getInstance(TimeZone var0, Locale var1) {
  94.       return new GregorianCalendar(var0, var1);
  95.    }
  96.  
  97.    public static synchronized Locale[] getAvailableLocales() {
  98.       return DateFormat.getAvailableLocales();
  99.    }
  100.  
  101.    protected abstract void computeTime();
  102.  
  103.    protected abstract void computeFields();
  104.  
  105.    public final Date getTime() {
  106.       return new Date(this.getTimeInMillis());
  107.    }
  108.  
  109.    public final void setTime(Date var1) {
  110.       this.setTimeInMillis(var1.getTime());
  111.    }
  112.  
  113.    protected long getTimeInMillis() {
  114.       if (!this.isTimeSet) {
  115.          this.computeTime();
  116.       }
  117.  
  118.       return this.time;
  119.    }
  120.  
  121.    protected void setTimeInMillis(long var1) {
  122.       this.isTimeSet = true;
  123.       this.time = var1;
  124.       this.areFieldsSet = false;
  125.       this.computeFields();
  126.    }
  127.  
  128.    public final int get(int var1) {
  129.       this.complete();
  130.       return this.fields[var1];
  131.    }
  132.  
  133.    protected final int internalGet(int var1) {
  134.       return this.fields[var1];
  135.    }
  136.  
  137.    final void internalSet(int var1, int var2) {
  138.       this.fields[var1] = var2;
  139.    }
  140.  
  141.    public final void set(int var1, int var2) {
  142.       this.isTimeSet = false;
  143.       this.fields[var1] = var2;
  144.       this.isSet[var1] = true;
  145.       this.areFieldsSet = false;
  146.       switch (var1) {
  147.          case 15:
  148.             this.userSetZoneOffset = true;
  149.             return;
  150.          case 16:
  151.             this.userSetDSTOffset = true;
  152.             return;
  153.          default:
  154.       }
  155.    }
  156.  
  157.    public final void set(int var1, int var2, int var3) {
  158.       this.set(1, var1);
  159.       this.set(2, var2);
  160.       this.set(5, var3);
  161.    }
  162.  
  163.    public final void set(int var1, int var2, int var3, int var4, int var5) {
  164.       this.set(1, var1);
  165.       this.set(2, var2);
  166.       this.set(5, var3);
  167.       this.set(11, var4);
  168.       this.set(12, var5);
  169.    }
  170.  
  171.    public final void set(int var1, int var2, int var3, int var4, int var5, int var6) {
  172.       this.set(1, var1);
  173.       this.set(2, var2);
  174.       this.set(5, var3);
  175.       this.set(11, var4);
  176.       this.set(12, var5);
  177.       this.set(13, var6);
  178.    }
  179.  
  180.    public final void clear() {
  181.       this.isSet = new boolean[17];
  182.       this.fields = new int[17];
  183.       this.userSetZoneOffset = false;
  184.       this.userSetDSTOffset = false;
  185.       this.areFieldsSet = false;
  186.       this.areAllFieldsSet = false;
  187.    }
  188.  
  189.    public final void clear(int var1) {
  190.       this.isSet[var1] = false;
  191.       this.fields[var1] = 0;
  192.       this.areFieldsSet = false;
  193.       this.areAllFieldsSet = false;
  194.       switch (var1) {
  195.          case 15:
  196.             this.userSetZoneOffset = false;
  197.             return;
  198.          case 16:
  199.             this.userSetDSTOffset = false;
  200.             return;
  201.          default:
  202.       }
  203.    }
  204.  
  205.    public final boolean isSet(int var1) {
  206.       return this.isSet[var1];
  207.    }
  208.  
  209.    protected void complete() {
  210.       if (!this.isTimeSet) {
  211.          this.computeTime();
  212.       }
  213.  
  214.       if (!this.areFieldsSet) {
  215.          this.computeFields();
  216.       }
  217.  
  218.    }
  219.  
  220.    public abstract boolean equals(Object var1);
  221.  
  222.    public abstract boolean before(Object var1);
  223.  
  224.    public abstract boolean after(Object var1);
  225.  
  226.    public abstract void add(int var1, int var2);
  227.  
  228.    public abstract void roll(int var1, boolean var2);
  229.  
  230.    public void setTimeZone(TimeZone var1) {
  231.       this.zone = var1;
  232.    }
  233.  
  234.    public TimeZone getTimeZone() {
  235.       return this.zone;
  236.    }
  237.  
  238.    public void setLenient(boolean var1) {
  239.       this.lenient = var1;
  240.    }
  241.  
  242.    public boolean isLenient() {
  243.       return this.lenient;
  244.    }
  245.  
  246.    public void setFirstDayOfWeek(int var1) {
  247.       this.firstDayOfWeek = var1;
  248.    }
  249.  
  250.    public int getFirstDayOfWeek() {
  251.       return this.firstDayOfWeek;
  252.    }
  253.  
  254.    public void setMinimalDaysInFirstWeek(int var1) {
  255.       this.minimalDaysInFirstWeek = var1;
  256.    }
  257.  
  258.    public int getMinimalDaysInFirstWeek() {
  259.       return this.minimalDaysInFirstWeek;
  260.    }
  261.  
  262.    public abstract int getMinimum(int var1);
  263.  
  264.    public abstract int getMaximum(int var1);
  265.  
  266.    public abstract int getGreatestMinimum(int var1);
  267.  
  268.    public abstract int getLeastMaximum(int var1);
  269.  
  270.    public Object clone() {
  271.       try {
  272.          Calendar var1 = (Calendar)super.clone();
  273.          var1.fields = new int[17];
  274.          var1.isSet = new boolean[17];
  275.          System.arraycopy(this.fields, 0, var1.fields, 0, 17);
  276.          System.arraycopy(this.isSet, 0, var1.isSet, 0, 17);
  277.          var1.zone = (TimeZone)this.zone.clone();
  278.          return var1;
  279.       } catch (CloneNotSupportedException var2) {
  280.          throw new InternalError();
  281.       }
  282.    }
  283.  
  284.    private void setWeekCountData(Locale var1) {
  285.       Class var2 = this.getClass();
  286.       synchronized(var2){}
  287.  
  288.       try {
  289.          if (var1 != localeCache || localeCache == null) {
  290.             ResourceBundle var4 = ResourceBundle.getBundle("java.text.resources.LocaleElements", var1);
  291.             String[] var5 = var4.getStringArray("DateTimeElements");
  292.             localeCache = var1;
  293.             firstDayOfWeekCache = Integer.parseInt(var5[0]);
  294.             minimalDaysInFirstWeekCache = Integer.parseInt(var5[1]);
  295.          }
  296.  
  297.          this.firstDayOfWeek = firstDayOfWeekCache;
  298.          this.minimalDaysInFirstWeek = minimalDaysInFirstWeekCache;
  299.       } catch (Throwable var7) {
  300.          throw var7;
  301.       }
  302.  
  303.    }
  304. }
  305.