org.geotoolkit.referencing.Properties Maven / Gradle / Ivy
/*
* Geotoolkit.org - An Open Source Java GIS Toolkit
* http://www.geotoolkit.org
*
* (C) 2004-2012, Open Source Geospatial Foundation (OSGeo)
* (C) 2009-2012, Geomatys
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* This package contains documentation from OpenGIS specifications.
* OpenGIS consortium's work is fully acknowledged here.
*/
package org.geotoolkit.referencing;
import java.util.Set;
import java.util.HashSet;
import java.util.AbstractMap;
import net.jcip.annotations.Immutable;
import org.opengis.referencing.datum.Datum;
import org.opengis.referencing.ReferenceSystem;
import org.opengis.referencing.IdentifiedObject;
import org.opengis.referencing.operation.CoordinateOperation;
import org.geotoolkit.util.collection.XCollections;
import org.geotoolkit.referencing.operation.AbstractCoordinateOperation;
import static org.geotoolkit.util.collection.XCollections.hashMapCapacity;
/**
* An immutable map fetching all properties from the specified identified object. Calls
* to {@code get} methods are forwarded to the appropriate {@link IdentifiedObject} method.
*
* @author Martin Desruisseaux (IRD)
* @version 3.00
*
* @since 2.0
* @module
*/
@Immutable
final class Properties extends AbstractMap {
/**
* The object where all properties come from.
*/
private final IdentifiedObject info;
/**
* The entries set. Will be constructed only when first needed.
*/
private transient Set> entries;
/**
* Creates new properties from the specified identified object.
*/
Properties(final IdentifiedObject info) {
this.info = info;
}
/**
* Returns true if this map contains a mapping for the specified key.
*/
@Override
public boolean containsKey(final Object key) {
return get(key) != null;
}
/**
* Returns the value to which this map maps the specified key.
* Returns {@code null} if the map contains no mapping for this key.
*/
@Override
public Object get(final Object key) {
if (key instanceof String) {
final String s = ((String) key).trim();
for (int i=0; iThe index of each element in this array
* must matches the index searched by {@link #get(int)}.
*
* @todo Add properties for {@link IdentifiedObject} sub-interfaces.
*/
private static final String[] KEYS = {
/*[0]*/ IdentifiedObject .NAME_KEY,
/*[1]*/ IdentifiedObject .IDENTIFIERS_KEY,
/*[2]*/ IdentifiedObject .ALIAS_KEY,
/*[3]*/ IdentifiedObject .REMARKS_KEY,
/*[4]*/ CoordinateOperation .SCOPE_KEY, // same in Datum and ReferenceSystem
/*[5]*/ CoordinateOperation .DOMAIN_OF_VALIDITY_KEY, // same in Datum and ReferenceSystem
/*[6]*/ CoordinateOperation .OPERATION_VERSION_KEY,
/*[7]*/ CoordinateOperation .COORDINATE_OPERATION_ACCURACY_KEY
};
/**
* Returns a set view of the mappings contained in this map.
*/
@Override
public Set> entrySet() {
if (entries == null) {
entries = new HashSet>(hashMapCapacity(KEYS.length));
for (int i=0; i(KEYS[i], value));
}
}
entries = XCollections.unmodifiableSet(entries);
}
return entries;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy