use of org.apache.sis.xml.XLink in project sis by apache.
the class ModifiableIdentifierMap method setHRef.
/**
* Sets the {@code xlink:href} value, which may be null. If an explicit {@code xlink:href} identifier exists,
* then it will removed before to set the new {@code href} in the {@link XLink} object. The intent is to give
* precedence to the {@link XLink#getHRef()} property in every cases where the {@code href} is parsable as a
* {@link URI}, and use the value associated to the {@code HREF} key only as a fallback when the string can not
* be parsed.
*
* @param href the new value, or {@code null} for removing the value.
* @return the previous value, or {@code null} if none.
*
* @see #getHRef()
*/
private URI setHRef(final URI href) {
URI old = store(IdentifierSpace.HREF, null);
final Identifier identifier = getIdentifier(IdentifierSpace.XLINK);
if (identifier instanceof SpecializedIdentifier<?>) {
final Object link = ((SpecializedIdentifier<?>) identifier).value;
if (link instanceof XLink) {
if (old == null) {
old = ((XLink) link).getHRef();
}
((XLink) link).setHRef(href);
return old;
}
}
if (href != null) {
final XLink link = new XLink();
link.setHRef(href);
store(IdentifierSpace.XLINK, link);
}
return old;
}
Aggregations