/** * Returns a data store implementation associated with this provider for the given parameters. * * @param parameters opening parameters as defined by {@link #getOpenParameters()}. * @return a data store implementation associated with this provider for the given parameters. * @throws DataStoreException if an error occurred while creating the data store instance. */ @Override public DataStore open(final ParameterValueGroup parameters) throws DataStoreException { ArgumentChecks.ensureNonNull("parameters", parameters); try { final Parameters p = Parameters.castOrWrap(parameters); final StorageConnector connector = new StorageConnector(p.getValue(SOURCE_PARAM)); final GenericName[] tableNames = p.getValue(TABLES_PARAM); return new SQLStore(this, connector, tableNames); } catch (ParameterNotFoundException | UnconvertibleObjectException e) { throw new IllegalOpenParameterException(e.getMessage(), e); } } }
/** * Creates a storage connector initialized to the location declared in given parameters. * This convenience method does not set any other parameters. * In particular, reading (or ignoring) the {@value #CREATE} parameter is left to callers, * because not all implementations may create data stores with {@link java.nio.file.StandardOpenOption}. * * @param provider the provider for which to create a storage connector (for error messages). * @param parameters the parameters to use for creating a storage connector. * @return the storage connector initialized to the location specified in the parameters. * @throws IllegalOpenParameterException if no {@value #LOCATION} parameter has been found. */ public static StorageConnector connector(final DataStoreProvider provider, final ParameterValueGroup parameters) throws IllegalOpenParameterException { ParameterNotFoundException cause = null; if (parameters != null) try { final Object location = parameters.parameter(LOCATION).getValue(); if (location != null) { return new StorageConnector(location); } } catch (ParameterNotFoundException e) { cause = e; } throw new IllegalOpenParameterException(Resources.format(Resources.Keys.UndefinedParameter_2, provider.getShortName(), LOCATION), cause); } }
throw new IllegalOpenParameterException(Resources.format(Resources.Keys.UndefinedParameter_2, getShortName(), LOCATION), cause);
/** * Returns a data store implementation associated with this provider for the given parameters. * * @return a folder data store implementation for the given parameters. * @throws DataStoreException if an error occurred while creating the data store instance. */ @Override public DataStore open(final ParameterValueGroup parameters) throws DataStoreException { ArgumentChecks.ensureNonNull("parameter", parameters); ParameterNotFoundException cause = null; try { final Object location = parameters.parameter(LOCATION).getValue(); if (location != null) { final Parameters pg = Parameters.castOrWrap(parameters); final StorageConnector connector = new StorageConnector(location); connector.setOption(OptionKey.LOCALE, pg.getValue(LOCALE)); connector.setOption(OptionKey.TIMEZONE, pg.getValue(TIMEZONE)); connector.setOption(OptionKey.ENCODING, pg.getValue(ENCODING)); return open(connector); } } catch (ParameterNotFoundException e) { cause = e; } throw new IllegalOpenParameterException(Resources.format(Resources.Keys.UndefinedParameter_2, getShortName(), LOCATION), cause); }