/** * 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); }
/** * 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); }
/** * Tests XML marshalling of {@code <gcx:FileName>} 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 testFileName() throws JAXBException { roundtrip(new DefaultBrowseGraphic(URI.create("file:/catalog/image.png")), "<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:MD_BrowseGraphic>"); }
/** * 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>"); }
/** * 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>"); }
@DependsOnMethod("testFileNameAndType") public void testStringSubstitution() throws JAXBException { final DefaultBrowseGraphic browse = new DefaultBrowseGraphic(URI.create("file:/catalog/image.png")); browse.setFileType("image/tiff");
final DefaultBrowseGraphic g = new DefaultBrowseGraphic(URI.create("file:///thumbnail.png")); g.setFileDescription(new SimpleInternationalString("Arbitrary thumbnail for this test only.")); identification.setGraphicOverviews(singleton(g));