use of org.apache.xmlbeans.XmlRuntimeException in project arctic-sea by 52North.
the class GmlEncoderv311 method createTimePeriodType.
/**
* Creates a XML TimePeriod from the SOS time object.
*
* @param timePeriod
* SOS time object
* @param timePeriodType
* the xml time period (may be {@code null})
* @return XML TimePeriod
*
* @throws EncodingException
* if an error occurs.
*/
private TimePeriodType createTimePeriodType(TimePeriod timePeriod, TimePeriodType timePeriodType) throws EncodingException {
try {
TimePeriodType tpt;
if (timePeriodType == null) {
tpt = TimePeriodType.Factory.newInstance(getXmlOptions());
} else {
tpt = timePeriodType;
}
if (timePeriod.getGmlId() != null && !timePeriod.getGmlId().isEmpty()) {
tpt.setId(timePeriod.getGmlId());
}
tpt.setBeginPosition(createTimePositionType(timePeriod.getStartTimePosition()));
tpt.setEndPosition(createTimePositionType(timePeriod.getEndTimePosition()));
return tpt;
} catch (XmlRuntimeException | XmlValueDisconnectedException x) {
throw new EncodingException("Error while creating TimePeriod!", x);
}
}
Aggregations