AbstractIdentifiedObject changes for revisions 7711:7857

Command line:

svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r7711:7857 https://svn.osgeo.org/geotools/trunk/modules/library/referencing/src/main/java/org/geotools/referencing/AbstractIdentifiedObject.java
Revision 7711Revision 7857
package org.geotools.referencing;

// J2SE dependencies
import java.util.Map;
import java.util.Locale;
import java.util.Iterator;
package org.geotools.referencing;

// J2SE dependencies
import java.util.HashMap;
import java.util.Map;
import java.util.Locale;
import java.util.Iterator;
import org.opengis.parameter.InvalidParameterValueException;

// Geotools dependencies
import org.geotools.util.WeakHashSet;
import org.geotools.resources.Utilities;
import org.geotools.resources.cts.Resources;
import org.geotools.resources.cts.ResourceKeys;
import org.geotools.referencing.wkt.Formattable;


/**
 * A base class for metadata applicable to reference system objects.
 * When {@link AuthorityFactory} is used to create an object, the
import org.opengis.parameter.InvalidParameterValueException;

// Geotools dependencies
import org.geotools.resources.Utilities;
import org.geotools.resources.cts.Resources;
import org.geotools.resources.cts.ResourceKeys;
import org.geotools.referencing.wkt.Formattable;
import org.geotools.util.InternationalString;

/**
 * A base class for metadata applicable to reference system objects.
 * When {@link AuthorityFactory} is used to create an object, the
public class IdentifiedObject extends Formattable
                           implements org.opengis.referencing.IdentifiedObject, Serializable
{
    /**
     * Serial number for interoperability with different versions.
     */
