/** * Gets the String value of this duration */ public String getValue() { return toString(); }
/** * Negated version of current object * * @return negated version */ public DvDuration negate() { return new DvDuration(getOtherReferenceRanges(), getNormalRange(), getNormalStatus(), getAccuracy(), isAccuracyPercent(), getMagnitudeStatus(), negatePeriod(period)); }
@Override public DvDuration parse(String value) { return getInstance(value); }
@Override public String serialise() { return getReferenceModelName() + "," + toString(); } }
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); }
/** * 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; }
accuracyPercent, magnitudeStatus); DvDuration d = DvDuration.getInstance(value); this.period = d.period; setValue(value);
public DataValue getDataValue() { if (getValueTextField().getText().isEmpty()) { return null; } else { return new DvDuration(getValueTextField().getText()); } }
public void setDataValue(DataValue dataValue) { String value = ""; if (dataValue instanceof DvDuration) { value = ((DvDuration) dataValue).getValue(); } getValueTextField().setText(value); }
@Override public DvDuration diff(T other) { return DvDuration.getDifference(this, other); }
@Override public String serialise() { return getReferenceModelName() + "," + toString(); } }
/** * 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; }
accuracyPercent, magnitudeStatus); DvDuration d = DvDuration.getInstance(value); this.period = d.period; setValue(value);
/** * 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())); }
return getDVInstantiation(DvDuration.class.getSimpleName(), ((DvDuration) dataValue).getValue());
@Override public DvDuration diff(T other) { return DvDuration.getDifference(this, other); }
/** * Negated version of current object * * @return negated version */ public DvDuration negate() { return new DvDuration(getOtherReferenceRanges(), getNormalRange(), getNormalStatus(), getAccuracy(), isAccuracyPercent(), getMagnitudeStatus(), negatePeriod(period)); }
/** * Gets the String value of this duration */ public String getValue() { return toString(); }
@Override public DvDuration parse(String value) { return getInstance(value); }
/** * 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())); }