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

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

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

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

final T previous = map.putSpecialized(authority, value);
if (previous != null && !previous.equals(value)) {
  Context.warningOccured(context, IdentifierMap.class, "putSpecialized",
      Errors.class, Errors.Keys.InconsistentAttribute_2, authority.getName(), value);
  map.putSpecialized(authority, previous);
origin: org.apache.sis.core/sis-utility

/**
 * Creates a new GML object wrapping the given GeoAPI implementation.
 * The ID will be determined from the given object.
 *
 * <p>This constructor is typically invoked at marshalling time. The {@link #id}
 * value set by this constructor will be used by JAXB for producing the XML.</p>
 *
 * @param  wrapped  an instance of a GeoAPI interface to be wrapped.
 */
protected GMLAdapter(final Object wrapped) {
  if (wrapped instanceof IdentifiedObject) {
    final IdentifierMap map = ((IdentifiedObject) wrapped).getIdentifierMap();
    if (map != null) {                                  // Should not be null, but let be safe.
      id = map.get(IdentifierSpace.ID);
    }
  }
}
origin: org.apache.sis.core/sis-metadata

  /**
   * Invoked by JAXB for specifying the unique identifier.
   *
   * @see org.apache.sis.metadata.iso.ISOMetadata#setUUID(String)
   */
  private void setUUID(final String id) {
    getIdentifierMap().put(IdentifierSpace.UUID, id);
  }
}
origin: apache/sis

/**
 * Tests write operations on an {@link IdentifierMap} using specific API.
 */
@Test
public void testPutSpecialized() {
  final List<Identifier> identifiers = new ArrayList<>();
  final IdentifierMap map = new ModifiableIdentifierMap(identifiers);
  final String myID = "myID";
  final java.util.UUID myUUID = fromString("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7");
  final URI myURI = URI.create("http://mylink");
  assertNull(map.putSpecialized(ID,   myID));
  assertNull(map.putSpecialized(UUID, myUUID));
  assertNull(map.putSpecialized(HREF, myURI));
  assertMapEquals("{gml:id=“myID”,"
      + " gco:uuid=“a1eb6e53-93db-4942-84a6-d9e7fb9db2c7”,"
      + " xlink:href=“http://mylink”}", map);
  assertSame(myID,   map.getSpecialized(ID));
  assertSame(myUUID, map.getSpecialized(UUID));
  assertSame(myURI,  map.getSpecialized(HREF));
  assertEquals("myID",                                 map.get(ID));
  assertEquals("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7", map.get(UUID));
  assertEquals("http://mylink",                        map.get(HREF));
}
origin: apache/sis

/**
 * Tests read operations on an {@link IdentifierMap} using specific API.
 */
@Test
public void testGetSpecialized() {
  final List<Identifier> identifiers = new ArrayList<>();
  final IdentifierMap map = new ModifiableIdentifierMap(identifiers);
  assertNull(map.put(ID,   "myID"));
  assertNull(map.put(UUID, "a1eb6e53-93db-4942-84a6-d9e7fb9db2c7"));
  assertNull(map.put(HREF, "http://mylink"));
  assertMapEquals("{gml:id=“myID”,"
      + " gco:uuid=“a1eb6e53-93db-4942-84a6-d9e7fb9db2c7”,"
      + " xlink:href=“http://mylink”}", map);
  assertEquals("myID",                                             map.get           (ID));
  assertEquals("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7",             map.get           (UUID));
  assertEquals("http://mylink",                                    map.get           (HREF));
  assertEquals("myID",                                             map.getSpecialized(ID));
  assertEquals(URI.create("http://mylink"),                        map.getSpecialized(HREF));
  assertEquals(fromString("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7"), map.getSpecialized(UUID));
}
origin: org.apache.sis.core/sis-metadata

