/** * Returns a SIS metadata implementation with the values of the given arbitrary implementation. * This method performs the first applicable action in the following choices: * * <ul> * <li>If the given object is {@code null}, then this method returns {@code null}.</li> * <li>Otherwise if the given object is already an instance of * {@code DefaultBrowseGraphic}, then it is returned unchanged.</li> * <li>Otherwise a new {@code DefaultBrowseGraphic} instance is created using the * {@linkplain #DefaultBrowseGraphic(BrowseGraphic) copy constructor} * and returned. Note that this is a <cite>shallow</cite> copy operation, since the other * metadata contained in the given object are not recursively copied.</li> * </ul> * * @param object the object to get as a SIS implementation, or {@code null} if none. * @return a SIS implementation containing the values of the given object (may be the * given object itself), or {@code null} if the argument was null. */ public static DefaultBrowseGraphic castOrCopy(final BrowseGraphic object) { if (object == null || object instanceof DefaultBrowseGraphic) { return (DefaultBrowseGraphic) object; } return new DefaultBrowseGraphic(object); }
/** * Invoked by JAXB at marshalling time for getting the actual metadata to write * inside the {@code <mcc:MD_BrowseGraphic>} XML element. * This is the value or a copy of the value given in argument to the {@code wrap} method. * * @return the metadata to be marshalled. */ @XmlElementRef public DefaultBrowseGraphic getElement() { return DefaultBrowseGraphic.castOrCopy(metadata); }
/** * Sets the text description of the illustration. * * @param newValue the new file description. */ public void setFileDescription(final InternationalString newValue) { checkWritePermission(); fileDescription = newValue; }
/** * Tests XML marshalling of {@code <gcx:MimeFileType>} inside {@code <mcc:MD_BrowseGraphic>}. * This method uses the XML schema defined by ISO 19115-3. * * @throws JAXBException if an error occurred while (un)marshalling the {@code BrowseGraphic}. */ @Test public void testMimeFileType() throws JAXBException { final DefaultBrowseGraphic browse = new DefaultBrowseGraphic(); browse.setFileType("image/tiff"); roundtrip(browse, "<mcc:MD_BrowseGraphic xmlns:mcc=\"" + Namespaces.MCC + '"' + " xmlns:gcx=\"" + Namespaces.GCX + "\">\n" + " <mcc:fileType>\n" + " <gcx:MimeFileType type=\"image/tiff\">image/tiff</gcx:MimeFileType>\n" + " </mcc:fileType>\n" + "</mcc:MD_BrowseGraphic>"); }
final DefaultBrowseGraphic g = new DefaultBrowseGraphic(URI.create("file:///thumbnail.png")); g.setFileDescription(new SimpleInternationalString("Arbitrary thumbnail for this test only.")); identification.setGraphicOverviews(singleton(g));
/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * @param object the metadata to copy values from, or {@code null} if none. * * @see #castOrCopy(BrowseGraphic) */ public DefaultBrowseGraphic(final BrowseGraphic object) { super(object); if (object != null) { fileName = object.getFileName(); fileDescription = object.getFileDescription(); fileType = object.getFileType(); if (object instanceof DefaultBrowseGraphic) { imageConstraints = ((DefaultBrowseGraphic) object).getImageConstraints(); linkages = ((DefaultBrowseGraphic) object).getLinkages(); } } }
/** * Return the links to browse graphic. * * @return the links to browse graphic. * * @since 0.5 */ /// @XmlElement(name = "linkage") @UML(identifier="linkage", obligation=OPTIONAL, specification=ISO_19115) public Collection<OnlineResource> getLinkages() { return linkages = nonNullCollection(linkages, OnlineResource.class); }
/** * Tests unmarshalling of {@code <gcx:FileName>} without {@code src} attribute. * * @throws JAXBException if an error occurred while (un)marshalling the {@code BrowseGraphic}. */ @Test @DependsOnMethod("testFileName") public void testFileNameWithoutSrc() throws JAXBException { final DefaultBrowseGraphic browse = unmarshal(DefaultBrowseGraphic.class, "<mcc:MD_BrowseGraphic xmlns:mcc=\"" + Namespaces.MCC + '"' + " xmlns:gcx=\"" + Namespaces.GCX + "\">\n" + " <mcc:fileName>\n" + " <gcx:FileName>file:/catalog/image.png</gcx:FileName>\n" + " </mcc:fileName>\n" + "</mcc:MD_BrowseGraphic>"); assertEquals(URI.create("file:/catalog/image.png"), browse.getFileName()); }
@XmlElement(name = "linkage") private Collection<OnlineResource> getLinkage() { return FilterByVersion.CURRENT_METADATA.accept() ? getLinkages() : null; } }
/** * Invoked by JAXB at both marshalling and unmarshalling time. * This attribute has been added by ISO 19115:2014 standard. * If (and only if) marshalling an older standard version, we omit this attribute. */ @XmlElement(name = "imageConstraints") private Collection<Constraints> getImageConstraint() { return FilterByVersion.CURRENT_METADATA.accept() ? getImageConstraints() : null; }
/** * Tests XML marshalling of {@code <gcx:FileName>} and {@code <gcx:MimeFileType>} together. * This method uses the XML schema defined by ISO 19115-3. * * @throws JAXBException if an error occurred while (un)marshalling the {@code BrowseGraphic}. */ @Test @DependsOnMethod({"testFileName", "testMimeFileType"}) public void testFileNameAndType() throws JAXBException { final DefaultBrowseGraphic browse = new DefaultBrowseGraphic(URI.create("file:/catalog/image.png")); browse.setFileType("image/tiff"); roundtrip(browse, "<mcc:MD_BrowseGraphic xmlns:mcc=\"" + Namespaces.MCC + '"' + " xmlns:gcx=\"" + Namespaces.GCX + "\">\n" + " <mcc:fileName>\n" + " <gcx:FileName src=\"file:/catalog/image.png\">image.png</gcx:FileName>\n" + " </mcc:fileName>\n" + " <mcc:fileType>\n" + " <gcx:MimeFileType type=\"image/tiff\">image/tiff</gcx:MimeFileType>\n" + " </mcc:fileType>\n" + "</mcc:MD_BrowseGraphic>"); }
/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * @param object the metadata to copy values from, or {@code null} if none. * * @see #castOrCopy(BrowseGraphic) */ public DefaultBrowseGraphic(final BrowseGraphic object) { super(object); if (object != null) { fileName = object.getFileName(); fileDescription = object.getFileDescription(); fileType = object.getFileType(); if (object instanceof DefaultBrowseGraphic) { imageConstraints = ((DefaultBrowseGraphic) object).getImageConstraints(); linkages = ((DefaultBrowseGraphic) object).getLinkages(); } } }
/** * Returns the restrictions on access and / or use of browse graphic. * * @return restrictions on access and / or use of browse graphic. * * @since 0.5 */ // @XmlElement at the end of this class. @UML(identifier="imageContraints", obligation=OPTIONAL, specification=ISO_19115) public Collection<Constraints> getImageConstraints() { return imageConstraints = nonNullCollection(imageConstraints, Constraints.class); }
/** * Implementation of {@link #testWarnings()} using the given {@code <mcc:fileName>} values. */ private void testWarnings(final String first, final String second) throws JAXBException { final Warning listener = new Warning(); final DefaultBrowseGraphic browse = listener.unmarshal( "<mcc:MD_BrowseGraphic xmlns:mcc=\"" + Namespaces.MCC + '"' + " xmlns:gcx=\"" + Namespaces.GCX + '"' + " xmlns:gco=\"" + Namespaces.GCO + "\">\n" + " <mcc:fileName>\n" + " " + first + "\n" + " " + second + "\n" + " </mcc:fileName>\n" + "</mcc:MD_BrowseGraphic>"); assertEquals(URI.create("file:/catalog/image.png"), browse.getFileName()); assertTrue("Expected a warning.", listener.receivedWarning); }
@DependsOnMethod("testFileNameAndType") public void testStringSubstitution() throws JAXBException { final DefaultBrowseGraphic browse = new DefaultBrowseGraphic(URI.create("file:/catalog/image.png")); browse.setFileType("image/tiff");
/** * Returns a SIS metadata implementation with the values of the given arbitrary implementation. * This method performs the first applicable action in the following choices: * * <ul> * <li>If the given object is {@code null}, then this method returns {@code null}.</li> * <li>Otherwise if the given object is already an instance of * {@code DefaultBrowseGraphic}, then it is returned unchanged.</li> * <li>Otherwise a new {@code DefaultBrowseGraphic} instance is created using the * {@linkplain #DefaultBrowseGraphic(BrowseGraphic) copy constructor} * and returned. Note that this is a <cite>shallow</cite> copy operation, since the other * metadata contained in the given object are not recursively copied.</li> * </ul> * * @param object the object to get as a SIS implementation, or {@code null} if none. * @return a SIS implementation containing the values of the given object (may be the * given object itself), or {@code null} if the argument was null. */ public static DefaultBrowseGraphic castOrCopy(final BrowseGraphic object) { if (object == null || object instanceof DefaultBrowseGraphic) { return (DefaultBrowseGraphic) object; } return new DefaultBrowseGraphic(object); }
/** * Sets the name of the file that contains a graphic that provides an illustration of the dataset. * * @param newValue the new filename. */ public void setFileName(final URI newValue) { checkWritePermission(fileName); fileName = newValue; }
/** * Return the links to browse graphic. * * @return the links to browse graphic. * * @since 0.5 */ // @XmlElement at the end of this class. @UML(identifier="linkage", obligation=OPTIONAL, specification=ISO_19115) public Collection<OnlineResource> getLinkages() { return linkages = nonNullCollection(linkages, OnlineResource.class); }
/** * Tests the unmarshaller with the same URI in both {@code <gco:CharacterString>} and {@code <gcx:FileName>}. * Since the URI is the same, the unmarshaller should not produce any warning since there is no ambiguity. * * @throws JAXBException if an error occurred while (un)marshalling the {@code BrowseGraphic}. */ @Test @DependsOnMethod("testStringSubstitution") public void testDuplicatedValues() throws JAXBException { final Warning listener = new Warning(); final DefaultBrowseGraphic browse = listener.unmarshal( "<mcc:MD_BrowseGraphic xmlns:mcc=\"" + Namespaces.MCC + '"' + " xmlns:gcx=\"" + Namespaces.GCX + '"' + " xmlns:gco=\"" + Namespaces.GCO + "\">\n" + " <mcc:fileName>\n" + " <gcx:FileName src=\"file:/catalog/image.png\">image.png</gcx:FileName>\n" + " <gco:CharacterString>file:/catalog/image.png</gco:CharacterString>\n" + " </mcc:fileName>\n" + "</mcc:MD_BrowseGraphic>"); assertEquals(URI.create("file:/catalog/image.png"), browse.getFileName()); assertFalse("Expected no warning.", listener.receivedWarning); }
/** * Invoked by JAXB at marshalling time for getting the actual metadata to write * inside the {@code <gmd:MD_BrowseGraphic>} XML element. * This is the value or a copy of the value given in argument to the {@code wrap} method. * * @return the metadata to be marshalled. */ @XmlElementRef public DefaultBrowseGraphic getElement() { return DefaultBrowseGraphic.castOrCopy(metadata); }