use of eu.europa.ec.inspire.schemas.base2.x20.DocumentCitationType in project arctic-sea by 52North.
the class DocumentCitationTypeEncoder method encode.
@Override
public XmlObject encode(DocumentCitation documentCitation, EncodingContext context) throws EncodingException {
DocumentCitationType dct = DocumentCitationType.Factory.newInstance(getXmlOptions());
if (documentCitation.isSetDate()) {
dct.addNewDate().addNewCIDate().addNewDate().setDateTime(documentCitation.getDate().get().toGregorianCalendar());
}
if (documentCitation.isSetName()) {
dct.setName2(documentCitation.getFirstName().getValue());
}
if (documentCitation.isSetLinks()) {
for (Nillable<String> link : documentCitation.getLinks()) {
if (link.isPresent()) {
dct.addNewLink().setStringValue(link.get());
} else {
Link l = dct.addNewLink();
l.setNil();
if (link.getNilReason().isPresent()) {
l.setNilReason(link.getNilReason().get());
}
}
}
}
return dct;
}
use of eu.europa.ec.inspire.schemas.base2.x20.DocumentCitationType in project arctic-sea by 52North.
the class DocumentCitationTypeDecoder method decode.
@Override
public DocumentCitation decode(XmlObject xmlObject) throws DecodingException {
if (xmlObject instanceof DocumentCitationType) {
DocumentCitation documentCitation = new DocumentCitation();
DocumentCitationType dct = (DocumentCitationType) xmlObject;
documentCitation.setDescription(dct.getDescription().getStringValue());
if (dct.isNilDate()) {
if (dct.getDate().isSetNilReason()) {
documentCitation.setDate(Nillable.<DateTime>nil(dct.getDate().getNilReason().toString()));
}
} else {
documentCitation.setDate(new DateTime(dct.getDate().getCIDate().getDate().getDate().getTime()));
}
if (dct.getLinkArray() != null) {
for (Link link : dct.getLinkArray()) {
if (link.isNil() && link.isSetNilReason()) {
documentCitation.addLink(Nillable.<String>nil(link.getNilReason().toString()));
} else {
documentCitation.addLink(link.getStringValue());
}
}
}
return documentCitation;
}
throw new UnsupportedDecoderInputException(this, xmlObject);
}
Aggregations