Search in sources :

Example 16 with SimpleInternationalString

use of org.apache.sis.util.iso.SimpleInternationalString in project sis by apache.

the class DefaultLineageTest method create.

/**
 * Create a lineage to marshal. If {@code extension} is {@code false}, then this method uses
 * only properties defined in ISO 19115-1. If {@code extension} is {@code true}, then this
 * method adds an ISO 19115-2 property.
 */
private static DefaultLineage create(final boolean extension) {
    final DefaultLineage lineage = new DefaultLineage();
    final DefaultSource source = new DefaultSource();
    source.setDescription(new SimpleInternationalString("Description of source data level."));
    lineage.getSources().add(source);
    if (extension) {
        source.setProcessedLevel(new DefaultIdentifier("DummyLevel"));
    }
    return lineage;
}
Also used : SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier)

Example 17 with SimpleInternationalString

use of org.apache.sis.util.iso.SimpleInternationalString in project sis by apache.

the class XLinkTest method testGetType.

/**
 * Tests the automatic {@link XLink#getType()} detection.
 *
 * @throws URISyntaxException if a test URI can not be parsed (should not happen).
 */
@Test
public void testGetType() throws URISyntaxException {
    final XLink link = new XLink();
    int hashCode = link.hashCode();
    assertFalse(hashCode == 0);
    assertNull(link.getType());
    link.setType(XLink.Type.AUTO);
    assertEquals(XLink.Type.TITLE, link.getType());
    assertEquals("XLink[type=\"title\"]", link.toString());
    assertFalse("Hash code should have changed.", hashCode == (hashCode = link.hashCode()));
    assertFalse("Hash code can not be zero.", hashCode == 0);
    link.setRole(new URI("org:apache:sis:role"));
    assertEquals(XLink.Type.EXTENDED, link.getType());
    assertEquals("XLink[type=\"extended\", role=\"org:apache:sis:role\"]", link.toString());
    assertFalse("Hash code should have changed.", hashCode == (hashCode = link.hashCode()));
    assertFalse("Hash code can not be zero.", hashCode == 0);
    link.setTitle(new SimpleInternationalString("Some title"));
    assertEquals(XLink.Type.EXTENDED, link.getType());
    assertEquals("XLink[type=\"extended\", role=\"org:apache:sis:role\", title=\"Some title\"]", link.toString());
    assertFalse("Hash code should have changed.", hashCode == (hashCode = link.hashCode()));
    assertFalse("Hash code can not be zero.", hashCode == 0);
    link.setLabel("SomeLabel");
    assertEquals(XLink.Type.RESOURCE, link.getType());
    assertEquals("XLink[type=\"resource\", role=\"org:apache:sis:role\", title=\"Some title\", label=\"SomeLabel\"]", link.toString());
    assertFalse("Hash code should have changed.", hashCode == (hashCode = link.hashCode()));
    assertFalse("Hash code can not be zero.", hashCode == 0);
    link.setHRef(new URI("org:apache:sis:href"));
    assertEquals(XLink.Type.LOCATOR, link.getType());
    assertEquals("XLink[type=\"locator\", href=\"org:apache:sis:href\", role=\"org:apache:sis:role\", title=\"Some title\", label=\"SomeLabel\"]", link.toString());
    assertFalse("Hash code should have changed.", hashCode == (hashCode = link.hashCode()));
    assertFalse("Hash code can not be zero.", hashCode == 0);
    link.setShow(XLink.Show.NEW);
    assertNull("Can't be Type.SIMPLE if a label is defined.", link.getType());
    assertEquals("XLink[href=\"org:apache:sis:href\", role=\"org:apache:sis:role\", title=\"Some title\", show=\"new\", label=\"SomeLabel\"]", link.toString());
    assertFalse("Hash code should have changed.", hashCode == (hashCode = link.hashCode()));
    assertFalse("Hash code can not be zero.", hashCode == 0);
    link.setLabel(null);
    assertEquals(XLink.Type.SIMPLE, link.getType());
    assertEquals("XLink[type=\"simple\", href=\"org:apache:sis:href\", role=\"org:apache:sis:role\", title=\"Some title\", show=\"new\"]", link.toString());
    assertFalse("Hash code should have changed.", hashCode == (hashCode = link.hashCode()));
    assertFalse("Hash code can not be zero.", hashCode == 0);
    link.setActuate(XLink.Actuate.ON_LOAD);
    assertEquals(XLink.Type.SIMPLE, link.getType());
    assertEquals("XLink[type=\"simple\", href=\"org:apache:sis:href\", role=\"org:apache:sis:role\", title=\"Some title\", show=\"new\", actuate=\"onLoad\"]", link.toString());
    assertFalse("Hash code should have changed.", hashCode == (hashCode = link.hashCode()));
    assertFalse("Hash code can not be zero.", hashCode == 0);
    /*
         * Now freezes the XLink and ensures that it is really immutable.
         */
    link.freeze();
    assertEquals("hashCode", hashCode, link.hashCode());
    try {
        link.setType(null);
        fail("The XLink should be unmodifiable.");
    } catch (UnsupportedOperationException e) {
        // This is the expected exception.
        assertTrue(e.getMessage().contains("XLink"));
    }
}
Also used : SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) URI(java.net.URI) Test(org.junit.Test)

