/** Constructs a generic name from the specified authority and code. */ private GenericName getName(final Citation authority, final CharSequence code) { if (authority == null) { return new org.geotools.util.LocalName(code); } final CharSequence title; if (codespace != null) { title = codespace; } else { title = getShortestTitle(authority); } GenericName scope; synchronized (NamedIdentifier.class) { if (SCOPES == null) { SCOPES = new WeakValueHashMap<CharSequence, GenericName>(); } scope = SCOPES.get(title); if (scope == null) { scope = new org.geotools.util.LocalName(title); SCOPES.put(title, scope); } } return new org.geotools.util.ScopedName(scope, code); }
/** * Tries to get a codespace from the specified authority. This method scan first through the * identifier, then through the titles if no suitable identifier were found. */ private static String getCodeSpace(final Citation authority) { final Collection<? extends Identifier> identifiers = authority.getIdentifiers(); if (identifiers != null) { for (final Identifier id : identifiers) { final String identifier = id.getCode(); if (isValidCodeSpace(identifier)) { return identifier; } } } // The "null" locale argument is required for getting the unlocalized version. final String title = getShortestTitle(authority).toString(null); if (isValidCodeSpace(title)) { return title; } return null; }