String id = Context.getObjectID(context, object);
if (id == null) {
  id = object.getIdentifierMap().getSpecialized(IdentifierSpace.ID);
  if (id != null) {
    final StringBuilder buffer = new StringBuilder();
origin: apache/sis

/**
 * Tests the handling of duplicated authorities.
 */
@Test
public void testDuplicatedAuthorities() {
  final List<Identifier> identifiers = new ArrayList<>();
  assertTrue(identifiers.add(new IdentifierMapEntry(ID,   "myID1")));
  assertTrue(identifiers.add(new IdentifierMapEntry(UUID, "myUUID")));
  assertTrue(identifiers.add(new IdentifierMapEntry(ID,   "myID2")));
  final IdentifierMap map = new ModifiableIdentifierMap(identifiers);
  assertEquals("Duplicated authorities shall be filtered.", 2, map.size());
  assertEquals("Duplicated authorities shall still exist.", 3, identifiers.size());
  assertEquals("myID1",  map.get(ID));
  assertEquals("myUUID", map.get(UUID));
  final Iterator<Citation> it = map.keySet().iterator();
  assertTrue(it.hasNext());
  assertSame(ID, it.next());
  it.remove();
  assertTrue(it.hasNext());
  assertSame(UUID, it.next());
  assertFalse("Duplicated authority shall have been removed.", it.hasNext());
  assertEquals(1, identifiers.size());
  assertEquals(1, map.size());
}
origin: apache/sis

/**
 * Tests explicitly the special handling of {@code href} values.
 */
@Test
public void testHRefSubstitution() {
  final List<Identifier> identifiers = new ArrayList<>();
  final IdentifierMap map = new ModifiableIdentifierMap(identifiers);
  assertNull(map.put(HREF, "myHREF"));
  assertEquals("Shall contain the entry we added.", "myHREF", map.get(HREF));
  // Check the XLink object
  final XLink link = map.getSpecialized(XLINK);
  assertEquals("Added href shall be stored as XLink attribute.", "myHREF", String.valueOf(link.getHRef()));
  assertEquals("Identifier list shall contain the XLink.", link.toString(), getSingleton(identifiers).getCode());
  // Modidfy the XLink object directly
  link.setHRef(URI.create("myNewHREF"));
  assertEquals("Change in XLink shall be reflected in href.", "myNewHREF", map.get(HREF));
}
origin: apache/sis

String id = Context.getObjectID(context, object);
if (id == null) {
  id = object.getIdentifierMap().getSpecialized(IdentifierSpace.ID);
  if (id != null) {
    final StringBuilder buffer = new StringBuilder();
origin: apache/sis

final T previous = map.putSpecialized(authority, value);
if (previous != null && !previous.equals(value)) {
  Context.warningOccured(context, IdentifierMap.class, "putSpecialized",
      Errors.class, Errors.Keys.InconsistentAttribute_2, authority.getName(), value);
  map.putSpecialized(authority, previous);
origin: apache/sis

/**
 * Creates a new GML object wrapping the given GeoAPI implementation.
 * The ID will be determined from the given object.
 *
 * <p>This constructor is typically invoked at marshalling time. The {@link #id}
 * value set by this constructor will be used by JAXB for producing the XML.</p>
 *
 * @param  wrapped  an instance of a GeoAPI interface to be wrapped.
 */
protected GMLAdapter(final Object wrapped) {
  if (wrapped instanceof IdentifiedObject) {
    final IdentifierMap map = ((IdentifiedObject) wrapped).getIdentifierMap();
    if (map != null) {                                  // Should not be null, but let be safe.
      id = map.get(IdentifierSpace.ID);
    }
  }
}
origin: apache/sis

  /**
   * Invoked by JAXB for specifying the unique identifier.
   *
   * @see org.apache.sis.metadata.iso.ISOMetadata#setUUID(String)
   */
  @SuppressWarnings("unused")
  private void setUUID(final String id) {
    getIdentifierMap().put(IdentifierSpace.UUID, id);
  }
}
origin: org.apache.sis.core/sis-utility

XLink link = map.getSpecialized(IdentifierSpace.XLINK);
UUID  uuid = map.getSpecialized(IdentifierSpace.UUID);
if (uuid != null || link != null) {
origin: org.apache.sis.core/sis-metadata

/**
 * Sets the International Standard Serial Number.
 * In this SIS implementation, invoking this method is equivalent to:
 *
 * {@preformat java
 *   getIdentifierMap().putSpecialized(Citations.ISSN, newValue);
 * }
 *
 * @param  newValue  the new ISSN.
 *
 * @see #setIdentifiers(Collection)
 * @see Citations#ISSN
 */
public void setISSN(final String newValue) {
  checkWritePermission();
  if (newValue != null || !isNullOrEmpty(identifiers)) {
    getIdentifierMap().putSpecialized(Citations.ISSN, newValue);
  }
}
origin: org.apache.sis.core/sis-metadata

/**
 * Invoked by JAXB for fetching the unique identifier unique "worldwide".
 *
 * @see org.apache.sis.metadata.iso.ISOMetadata#getUUID()
 */
@XmlAttribute  // Defined in "gco" as unqualified attribute.
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
private String getUUID() {
  return isNullOrEmpty(identifiers) ? null : getIdentifierMap().get(IdentifierSpace.UUID);
}
origin: org.apache.sis.core/sis-metadata

  /**
   * Sets an unique identifier.
   * This method is invoked automatically by JAXB and should never be invoked explicitely.
   */
  private void setUUID(final String id) {
    /*
     * IdentifierMapAdapter will take care of converting the String to UUID if possible, or
     * will store the value as a plain String if it can not be converted. In the later case,
     * a warning will be emitted (logged or processed by listeners).
     */
    getIdentifierMap().put(IdentifierSpace.UUID, id);
  }
}
origin: apache/sis

XLink link = map.getSpecialized(IdentifierSpace.XLINK);
UUID  uuid = map.getSpecialized(IdentifierSpace.UUID);
if (uuid != null || link != null) {
origin: org.apache.sis.core/sis-metadata

  /**
   * Invoked by {@code setID(String)} method implementations for assigning an identifier to an object
   * at unmarshalling time.
   *
   * @param object  the object for which to assign an identifier.
   * @param id      the {@code gco:id} or {@code gml:id} value.
   *
   * @since 0.7
   */
  public static void setObjectID(final IdentifiedObject object, String id) {
    id = CharSequences.trimWhitespaces(id);
    if (id != null && !id.isEmpty()) {
      object.getIdentifierMap().putSpecialized(IdentifierSpace.ID, id);
      final Context context = Context.current();
      if (!Context.setObjectForID(context, object, id)) {
        Context.warningOccured(context, object.getClass(), "setID", Errors.class, Errors.Keys.DuplicatedIdentifier_1, id);
      }
    }
  }
}
origin: org.apache.sis.core/sis-metadata

/**
 * Returns an unique identifier, or {@code null} if none.
 * This method is invoked automatically by JAXB and should never be invoked explicitely.
 */
@XmlAttribute                           // Defined in "gco" as unqualified attribute.
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
private String getUUID() {
  /*
   * IdentifierMapAdapter will take care of converting UUID to String,
   * or to return a previously stored String if it was an unparsable UUID.
   */
  return isNullOrEmpty(identifiers) ? null : getIdentifierMap().get(IdentifierSpace.UUID);
}
origin: apache/sis

  /**
   * Sets an unique identifier.
   * This method is invoked automatically by JAXB and should never be invoked explicitly.
   */
  private void setUUID(final String id) {
    /*
     * IdentifierMapAdapter will take care of converting the String to UUID if possible, or
     * will store the value as a plain String if it can not be converted. In the later case,
     * a warning will be emitted (logged or processed by listeners).
     */
    getIdentifierMap().put(IdentifierSpace.UUID, id);
  }
}
org.apache.sis.xmlIdentifierMap

Javadoc

A map view of some or all identifiers in an IdentifiedObject. Each java.util.Map.Entry is associated to an Identifier where java.util.Map.Entry#getKey() is the Identifier#getAuthority() and the java.util.Map.Entry#getValue() is the Identifier#getCode().

Some XML identifiers are difficult to handle as Identifier objects. Those identifiers are rather handled using specialized classes like XLink. This IdentifierMap interface mirrors the standard Map#get(Object) and Map#put(Object,Object) methods with specialized methods, in order to fetch and store identifiers as objects of the specialized class.

Most used methods

  • putSpecialized
    Associates the given identifier with the given namespace in this map (optional operation). If the ma
  • get
  • getSpecialized
    Returns the identifier associated to the given namespace, or null if this map contains no mapping of
  • put
  • keySet
  • size

Popular in Java

  • Making http requests using okhttp
  • addToBackStack (FragmentTransaction)
  • getSharedPreferences (Context)
  • getContentResolver (Context)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in 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