private static DvDuration create(DvDuration dvDuration, String attributeName, Object value) throws InternalErrorException { String durationValue = dvDuration.getValue(); if (attributeName.equals("value")) { durationValue = (String) value; } return new DvDuration(durationValue); }
public DataValue getDataValue() { if (getValueTextField().getText().isEmpty()) { return null; } else { return new DvDuration(getValueTextField().getText()); } }
/** * Create a Duration from two instances of DvWorldTime * * @param start * @param end */ public static DvDuration getDifference(DvTemporal start, DvTemporal end) { Duration d = new Duration(start.getDateTime(), end.getDateTime()); return new DvDuration(null, null, null, 0.0, false, null, d.toPeriodFrom(start.getDateTime())); }
/** * Create a Duration from two instances of DvWorldTime * * @param start * @param end */ public static DvDuration getDifference(DvTemporal start, DvTemporal end) { Duration d = new Duration(start.getDateTime(), end.getDateTime()); return new DvDuration(null, null, null, 0.0, false, null, d.toPeriodFrom(start.getDateTime())); }
/** * Create a Duration from a ISO8601 string presentation * * @param value * @throws IllegalArgumentException * if value null or wrong format */ public static DvDuration getInstance(String value) { if (value == null) { throw new IllegalArgumentException("null value"); } if (!value.matches(PATTERN)) { throw new IllegalArgumentException("Wrong duration format: " + value); } Period period = null; final String suppliedValue = value; if (value.startsWith("-")) { value = value.substring(1, value.length()); // skip '-' period = ISOPeriodFormat.standard().parsePeriod(value); period = negatePeriod(period); } else { period = ISOPeriodFormat.standard().parsePeriod(value); } DvDuration duration = new DvDuration(null, null, null, 0.0, false, null, period); duration.setValue(suppliedValue); // If we don't set this we cannot reconstruct the original constraint if 0s or 0h etc if all the same period, but the constraint in the ADL / XML serialisation still looks different return duration; }
/** * Create a Duration from a ISO8601 string presentation * * @param value * @throws IllegalArgumentException * if value null or wrong format */ public static DvDuration getInstance(String value) { if (value == null) { throw new IllegalArgumentException("null value"); } if (!value.matches(PATTERN)) { throw new IllegalArgumentException("Wrong duration format: " + value); } Period period = null; final String suppliedValue = value; if (value.startsWith("-")) { value = value.substring(1, value.length()); // skip '-' period = ISOPeriodFormat.standard().parsePeriod(value); period = negatePeriod(period); } else { period = ISOPeriodFormat.standard().parsePeriod(value); } DvDuration duration = new DvDuration(null, null, null, 0.0, false, null, period); duration.setValue(suppliedValue); // If we don't set this we cannot reconstruct the original constraint if 0s or 0h etc if all the same period, but the constraint in the ADL / XML serialisation still looks different return duration; }
/** * Negated version of current object * * @return negated version */ public DvDuration negate() { return new DvDuration(getOtherReferenceRanges(), getNormalRange(), getNormalStatus(), getAccuracy(), isAccuracyPercent(), getMagnitudeStatus(), negatePeriod(period)); }
/** * Negated version of current object * * @return negated version */ public DvDuration negate() { return new DvDuration(getOtherReferenceRanges(), getNormalRange(), getNormalStatus(), getAccuracy(), isAccuracyPercent(), getMagnitudeStatus(), negatePeriod(period)); }
/** * Difference of this quantity and another whose formal type must be the * difference type of this quantity type. * * @param q * @return product of substraction * @throws ClassCastException */ @Override public DvQuantified<DvDuration> subtract(DvQuantified q) { final DvDuration d = (DvDuration) q; DateTime dt = new DateTime(0); Duration duration = period.toDurationFrom(dt); Duration result = duration.minus(d.period.toDurationFrom(dt)); Period p = result.toPeriodFrom(dt); return new DvDuration(d.getOtherReferenceRanges(), d.getNormalRange(), d.getNormalStatus(), d.getAccuracy(), d.isAccuracyPercent(), d.getMagnitudeStatus(), p); }
/** * Sum of this quantity and another whose formal type must be the difference * type of this quantity. * * @param q * @return production of addition * @throws ClassCastException */ @Override public DvQuantified<DvDuration> add(DvQuantified q) { final DvDuration d = (DvDuration) q; DateTime dt = new DateTime(0); Duration duration = period.toDurationFrom(dt); Duration result = duration.plus(d.period.toDurationFrom(dt)); Period p = result.toPeriodFrom(dt); return new DvDuration(d.getOtherReferenceRanges(), d.getNormalRange(), d.getNormalStatus(), d.getAccuracy(), d.isAccuracyPercent(), d.getMagnitudeStatus(), p); }
/** * Difference of this quantity and another whose formal type must be the * difference type of this quantity type. * * @param q * @return product of substraction * @throws ClassCastException */ @Override public DvQuantified<DvDuration> subtract(DvQuantified q) { final DvDuration d = (DvDuration) q; DateTime dt = new DateTime(0); Duration duration = period.toDurationFrom(dt); Duration result = duration.minus(d.period.toDurationFrom(dt)); Period p = result.toPeriodFrom(dt); return new DvDuration(d.getOtherReferenceRanges(), d.getNormalRange(), d.getNormalStatus(), d.getAccuracy(), d.isAccuracyPercent(), d.getMagnitudeStatus(), p); }
/** * Sum of this quantity and another whose formal type must be the difference * type of this quantity. * * @param q * @return production of addition * @throws ClassCastException */ @Override public DvQuantified<DvDuration> add(DvQuantified q) { final DvDuration d = (DvDuration) q; DateTime dt = new DateTime(0); Duration duration = period.toDurationFrom(dt); Duration result = duration.plus(d.period.toDurationFrom(dt)); Period p = result.toPeriodFrom(dt); return new DvDuration(d.getOtherReferenceRanges(), d.getNormalRange(), d.getNormalStatus(), d.getAccuracy(), d.isAccuracyPercent(), d.getMagnitudeStatus(), p); }