1 16 package org.joda.time.field; 17 18 import java.io.Serializable ; 19 import org.joda.time.DurationField; 20 import org.joda.time.DurationFieldType; 21 22 33 public class DelegatedDurationField extends DurationField implements Serializable { 34 35 36 private static final long serialVersionUID = -5576443481242007829L; 37 38 39 private final DurationField iField; 40 41 private final DurationFieldType iType; 42 43 48 protected DelegatedDurationField(DurationField field) { 49 this(field, null); 50 } 51 52 58 protected DelegatedDurationField(DurationField field, DurationFieldType type) { 59 super(); 60 if (field == null) { 61 throw new IllegalArgumentException ("The field must not be null"); 62 } 63 iField = field; 64 iType = (type == null ? field.getType() : type); 65 } 66 67 73 public final DurationField getWrappedField() { 74 return iField; 75 } 76 77 public DurationFieldType getType() { 78 return iType; 79 } 80 81 public String getName() { 82 return iType.getName(); 83 } 84 85 88 public boolean isSupported() { 89 return iField.isSupported(); 90 } 91 92 public boolean isPrecise() { 93 return iField.isPrecise(); 94 } 95 96 public int getValue(long duration) { 97 return iField.getValue(duration); 98 } 99 100 public long getValueAsLong(long duration) { 101 return iField.getValueAsLong(duration); 102 } 103 104 public int getValue(long duration, long instant) { 105 return iField.getValue(duration, instant); 106 } 107 108 public long getValueAsLong(long duration, long instant) { 109 return iField.getValueAsLong(duration, instant); 110 } 111 112 public long getMillis(int value) { 113 return iField.getMillis(value); 114 } 115 116 public long getMillis(long value) { 117 return iField.getMillis(value); 118 } 119 120 public long getMillis(int value, long instant) { 121 return iField.getMillis(value, instant); 122 } 123 124 public long getMillis(long value, long instant) { 125 return iField.getMillis(value, instant); 126 } 127 128 public long add(long instant, int value) { 129 return iField.add(instant, value); 130 } 131 132 public long add(long instant, long value) { 133 return iField.add(instant, value); 134 } 135 136 public int getDifference(long minuendInstant, long subtrahendInstant) { 137 return iField.getDifference(minuendInstant, subtrahendInstant); 138 } 139 140 public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant) { 141 return iField.getDifferenceAsLong(minuendInstant, subtrahendInstant); 142 } 143 144 public long getUnitMillis() { 145 return iField.getUnitMillis(); 146 } 147 148 public int compareTo(Object durationField) { 149 return iField.compareTo(durationField); 150 } 151 152 public String toString() { 153 return (iType == null) ? iField.toString() : 154 ("DurationField[" + iType + ']'); 155 } 156 157 } 158 | Popular Tags |