/** * Compares this name with the specified object for order. Returns a negative integer, zero, or * a positive integer as this name lexicographically precedes, is equals to, or follows the * specified object. The comparaison is case-insensitive. */ @Override public int compareTo(final GenericName object) { return toString().compareToIgnoreCase(object.toString()); }
/** * Returns a string representation of this generic name. This string representation is * local-independant. It contains all elements listed by {@link #getParsedNames} separated by an * arbitrary character (usually {@code :} or {@code /}). */ @Override public String toString() { return getName().toString(); }
/** * Puts all elements in the {@code names} array into the specified map. Order matter, since the * first element in the array should be the first element returned by the map if the map is * actually an instance of {@link LinkedHashMap}. This method returns the number of elements * ignored. */ private static final int putAll(final GenericName[] names, final Map<String, GenericName> map) { int ignored = 0; for (int i = 0; i < names.length; i++) { final GenericName name = names[i]; final GenericName scoped = name.toFullyQualifiedName(); final String key = toCaseless(scoped.toString()); final GenericName old = map.put(key, name); if (old instanceof ScopedName) { map.put(key, old); // Preserves the user value, except if it was unscoped. ignored++; } } return ignored; }
/** * Puts all elements in the {@code names} array into the specified map. Order matter, since the * first element in the array should be the first element returned by the map if the map is * actually an instance of {@link LinkedHashMap}. This method returns the number of elements * ignored. */ private static final int putAll(final GenericName[] names, final Map<String, GenericName> map) { int ignored = 0; for (int i = 0; i < names.length; i++) { final GenericName name = names[i]; final GenericName scoped = name.toFullyQualifiedName(); final String key = toCaseless(scoped.toString()); final GenericName old = map.put(key, name); if (old instanceof ScopedName) { map.put(key, old); // Preserves the user value, except if it was unscoped. ignored++; } } return ignored; }
/** * Implementation of {@code nameMatches} method. * * @param object The object to check. * @param alias The list of alias in {@code object} (may be {@code null}). This method will * never modify this list. Consequently, it may be a direct reference to an internal array. * @param name The name. * @return {@code true} if the primary name of at least one alias matches the specified {@code * name}. */ private static boolean nameMatches( final IdentifiedObject object, final Collection<GenericName> alias, String name) { name = name.trim(); if (name.equalsIgnoreCase(object.getName().getCode().trim())) { return true; } if (alias != null) { for (final GenericName asName : alias) { final GenericName asScoped = asName.toFullyQualifiedName(); if (asScoped != asName && name.equalsIgnoreCase(asScoped.toString().trim())) { return true; } if (name.equalsIgnoreCase(asName.tip().toString().trim())) { return true; } } } return false; }
/** * Produce a good key based on the privided citaiton and code. You can think of the citation as * being "here" and the code being the "what". * * @param code Code * @return A good key for use with ObjectCache */ public static String toKey(Citation citation, String code) { code = code.trim(); final GenericName name = NameFactory.create(code); final GenericName scope = name.scope().name(); if (scope == null) { return code; } if (citation != null && Citations.identifierMatches(citation, scope.toString())) { return name.tip().toString().trim(); } return code; }
/** * Trims the authority scope, if present. If more than one authority were given at {@linkplain * #PropertyAuthorityFactory(ReferencingFactoryContainer, Citation[], URL) construction time}, * then any of them may appears as the scope in the supplied code. * * @param code The code to trim. * @return The code without the authority scope. */ @Override protected String trimAuthority(String code) { code = code.trim(); final GenericName name = NameFactory.create(code); final GenericName scope = name.scope().name(); if (scope == null) { return code; } final String candidate = scope.toString(); for (int i = 0; i < authorities.length; i++) { if (Citations.identifierMatches(authorities[i], candidate)) { return name.tip().toString().trim(); } } return code; }
/** * Trims the authority scope, if present. For example if this factory is an EPSG authority * factory and the specified code start with the "EPSG:" prefix, then the prefix is removed. * Otherwise, the string is returned unchanged (except for leading and trailing spaces). * * @param code The code to trim. * @return The code without the authority scope. */ protected String trimAuthority(String code) { /* * IMPLEMENTATION NOTE: This method is overridden in * PropertyAuthorityFactory. If the implementation below is modified, it * is probably worth revisiting the overridden method as well. */ code = code.trim(); final GenericName name = NameFactory.create(code); final GenericName scope = name.scope().name(); if (scope == null) { return code; } if (Citations.identifierMatches(getAuthority(), scope.toString())) { return name.tip().toString().trim(); } return code; }
/** * Trims the authority scope, if present. For example if this factory is an EPSG authority * factory and the specified code start with the "EPSG:" prefix, then the prefix is removed. * Otherwise, the string is returned unchanged (except for leading and trailing spaces). * * @param code The code to trim. * @return The code without the authority scope. */ protected String trimAuthority(String code) { /* * IMPLEMENTATION NOTE: This method is overrided in PropertyAuthorityFactory. If * implementation below is modified, it is probably worth to revisit the overrided * method as well. */ code = code.trim(); final GenericName name = NameFactory.create(code); final GenericName scope = name.scope().name(); if (scope == null) { return code; } if (Citations.identifierMatches(getAuthority(), scope.toString())) { return name.tip().toString().trim(); } return code; }
final GenericName id = (GenericName) it.next(); try { candidate = getProxy().create(id.toString()); } catch (FactoryException e) {
final Object title; if (scope != null) { if (scopes != null && !scopes.contains(scope.toString())) {
final GenericName scope = alias.scope().name(); if (scope != null) { if (title.equalsIgnoreCase(scope.toString())) { return alias.tip().toString();
/** * Creates a new attribute which will delegate its work to the given feature. */ private AttributeView(final AbstractFeature feature, final DefaultAttributeType<V> type) { super(type); this.feature = feature; this.name = type.getName().toString(); }
/** * Returns the namespace of the names created by {@code setName(CharSequence...)} method calls. * A {@code null} value means that the names are in the * {@linkplain org.apache.sis.util.iso.DefaultNameSpace#isGlobal() global namespace}. * * @return the namespace to use when {@link #setName(CharSequence)} is invoked, or {@code null} if none. */ public CharSequence getNameSpace() { return (namespace != null) ? namespace.name().toString() : null; }
/** * Returns the attribute characteristic name. */ @Override protected String getKey() { return value.getName().toString(); }
/** * Returns the name to be given to {@link DefaultLocalName} constructors. */ private static CharSequence name(final GenericName name) { if (name instanceof DefaultLocalName) { return ((DefaultLocalName) name).name; } final InternationalString label = name.toInternationalString(); return (label != null) ? label : name.toString(); }
final GenericName scope = alias.scope().name(); if (scope != null) { if (Citations.identifierMatches(authority, scope.toString())) { name = alias.tip().toString(); break;
/** * Null-safe getter for the namespace argument to be given to {@link #toClass(String, String)}. */ static String namespace(final NameSpace ns) { if (ns != null && !ns.isGlobal()) { final GenericName name = ns.name(); if (name != null) { return name.toString(); } } return null; }
/** * Returns the name to use for displaying error messages. */ final String getDisplayName() { final GenericName name = getName(); return (name != null) ? name.toString() : Vocabulary.getResources(identification).getString(Vocabulary.Keys.Unnamed); }
assertEquals( "Authority", author, parameters.getName().getAuthority().getTitle().toString()); assertEquals("Vendor", vendor, alias.scope().name().toString()); assertNotNull("Version", parameters.getName().getVersion()); assertLocalized("Vendor", alias.scope().name().toInternationalString());