Tabnine Logo
NilObject
Code IndexAdd Tabnine to your IDE (free)

How to use
NilObject
in
org.apache.sis.xml

Best Java code snippets using org.apache.sis.xml.NilObject (Showing top 10 results out of 315)

origin: org.apache.sis.core/sis-utility

if (object != null) {
  if (object instanceof NilObject) {
    return ((NilObject) object).getNilReason();
origin: apache/sis

ox = ((NilObject) other).getNilReason();
origin: org.apache.sis.core/sis-utility

ox = ((NilObject) other).getNilReason();
origin: apache/sis

if (object != null) {
  if (object instanceof NilObject) {
    return ((NilObject) object).getNilReason();
origin: apache/sis

final NilReason reason = ((NilObject) value).getNilReason();
if (reason != null) {
  reference = reason.toString();
origin: org.apache.sis.core/sis-utility

final NilReason reason = ((NilObject) value).getNilReason();
if (reason != null) {
  reference = reason.toString();
origin: apache/sis

assertInstanceOf("Should have instantiated a proxy.", NilObject.class, series);
final NilReason reason = ((NilObject) series).getNilReason();
assertNull("NilReason.explanation", reason.getOtherExplanation());
assertEquals("NilReason.URI", "http://www.myreason.org", String.valueOf(reason.getURI()));
origin: apache/sis

/**
 * Tests a simple case for a missing data.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 */
@Test
public void testMissing() throws JAXBException {
  final String expected =
      "<cit:CI_Citation xmlns:cit=\"" + Namespaces.CIT + '"' +
              " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
      "  <cit:title>\n" +
      "    <gco:CharacterString>A title</gco:CharacterString>\n" +
      "  </cit:title>\n" +
      "  <cit:series gco:nilReason=\"missing\"/>\n" +
      "</cit:CI_Citation>";
  final Citation citation = unmarshal(Citation.class, expected);
  assertTitleEquals("citation", "A title", citation);
  final Series series = citation.getSeries();
  assertInstanceOf("Should have instantiated a proxy.", NilObject.class, series);
  final NilReason reason = ((NilObject) series).getNilReason();
  assertSame("nilReason", NilReason.MISSING, reason);
  assertNull("NilReason.explanation", reason.getOtherExplanation());
  assertNull("NilReason.URI",         reason.getURI());
  assertEquals("Series[missing]", series.toString());
  assertNull("All attributes are expected to be null.", series.getName());
  final String actual = marshal(citation);
  assertXmlEquals(expected, actual, "xmlns:*");
  assertEquals(citation, unmarshal(Citation.class, actual));
}
origin: apache/sis

/**
 * Tests a case where the nil reason is specified by an other reason.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 */
@Test
@DependsOnMethod("testMissing")
public void testOther() throws JAXBException {
  final String expected =
      "<cit:CI_Citation xmlns:cit=\"" + Namespaces.CIT + '"' +
              " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
      "  <cit:title>\n" +
      "    <gco:CharacterString>A title</gco:CharacterString>\n" +
      "  </cit:title>\n" +
      "  <cit:series gco:nilReason=\"other:myReason\"/>\n" +
      "</cit:CI_Citation>";
  final Citation citation = unmarshal(Citation.class, expected);
  assertTitleEquals("citation", "A title", citation);
  final Series series = citation.getSeries();
  assertInstanceOf("Should have instantiated a proxy.", NilObject.class, series);
  final NilReason reason = ((NilObject) series).getNilReason();
  assertEquals("NilReason.explanation", "myReason", reason.getOtherExplanation());
  assertNull("NilReason.URI", reason.getURI());
  assertEquals("Series[other:myReason]", series.toString());
  assertNull("All attributes are expected to be null.", series.getName());
  final String actual = marshal(citation);
  assertXmlEquals(expected, actual, "xmlns:*");
  assertEquals(citation, unmarshal(Citation.class, actual));
}
origin: apache/sis

final Citation citation = identification.getCitation();
assertInstanceOf("citation", NilObject.class, citation);
assertEquals("nilReason", NilReason.MISSING, ((NilObject) citation).getNilReason());
assertEquals("abstract", "SIS test", identification.getAbstract().toString());
assertEquals("language", Locale.ENGLISH, getSingleton(identification.getLanguages()));
org.apache.sis.xmlNilObject

Javadoc

A marker interface for nil XML elements providing an explanation about why the information is absent. GeoAPI getter methods usually return a null value when no information is available for a given attribute. However it is possible to specify why an information is absent, in which case the corresponding getter method will rather return an instance of this NilObject interface. The information may be absent for various reasons, including the attribute being inapplicable in the metadata context ( NilReason#INAPPLICABLE), the information probably exists but is unknown to the data provider ( NilReason#UNKNOWN), the information may not exist at all ( NilReason#MISSING) or can not be divulged ( NilReason#WITHHELD).

Nil objects appear most frequently in XML documents because if a mandatory ISO 19115-1 attribute is absent, then the ISO 19115-3 standard requires us to said why it is absent. The following example shows a CI_Citation fragment with an ordinary CI_Series element on the left side, and an unknown CI_Series element on the right side:

Example of missing object
Normal Series element Unknown Series element
xml xml
If the CI_Series element was completely omitted, then org.opengis.metadata.citation.Citation#getSeries()method would return null in Apache SIS implementation. But since a nilReason is provided, then the SIS implementation of getSeries() will rather return an object which implement both the Series and the NilObject interfaces, and the #getNilReason() method on that instance will return the NilReason#UNKNOWN constant.
Instantiation
Instances of NilObject are created by first fetching the reason why the information is missing, then invoking NilReason#createNilObject(Class). The following example instantiates a Citation object which is nil because the information are missing: java

Most used methods

  • getNilReason
    Returns the reason why this object contains no information.

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • runOnUiThread (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • JTable (javax.swing)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now