gt:         Charset dbfCharset = lookup(DBFCHARSET, params, Charset.class);
context: /*
   *    GeoTools - The Open Source Java GIS Toolkit
   *    http://geotools.org
   *
   *    (C) 2002-2011, Open Source Geospatial Foundation (OSGeo)
   *
   *    This library is free software; you can redistribute it and/or
   *    modify it under the terms of the GNU Lesser General Public
   *    License as published by the Free Software Foundation;
   *    version 2.1 of the License.
   *
   *    This library is distributed in the hope that it will be useful,
   *    but WITHOUT ANY WARRANTY; without even the implied warranty of
   *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   *    Lesser General Public License for more details.
   */
  package org.geotools.data.shapefile;
  
  import java.awt.RenderingHints.Key;
  import java.io.File;
  import java.io.FileFilter;
  import java.io.IOException;
  import java.net.URI;
  import java.net.URL;
  import java.nio.charset.Charset;
  import java.nio.charset.StandardCharsets;
  import java.util.Arrays;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.Map;
  import java.util.TimeZone;
  import java.util.logging.Logger;
  import org.geotools.data.DataStore;
  import org.geotools.data.DataUtilities;
  import org.geotools.data.FileDataStore;
  import org.geotools.data.FileDataStoreFactorySpi;
  import org.geotools.data.directory.DirectoryDataStore;
  import org.geotools.data.directory.FilteringFileStoreFactory;
  import org.geotools.data.shapefile.files.ShpFiles;
  import org.geotools.util.KVP;
  import org.geotools.util.URLs;
  import org.geotools.util.logging.Logging;
  
  /** Builds instances of the shapefile data store */
  public class ShapefileDataStoreFactory implements FileDataStoreFactorySpi {
  
      static final Logger LOGGER = Logging.getLogger(ShapefileDataStoreFactory.class);
  
      /** url to the .shp file. */
      public static final Param URLP =
              new Param(
                      "url", URL.class, "url to a .shp file", true, null, new KVP(Param.EXT, "shp"));
  
      /**
       * This system property will enable "DBF charset autodetection from CPG sidecar file" feature.
       */
      public static final String ENABLE_CPG_SWITCH = "org.geotools.shapefile.enableCPG";
  
      /** Optional - uri of the FeatureType's namespace */
      public static final Param NAMESPACEP =
              new Param(
                      "namespace",
                      URI.class,
                      "uri to a the namespace",
                      false,
                      null, // not required
                      new KVP(Param.LEVEL, "advanced"));
  
      /** Optional - enable/disable the use of memory-mapped io */
      public static final Param MEMORY_MAPPED =
              new Param(
                      "memory mapped buffer",
                      Boolean.class,
                      "enable/disable the use of memory-mapped io",
                      false,
                      false,
                      new KVP(Param.LEVEL, "advanced"));
  
      /** Optional - enable/disable the use of memory-mapped io */
      public static final Param CACHE_MEMORY_MAPS =
              new Param(
                      "cache and reuse memory maps",
                      Boolean.class,
                      "only memory map a file one, then cache and reuse the map",
                      false,
                      true,
                      new KVP(Param.LEVEL, "advanced"));
  
      /** Optional - discriminator for directory stores */
      public static final Param FILE_TYPE =
              new Param(
                      "filetype",
                      String.class,
                      "Discriminator for directory stores",
                      false,
                      "shapefile",
                      new KVP(Param.LEVEL, "program"));
  
      /** Optional - Enable/disable the automatic creation of spatial index */
      public static final Param CREATE_SPATIAL_INDEX =
              new Param(
                      "create spatial index",
                      Boolean.class,
                      "enable/disable the automatic creation of spatial index",
                      false,
                      true,
                      new KVP(Param.LEVEL, "advanced"));
  
      /**
       * Optional - character used to decode strings from the DBF file. If none is provided, the
       * factory will instruct {@link ShapefileDataStore} to try to guess a charset from CPG file,
       * before using a default value.
       *
       * @see ShapefileDataStore#setTryCPGFile(boolean)
       */
      public static final Param DBFCHARSET =
              new Param(
                      "charset",
                      Charset.class,
                      "character used to decode strings from the DBF file",
                      false,
                      StandardCharsets.ISO_8859_1,
                      new KVP(Param.LEVEL, "advanced")) {
                  /*
                   * This is an example of a non simple Param type where a custom parse method is required.
                   *
                   * @see org.geotools.data.DataStoreFactorySpi.Param#parse(java.lang.String)
                   */
                  @Override
                  public Object parse(String text) throws IOException {
                      return Charset.forName(text);
                  }
  
                  @Override
                  public String text(Object value) {
                      return ((Charset) value).name();
                  }
              };
      /**
       * Optional parameter used to indicate 'shape-ng' (as a marker to select the implementation of
       * DataStore to use).
       */
      public static final Param FSTYPE =
              new Param(
                      "fstype",
                      String.class,
                      "Enable using a setting of 'shape'.",
                      false,
                      "shape",
                      new KVP(
                              Param.LEVEL,
                              "advanced",
                              Param.OPTIONS,
                              Arrays.asList(new String[] {"shape-ng", "shape", "index"})));
      /** Optional - timezone to decode dates from the DBF file */
      public static final Param DBFTIMEZONE =
              new Param(
                      "timezone",
                      TimeZone.class,
                      "time zone used to read dates from the DBF file",
                      false,
                      TimeZone.getDefault(),
                      new KVP(Param.LEVEL, "advanced")) {
  
                  @Override
                  public Object parse(String text) throws IOException {
                      return TimeZone.getTimeZone(text);
                  }
  
                  @Override
                  public String text(Object value) {
                      return ((TimeZone) value).getID();
                  }
              };
  
      /** Optional - enable spatial index for local files */
      public static final Param ENABLE_SPATIAL_INDEX =
              new Param(
                      "enable spatial index",
                      Boolean.class,
                      "enable/disable the use of spatial index for local shapefiles",
                      false,
                      true,
                      new KVP(Param.LEVEL, "advanced"));
  
      /** Optional - skip the scan for alternative shapefile extensions (i.e. .SHP, .shp.XML, ...) */
      public static final Param SKIP_SCAN =
              new Param(
                      "skipScan",
                      Boolean.class,
                      "Skip scan for alternative shapefile extensions (i.e. .SHP, .shp.XML, ...)",
                      false,
                      true,
                      new KVP(Param.LEVEL, "advanced"));
  
      @Override
      public String getDisplayName() {
          return "Shapefile";
      }
  
      @Override
      public String getDescription() {
          return "ESRI(tm) Shapefiles (*.shp)";
      }
  
      @Override
      public Param[] getParametersInfo() {
          return new Param[] {
              URLP,
              NAMESPACEP,
              ENABLE_SPATIAL_INDEX,
              CREATE_SPATIAL_INDEX,
              DBFCHARSET,
              DBFTIMEZONE,
              MEMORY_MAPPED,
              CACHE_MEMORY_MAPS,
              FILE_TYPE,
              FSTYPE,
              SKIP_SCAN
          };
      }
  
      @Override
      public boolean isAvailable() {
          return true;
      }
  
      @Override
      public Map<Key, ?> getImplementationHints() {
          return Collections.emptyMap();
      }
  
      @Override
      public DataStore createDataStore(Map<String, ?> params) throws IOException {
          URL url = lookup(URLP, params, URL.class);
          Boolean isMemoryMapped = lookup(MEMORY_MAPPED, params, Boolean.class);
          Boolean cacheMemoryMaps = lookup(CACHE_MEMORY_MAPS, params, Boolean.class);
          URI namespace = lookup(NAMESPACEP, params, URI.class);
  