/** * Extracts the {@code xlink:href} value from the {@link XLink} if presents. * This method does not test if an explicit {@code xlink:href} identifier exists; * this check must be done by the caller <strong>before</strong> to invoke this method. * * @see ModifiableIdentifierMap#setHRef(URI) */ private URI getHRef() { final Identifier identifier = getIdentifier(IdentifierSpace.XLINK); if (identifier instanceof SpecializedIdentifier<?>) { final Object link = ((SpecializedIdentifier<?>) identifier).value; if (link instanceof XLink) { return ((XLink) link).getHRef(); } } return null; }
/** * Extracts the {@code xlink:href} value from the {@link XLink} if presents. * This method does not test if an explicit {@code xlink:href} identifier exists; * this check must be done by the caller <strong>before</strong> to invoke this method. * * @see ModifiableIdentifierMap#setHRef(URI) */ private URI getHRef() { final Identifier identifier = getIdentifier(IdentifierSpace.XLINK); if (identifier instanceof SpecializedIdentifier<?>) { final Object link = ((SpecializedIdentifier<?>) identifier).value; if (link instanceof XLink) { return ((XLink) link).getHRef(); } } return null; }
/** * A URN to an external resources, or to an other part of a XML document, or an identifier. * The {@code xlink:href} attribute allows an XML element to refer to another XML element * that has a corresponding {@code id} attribute. * * @return the current value, or {@code null} if none. * @category xlink */ @XmlSchemaType(name = "anyURI") @XmlAttribute(name = "href", namespace = Namespaces.XLINK) public final String getHRef() { final XLink link = xlink(false); return (link != null) ? toString(link.getHRef()) : null; }
/** * A URN to an external resources, or to an other part of a XML document, or an identifier. * The {@code xlink:href} attribute allows an XML element to refer to another XML element * that has a corresponding {@code id} attribute. * * @return the current value, or {@code null} if none. * @category xlink */ @XmlSchemaType(name = "anyURI") @XmlAttribute(name = "href", namespace = Namespaces.XLINK) public final String getHRef() { final XLink link = xlink(false); return (link != null) ? toString(link.getHRef()) : null; }
ensureNonNull("type", type); ensureNonNull("xlink", link); final URI href = link.getHRef(); if (href != null && href.toString().startsWith("#")) { final String id = href.getFragment();
ensureNonNull("type", type); ensureNonNull("xlink", link); final URI href = link.getHRef(); if (href != null && href.toString().startsWith("#")) { final String id = href.getFragment();
/** * Returns a string representation of this object. The default implementation returns the * simple class name followed by non-null attributes, as in the example below: * * {@preformat text * XLink[type="locator", href="urn:ogc:def:method:EPSG::4326"] * } */ @Override public String toString() { final StringBuilder buffer = new StringBuilder(64); buffer.append(Classes.getShortClassName(this)).append('['); append(buffer, "type", getType()); append(buffer, "href", getHRef()); append(buffer, "role", getRole()); append(buffer, "arcrole", getArcRole()); append(buffer, "title", getTitle()); append(buffer, "show", getShow()); append(buffer, "actuate", getActuate()); append(buffer, "label", getLabel()); append(buffer, "from", getFrom()); append(buffer, "to", getTo()); return buffer.append(']').toString(); }
/** * Returns a string representation of this object. The default implementation returns the * simple class name followed by non-null attributes, as in the example below: * * {@preformat text * XLink[type="locator", href="urn:ogc:def:method:EPSG::4326"] * } */ @Override public String toString() { final StringBuilder buffer = new StringBuilder(64); buffer.append(Classes.getShortClassName(this)).append('['); append(buffer, "type", getType()); append(buffer, "href", getHRef()); append(buffer, "role", getRole()); append(buffer, "arcrole", getArcRole()); append(buffer, "title", getTitle()); append(buffer, "show", getShow()); append(buffer, "actuate", getActuate()); append(buffer, "label", getLabel()); append(buffer, "from", getFrom()); append(buffer, "to", getTo()); return buffer.append(']').toString(); }
if (link instanceof XLink) { if (old == null) { old = ((XLink) link).getHRef();
if (link instanceof XLink) { if (old == null) { old = ((XLink) link).getHRef();
/** * Verifies if the given metadata contains the expected {@code xlink:href} attribute value. * * @param isNilExpected {@code true} if the identification info is expected to be a {@link NilObject} instance. * @param metadata the metadata to verify. */ private static void verify(final boolean isNilExpected, final DefaultMetadata metadata) { final Identification identification = getSingleton(metadata.getIdentificationInfo()); assertEquals("NilObject", isNilExpected, identification instanceof NilObject); assertInstanceOf("Identification", IdentifiedObject.class, identification); final XLink xlink = ((IdentifiedObject) identification).getIdentifierMap().getSpecialized(IdentifierSpace.XLINK); assertEquals("xlink:href", "http://test.net", xlink.getHRef().toString()); }
/** * Tests explicitly the special handling of {@code href} values. */ @Test public void testHRefSubstitution() { final List<Identifier> identifiers = new ArrayList<>(); final IdentifierMap map = new ModifiableIdentifierMap(identifiers); assertNull(map.put(HREF, "myHREF")); assertEquals("Shall contain the entry we added.", "myHREF", map.get(HREF)); // Check the XLink object final XLink link = map.getSpecialized(XLINK); assertEquals("Added href shall be stored as XLink attribute.", "myHREF", String.valueOf(link.getHRef())); assertEquals("Identifier list shall contain the XLink.", link.toString(), getSingleton(identifiers).getCode()); // Modidfy the XLink object directly link.setHRef(URI.create("myNewHREF")); assertEquals("Change in XLink shall be reflected in href.", "myNewHREF", map.get(HREF)); }
assertEquals("SDN:C320:2:FR", anchor.getHRef().toString()); assertNull(anchor.getType());