/** * Returns the value associated to the given name. * * @param store the data store for which to get a value, or {@code null} if unknown. * @param name the name for which to get a value. * @return value associated to the given object. * @throws IllegalNameException if the given name was not found or is ambiguous. */ public E get(final DataStore store, final String name) throws IllegalNameException { final E value = values.get(name); if (value != null) { return value; } final short key; final Object[] params; final List<String> nc = aliases.get(name); if (nc == null) { key = Resources.Keys.FeatureNotFound_2; params = new CharSequence[] {name(store), name}; } else if (nc.size() >= 2) { key = Resources.Keys.AmbiguousName_4; params = new CharSequence[] {name(store), nc.get(0), nc.get(1), name}; } else { return null; // Name was explicitely associated to null value (actually not allowed by current API). } throw new IllegalNameException(locale(store), key, params); }
/** * Returns the value associated to the given name. * * @param store the data store for which to get a value, or {@code null} if unknown. * @param name the name for which to get a value. * @return value associated to the given object. * @throws IllegalNameException if the given name was not found or is ambiguous. */ public E get(final DataStore store, final String name) throws IllegalNameException { final E value = values.get(name); if (value != null) { return value; } final short key; final Object[] params; final List<String> nc = aliases.get(name); if (nc == null) { key = Resources.Keys.FeatureNotFound_2; params = new CharSequence[] {name(store), name}; } else if (nc.size() >= 2) { key = Resources.Keys.AmbiguousName_4; params = new CharSequence[] {name(store), nc.get(0), nc.get(1), name}; } else { return null; // Name was explicitly associated to null value (actually not allowed by current API). } throw new IllegalNameException(locale(store), key, params); }
/** * Searches for a resource identified by the given identifier. The given identifier should be the string * representation of the return value of {@link Resource#getIdentifier()} on the desired resource. * Implementation may also accept aliases for convenience. For example if the full name of a resource * is {@code "foo:bar"}, then this method may accept {@code "bar"} as a synonymous of {@code "foo:bar"} * provided that it does not introduce ambiguity. * * <p>The default implementation verifies if above criterion matches to this {@code DataStore} * (which is itself a resource), then iterates recursively over {@link Aggregate} components * if this data store is an aggregate. * If a match is found without ambiguity, the associated resource is returned. Otherwise an exception is thrown. * Subclasses are encouraged to override this method with a more efficient implementation.</p> * * @param identifier identifier of the resource to fetch. Must be non-null. * @return resource associated to the given identifier (never {@code null}). * @throws IllegalNameException if no resource is found for the given identifier, or if more than one resource is found. * @throws DataStoreException if another kind of error occurred while searching resources. * * @see Resource#getIdentifier() * @see FeatureNaming */ public Resource findResource(final String identifier) throws DataStoreException { ArgumentChecks.ensureNonEmpty("identifier", identifier); final Resource resource = findResource(identifier, this, new IdentityHashMap<>()); if (resource != null) { return resource; } throw new IllegalNameException(StoreUtilities.resourceNotFound(this, identifier)); }
throw new IllegalNameException(locale(store), Resources.Keys.InconsistentNameComponents_2, name(store), key);
throw new IllegalNameException(locale(store), Resources.Keys.InconsistentNameComponents_2, name(store), key);
/** * Returns the image at the given index. Images numbering starts at 1. * * @param sequence string representation of the image index, starting at 1. * @return image at the given index. * @throws DataStoreException if the requested image can not be obtained. */ @Override public GridCoverageResource findResource(final String sequence) throws DataStoreException { Exception cause; int index; try { index = Integer.parseInt(sequence); cause = null; } catch (NumberFormatException e) { index = 0; cause = e; } if (index > 0) try { ImageFileDirectory image = reader().getImageFileDirectory(index - 1); if (image != null) return image; } catch (IOException e) { throw errorIO(e); } throw new IllegalNameException(StoreUtilities.resourceNotFound(this, sequence), cause); }
throw new ConcurrentModificationException(name(store).toString()); // Paranoiac check. throw new IllegalNameException(locale(store), Resources.Keys.FeatureAlreadyPresent_2, name(store), key);
throw new ConcurrentModificationException(name(store).toString()); // Paranoiac check. throw new IllegalNameException(locale(store), Resources.Keys.FeatureAlreadyPresent_2, name(store), key);
return resource; throw new IllegalNameException(Resources.forLocale(getLocale()) .getString(Resources.Keys.ResourceNotFound_2, getDisplayName(), identifier));
result = match; } else { throw new IllegalNameException(Resources.forLocale(getLocale()) .getString(Resources.Keys.ResourceIdentifierCollision_2, getDisplayName(), identifier));
final int depth = name.depth(); if (depth < 1 || depth > 3) { throw new IllegalNameException(Resources.format(Resources.Keys.IllegalQualifiedName_1, name));
result = match; } else { throw new IllegalNameException(Resources.forLocale(getLocale()) .getString(Resources.Keys.ResourceIdentifierCollision_2, getDisplayName(), identifier));