public class IdentifiedObject extends Formattable
                           implements org.opengis.referencing.IdentifiedObject, Serializable
{

    /** "name" Key used to provide String for getName() */
    public static final String NAME_PROPERTY = "name";

    /** "remarks" Key used to provide String for getRemarks() */
    public static final String REMARKS_PROPERTY = "remarks";

    /**
     * Serial number for interoperability with different versions.
     */
 * The name for this object or code. Should never be <code>null</code>.
 * Keys are {@link Locale} objects and values are {@link String}.
 */
private final Map name;

/**
 * Set of alternative identifications of this object. The first identifier, if
 * any, is normally the primary identification code, and any others are aliases.
 * The name for this object or code. Should never be <code>null</code>.
 * Keys are {@link Locale} objects and values are {@link String}.
 */
//private final Map name;
private final InternationalString name;
/**
 * Set of alternative identifications of this object. The first identifier, if
 * any, is normally the primary identification code, and any others are aliases.
 * Comments on or information about this object, or <code>null</code> if none.
 * Keys are {@link Locale} objects and values are {@link String}.
 */
private final Map remarks;

/**
 * Constructs an object from a set of properties. Keys are strings from the table below.
 * Key are case-insensitive, and leading and trailing spaces are ignored. The map given in
 * Comments on or information about this object, or <code>null</code> if none.
 * Keys are {@link Locale} objects and values are {@link String}.
 */
// private final Map remarks;
private final InternationalString remarks;

static private final Map defaultMap( String objectName, String objectDescription ){
    Map map = new HashMap();
    map.put( NAME_PROPERTY, objectName );
    map.put( REMARKS_PROPERTY, objectDescription );
    return map;
}
public IdentifiedObject( String objectName, String objectDescription ) throws IllegalArgumentException {
    this( defaultMap( objectName, objectDescription ));
}
/**
 * Constructs an object from a set of properties. Keys are strings from the table below.
 * Key are case-insensitive, and leading and trailing spaces are ignored. The map given in
        throws IllegalArgumentException
{
    ensureNonNull("properties", properties);
    Map          name        = null;
    Map          remarks     = null;
    Identifier[] identifiers = null;
    /*
     * Iterate through each map entry. This have two purposes:
        throws IllegalArgumentException
{
    ensureNonNull("properties", properties);

    InternationalString name        = new org.geotools.util.InternationalString();
    InternationalString remarks     = new org.geotools.util.InternationalString();
    Identifier[] identifiers = null;
    /*
     * Iterate through each map entry. This have two purposes:
         * This algorithm is sub-optimal if the map contains a lot of entries of no interest to
         * this identifier. Hopefully, most users will fill a map only with usefull entries.
         */
check:  for (final Iterator it=properties.entrySet().iterator(); it.hasNext();) {
            Map.Entry entry = (Map.Entry) it.next();
            String    key   = ((String) entry.getKey()).trim().toLowerCase();
            Object    value = entry.getValue();
         * This algorithm is sub-optimal if the map contains a lot of entries of no interest to
         * this identifier. Hopefully, most users will fill a map only with usefull entries.
         */
CHECK:  for (final Iterator it=properties.entrySet().iterator(); it.hasNext();) {
            Map.Entry entry = (Map.Entry) it.next();
            String    key   = ((String) entry.getKey()).trim().toLowerCase();
            Object    value = entry.getValue();
switch (key.hashCode()) {
    case 1368189162: {
        if (key.equals("identifiers")) {
            identifiers = (Identifier[]) value;
            if (identifiers != null) {
                identifiers = (Identifier[]) identifiers.clone();
            }
            continue check;
        }
    }
    // Fix case for common keywords.
switch (key.hashCode()) {
    case 1368189162: {
        if (key.equals("identifiers")) {
            if (value != null) {
                Identifier origional[] = (Identifier[]) value;
                identifiers = (Identifier[]) (origional.clone());
            }
            continue CHECK;
        }
    }
    // Fix case for common keywords.
    case  1127093059: if (key.equals("realizationepoch")) key="realizationEpoch"; break;
    case -1109785975: if (key.equals("validarea"))        key="validArea";        break;
}
Locale locale = getLocale(key, "name");
if (locale != null) {
    name = addLocalizedString(name, locale, value);
    continue check;
}
locale = getLocale(key, "remarks");
if (locale != null) {
    remarks = addLocalizedString(remarks, locale, value);
    continue check;
}
if (localizables != null) {
    for (int i=0; i<localizables.length; i++) {
        final String prefix = localizables[i];
    case  1127093059: if (key.equals("realizationepoch")) key="realizationEpoch"; break;
    case -1109785975: if (key.equals("validarea"))        key="validArea";        break;
}
Locale locale = getLocale(key, NAME_PROPERTY );
if (locale != null) {
    if( value instanceof String ){
        name.addLocalizedString( locale, (String) value);
        continue CHECK;
}
    else if ( value instanceof InternationalString ){
        name = (InternationalString) value;
        continue CHECK;
    }
}
locale = getLocale(key, REMARKS_PROPERTY );
if (locale != null) {
    if( value instanceof String ){
        remarks.addLocalizedString( locale, (String) value);
        continue CHECK;
}
    if ( value instanceof InternationalString ){
        remarks = (InternationalString) value;
        continue CHECK;
    }
}
if (localizables != null) {
    for (int i=0; i<localizables.length; i++) {
        final String prefix = localizables[i];
                    Map map = (Map)subProperties.get(prefix);
                    map = addLocalizedString(map, locale, value);
                    subProperties.put(prefix, map);
                    continue check;
                }
            }
        }
        subProperties.put(key, value);
    }
    this.name        = name;
    this.identifiers = identifiers;
    this.remarks     = remarks;
    ensureNonNull("name", name);
    ensureNonNull("name", name.get(null));
    org.geotools.referencing.Identifier.canonicalizeKeys(name);
    org.geotools.referencing.Identifier.canonicalizeKeys(remarks);
}

/**
                    Map map = (Map)subProperties.get(prefix);
                    map = addLocalizedString(map, locale, value);
                    subProperties.put(prefix, map);
                    continue CHECK;
                }
            }
        }
        if( subProperties != null ){
        subProperties.put(key, value);
    }
    }
    this.name        = name;
    this.identifiers = identifiers;
    this.remarks     = remarks;
    ensureNonNull("name", name);
    ensureNonNull("name", name.toString());
    //org.geotools.referencing.Identifier.canonicalizeKeys(name);
    //org.geotools.referencing.Identifier.canonicalizeKeys(remarks);
}

/**
 * @return The name, or <code>null</code> if not available.
 */
public String getName(final Locale locale) {
    return getLocalized(name, locale);
}

/**
 * Set of alternative identifications of this object. The first identifier, if
 * any, is normally the primary identification code, and any others are aliases.
 * @return The name, or <code>null</code> if not available.
 */
public String getName(final Locale locale) {
    if( locale == null ){
        return name.toString();
}
    return name.toString( locale );
}
public org.opengis.util.InternationalString getName(){
    return name;
}
/**
 * Set of alternative identifications of this object. The first identifier, if
 * any, is normally the primary identification code, and any others are aliases.
 * @return The remarks, or <code>null</code> if not available.
 */
public String getRemarks(final Locale locale) {
    return getLocalized(remarks, locale);
}

/**
 * Returns a hash value for this info. {@linkplain #getName Name},
 * @return The remarks, or <code>null</code> if not available.
 */
public String getRemarks(final Locale locale) {
    if( locale == null ){
        return remarks.toString();
}
    return remarks.toString( locale);
}
public org.opengis.util.InternationalString getRemarks(){
    return remarks;
}

/**
 * Returns a hash value for this info. {@linkplain #getName Name},
{
    identifier = identifier.trim();
    if (identifiers==null || identifiers.length==0) {
        return identifier.equalsIgnoreCase(info.getName(null).trim());
    }
    final String code, codespace;
    final int separator = identifier.indexOf(':');
{
    identifier = identifier.trim();
    if (identifiers==null || identifiers.length==0) {
        return identifier.equalsIgnoreCase(info.getName().toString(null).trim());
    }
    final String code, codespace;
    final int separator = identifier.indexOf(':');