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;
}
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"));
}
}
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;
}
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;
}
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;
}
Aggregations