Example 18 with SimpleInternationalString

use of org.apache.sis.util.iso.SimpleInternationalString in project sis by apache.

the class CustomAttribute method quality.

/**
 * Evaluates the quality of this attribute with a custom rule.
 */
@Override
public DataQuality quality() {
    final DefaultDataQuality quality = (DefaultDataQuality) super.quality();
    final DefaultDomainConsistency report = new DefaultDomainConsistency();
    final DefaultQuantitativeResult result = new DefaultQuantitativeResult();
    result.setErrorStatistic(new SimpleInternationalString(ADDITIONAL_QUALITY_INFO));
    report.setMeasureIdentification(new NamedIdentifier(getName()));
    report.setResults(singleton(result));
    quality.setReports(singleton(report));
    return quality;
}
Also used : DefaultDomainConsistency(org.apache.sis.metadata.iso.quality.DefaultDomainConsistency) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) NamedIdentifier(org.apache.sis.referencing.NamedIdentifier) DefaultDataQuality(org.apache.sis.metadata.iso.quality.DefaultDataQuality) DefaultQuantitativeResult(org.apache.sis.metadata.iso.quality.DefaultQuantitativeResult)

Example 19 with SimpleInternationalString

use of org.apache.sis.util.iso.SimpleInternationalString in project sis by apache.

the class Store method getFormat.

/**
 * Returns a more complete description of the GPX format.
 * The format will be part of the metadata returned by {@link #getMetadata()}.
 *
 * @see StoreProvider#getFormat()
 * @see org.apache.sis.internal.storage.gpx.Metadata#getResourceFormats()
 */
final Format getFormat() {
    assert Thread.holdsLock(this);
    Format format = ((StoreProvider) provider).getFormat(listeners);
    if (version != null) {
        final DefaultFormat df = new DefaultFormat(format);
        final DefaultCitation citation = new DefaultCitation(df.getFormatSpecificationCitation());
        citation.setEdition(new SimpleInternationalString(version.toString()));
        df.setFormatSpecificationCitation(citation);
        format = df;
    }
    return format;
}
Also used : Format(org.opengis.metadata.distribution.Format) DefaultFormat(org.apache.sis.metadata.iso.distribution.DefaultFormat) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultFormat(org.apache.sis.metadata.iso.distribution.DefaultFormat)

Example 20 with SimpleInternationalString

use of org.apache.sis.util.iso.SimpleInternationalString in project sis by apache.

the class MetadataStandardTest method createCyclicMetadata.

/**
 * Creates a metadata object having a cyclic association. The cycle is between
 * {@code platform.instrument} and {@code instrument.isMountedOn}.
 */
static DefaultAcquisitionInformation createCyclicMetadata() {
    final DefaultInstrument instrument = new DefaultInstrument();
    instrument.setType(new SimpleInternationalString("An instrument type."));
    final DefaultPlatform platform = new DefaultPlatform();
    platform.setDescription(new SimpleInternationalString("A platform."));
    instrument.setMountedOn(platform);
    platform.setInstruments(singleton(instrument));
    final DefaultAcquisitionInformation acquisition = new DefaultAcquisitionInformation();
    acquisition.setPlatforms(singleton(platform));
    return acquisition;
}
Also used : SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultAcquisitionInformation(org.apache.sis.metadata.iso.acquisition.DefaultAcquisitionInformation) DefaultPlatform(org.apache.sis.metadata.iso.acquisition.DefaultPlatform) DefaultInstrument(org.apache.sis.metadata.iso.acquisition.DefaultInstrument)

Aggregations

SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)45 Test (org.junit.Test)20 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)19 InternationalString (org.opengis.util.InternationalString)14 URI (java.net.URI)4 DependsOnMethod (org.apache.sis.test.DependsOnMethod)4 NamedIdentifier (org.apache.sis.referencing.NamedIdentifier)3 Citation (org.opengis.metadata.citation.Citation)3 IdentifiedObject (org.opengis.referencing.IdentifiedObject)3 Collection (java.util.Collection)2 DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)2 DefaultMetadata (org.apache.sis.metadata.iso.DefaultMetadata)2 DefaultAcquisitionInformation (org.apache.sis.metadata.iso.acquisition.DefaultAcquisitionInformation)2 DefaultInstrument (org.apache.sis.metadata.iso.acquisition.DefaultInstrument)2 DefaultPlatform (org.apache.sis.metadata.iso.acquisition.DefaultPlatform)2 DefaultFormat (org.apache.sis.metadata.iso.distribution.DefaultFormat)2 DefaultDataQuality (org.apache.sis.metadata.iso.quality.DefaultDataQuality)2 InvocationHandler (java.lang.reflect.InvocationHandler)1 Method (java.lang.reflect.Method)1 URISyntaxException (java.net.URISyntaxException)1