/** * Returns the date type that matches the given string, or returns a new one if none match it. * * @param code The name of the code to fetch or to create. * @return A code matching the given name. */ public static DateType valueOf(String code) { return valueOf(DateType.class, code); } }
/** * ISO 19115 metadata property fixed to {@code DateType.IN_FORCE}. * This is part of the properties returned by {@link #getDates()}. * * @return event used for reference date. */ @Override public DateType getDateType() { return DateType.valueOf("IN_FORCE"); }
/** * Returns the date type that matches the given string, or returns a * new one if none match it. More specifically, this methods returns the first instance for * which <code>{@linkplain #name() name()}.{@linkplain String#equals equals}(code)</code> * returns {@code true}. If no existing instance is found, then a new one is created for * the given name. * * @param code the name of the code to fetch or to create. * @return a code matching the given name. */ public static DateType valueOf(String code) { return valueOf(DateType.class, code); } }
/** * Returns the date type that matches the given string, or returns a * new one if none match it. More specifically, this methods returns the first instance for * which <code>{@linkplain #name() name()}.{@linkplain String#equals equals}(code)</code> * returns {@code true}. If no existing instance is found, then a new one is created for * the given name. * * @param code the name of the code to fetch or to create. * @return a code matching the given name. */ public static DateType valueOf(String code) { return valueOf(DateType.class, code); } }
if (year != 0) { final Date date = new Date(LocalDate.of(year, 1, 1).toEpochDay() * MILLISECONDS_PER_DAY); c.setDates(Collections.singleton(new DefaultCitationDate(date, DateType.valueOf("IN_FORCE"))));
if (year != 0) { final Date date = new Date(LocalDate.of(year, 1, 1).toEpochDay() * MILLISECONDS_PER_DAY); c.setDates(Collections.singleton(new DefaultCitationDate(date, DateType.valueOf("IN_FORCE"))));
/** * Tests XML unmarshalling for a metadata version. * The version is not specified since it should be detected automatically. * * @param file file containing the metadata to unmarshal. */ private void testUnmarshalling(final String file) throws JAXBException { final DefaultCitation c = unmarshalFile(DefaultCitation.class, file); assertTitleEquals("title", "Fight against poverty", c); final CitationDate date = getSingleton(c.getDates()); assertEquals("date", date.getDate(), TestUtilities.date("2015-10-17 00:00:00")); assertEquals("dateType", DateType.valueOf("adopted"), date.getDateType()); assertEquals("presentationForm", PresentationForm.valueOf("physicalObject"), getSingleton(c.getPresentationForms())); final Iterator<ResponsibleParty> it = c.getCitedResponsibleParties().iterator(); final Contact contact = assertResponsibilityEquals(Role.ORIGINATOR, "Maid Marian", it.next()); assertEquals("Contact instruction", "Send carrier pigeon.", String.valueOf(contact.getContactInstructions())); final OnlineResource resource = contact.getOnlineResource(); assertEquals("Resource name", "IP over Avian Carriers", String.valueOf(resource.getName())); assertEquals("Resource description", "High delay, low throughput, and low altitude service.", String.valueOf(resource.getDescription())); assertEquals("Resource linkage", "https://tools.ietf.org/html/rfc1149", String.valueOf(resource.getLinkage())); assertEquals("Resource function", OnLineFunction.OFFLINE_ACCESS, resource.getFunction()); // Thanks to xlink:href, the Contact shall be the same instance as above. assertSame("contact", contact, assertResponsibilityEquals(Role.valueOf("funder"), "Robin Hood", it.next())); assertFalse(it.hasNext()); }
/** * Tests XML marshalling for the given metadata version. * * @param file file containing the expected metadata. * @param version the metadata version to marshal. */ private void testMarshalling(final String file, final Version version) throws JAXBException { final DefaultOnlineResource rs = new DefaultOnlineResource(URI.create("https://tools.ietf.org/html/rfc1149")); rs.setName("IP over Avian Carriers"); rs.setDescription(new SimpleInternationalString("High delay, low throughput, and low altitude service.")); rs.setFunction(OnLineFunction.OFFLINE_ACCESS); final DefaultContact contact = new DefaultContact(rs); contact.setContactInstructions(new SimpleInternationalString("Send carrier pigeon.")); contact.getIdentifierMap().putSpecialized(IdentifierSpace.ID, "ip-protocol"); final DefaultCitation c = new DefaultCitation("Fight against poverty"); final DefaultResponsibleParty r1 = new DefaultResponsibleParty(Role.ORIGINATOR); final DefaultResponsibleParty r2 = new DefaultResponsibleParty(Role.valueOf("funder")); r1.setParties(Collections.singleton(new DefaultIndividual("Maid Marian", null, contact))); r2.setParties(Collections.singleton(new DefaultIndividual("Robin Hood", null, contact))); c.setCitedResponsibleParties(Arrays.asList(r1, r2)); c.getDates().add(new DefaultCitationDate(TestUtilities.date("2015-10-17 00:00:00"), DateType.valueOf("adopted"))); c.getPresentationForms().add(PresentationForm.valueOf("physicalObject")); /* * Check that XML file built by the marshaller is the same as the example file. */ assertMarshalEqualsFile(file, c, version, "xmlns:*", "xsi:schemaLocation"); }
/** * Tests {@link DefaultMetadata#getDateStamp()} and {@link DefaultMetadata#setDateStamp(Date)} methods. */ @Test @SuppressWarnings("deprecation") public void testDateStamp() { final DefaultMetadata metadata = new DefaultMetadata(); assertNull("dateStamp", metadata.getDateStamp()); /* * Verifies that the deprecated method get its value from the CitationDate objects. */ Date creation = date("2014-10-07 00:00:00"); final DefaultCitationDate[] dates = new DefaultCitationDate[] { new DefaultCitationDate(date("2014-10-09 00:00:00"), DateType.valueOf("LAST_UPDATE")), new DefaultCitationDate(creation, DateType.CREATION) }; metadata.setDateInfo(Arrays.asList(dates)); assertEquals("dateStamp", creation, metadata.getDateStamp()); /* * Invoking the deprecated setters shall modify the CitationDate object * associated to DateType.CREATION. */ creation = date("2014-10-06 00:00:00"); metadata.setDateStamp(creation); assertEquals("citationDates[1].date", creation, dates[1].getDate()); assertArrayEquals("dates", dates, metadata.getDateInfo().toArray()); }