DividedDateTimeField.java 4.06 KB
package org.joda.time.field;

import org.joda.time.DateTimeField;
import org.joda.time.DateTimeFieldType;
import org.joda.time.DurationField;

public class DividedDateTimeField
  extends DecoratedDateTimeField
{
  final int a;
  final DurationField b;
  private final int c;
  private final int d;
  
  public DividedDateTimeField(DateTimeField paramDateTimeField, DateTimeFieldType paramDateTimeFieldType, int paramInt)
  {
    super(paramDateTimeField, paramDateTimeFieldType);
    if (paramInt < 2) {
      throw new IllegalArgumentException("The divisor must be at least 2");
    }
    DurationField localDurationField = paramDateTimeField.getDurationField();
    int i;
    label59:
    int j;
    if (localDurationField == null)
    {
      this.b = null;
      this.a = paramInt;
      i = paramDateTimeField.getMinimumValue();
      if (i < 0) {
        break label108;
      }
      i /= paramInt;
      j = paramDateTimeField.getMaximumValue();
      if (j < 0) {
        break label121;
      }
    }
    label108:
    label121:
    for (paramInt = j / paramInt;; paramInt = (j + 1) / paramInt - 1)
    {
      this.c = i;
      this.d = paramInt;
      return;
      this.b = new ScaledDurationField(localDurationField, paramDateTimeFieldType.getDurationType(), paramInt);
      break;
      i = (i + 1) / paramInt - 1;
      break label59;
    }
  }
  
  public DividedDateTimeField(RemainderDateTimeField paramRemainderDateTimeField, DateTimeFieldType paramDateTimeFieldType)
  {
    super(paramRemainderDateTimeField.getWrappedField(), paramDateTimeFieldType);
    int j = paramRemainderDateTimeField.a;
    this.a = j;
    this.b = paramRemainderDateTimeField.b;
    paramRemainderDateTimeField = getWrappedField();
    int i = paramRemainderDateTimeField.getMinimumValue();
    int k;
    if (i >= 0)
    {
      i /= j;
      k = paramRemainderDateTimeField.getMaximumValue();
      if (k < 0) {
        break label90;
      }
    }
    label90:
    for (j = k / j;; j = (k + 1) / j - 1)
    {
      this.c = i;
      this.d = j;
      return;
      i = (i + 1) / j - 1;
      break;
    }
  }
  
  public long add(long paramLong, int paramInt)
  {
    return getWrappedField().add(paramLong, this.a * paramInt);
  }
  
  public long add(long paramLong1, long paramLong2)
  {
    return getWrappedField().add(paramLong1, this.a * paramLong2);
  }
  
  public long addWrapField(long paramLong, int paramInt)
  {
    return set(paramLong, FieldUtils.getWrappedValue(get(paramLong), paramInt, this.c, this.d));
  }
  
  public int get(long paramLong)
  {
    int i = getWrappedField().get(paramLong);
    if (i >= 0) {
      return i / this.a;
    }
    return (i + 1) / this.a - 1;
  }
  
  public int getDifference(long paramLong1, long paramLong2)
  {
    return getWrappedField().getDifference(paramLong1, paramLong2) / this.a;
  }
  
  public long getDifferenceAsLong(long paramLong1, long paramLong2)
  {
    return getWrappedField().getDifferenceAsLong(paramLong1, paramLong2) / this.a;
  }
  
  public int getDivisor()
  {
    return this.a;
  }
  
  public DurationField getDurationField()
  {
    return this.b;
  }
  
  public int getMaximumValue()
  {
    return this.d;
  }
  
  public int getMinimumValue()
  {
    return this.c;
  }
  
  public long remainder(long paramLong)
  {
    return set(paramLong, get(getWrappedField().remainder(paramLong)));
  }
  
  public long roundFloor(long paramLong)
  {
    DateTimeField localDateTimeField = getWrappedField();
    return localDateTimeField.roundFloor(localDateTimeField.set(paramLong, get(paramLong) * this.a));
  }
  
  public long set(long paramLong, int paramInt)
  {
    FieldUtils.verifyValueBounds(this, paramInt, this.c, this.d);
    int i = getWrappedField().get(paramLong);
    if (i >= 0) {
      i %= this.a;
    }
    for (;;)
    {
      return getWrappedField().set(paramLong, i + this.a * paramInt);
      int j = this.a;
      i = (i + 1) % this.a + (j - 1);
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/org/joda/time/field/DividedDateTimeField.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */