Class DataStoreParams

java.lang.Object
org.codelibs.fess.entity.DataStoreParams

public class DataStoreParams extends Object
Parameter container class for data store configurations and runtime parameters. This class provides a convenient wrapper around a Map to store and retrieve data store specific parameters with type-safe access methods.

The class uses a ParamMap internally which provides case format conversion between camelCase and snake_case parameter names for flexible parameter access. Parameters can be stored as any Object type and retrieved with type conversion support for common types like String.

This class is commonly used to pass configuration parameters to data store implementations during crawling operations, allowing for flexible parameter handling without tight coupling to specific parameter schemas.

  • Field Details

    • params

      protected final Map<String,Object> params
      Internal map storing parameter key-value pairs. Uses ParamMap for automatic case format conversion between camelCase and snake_case.
  • Constructor Details

    • DataStoreParams

      public DataStoreParams()
      Creates a new empty DataStoreParams instance. Initializes the internal parameter map with a ParamMap wrapper.
    • DataStoreParams

      protected DataStoreParams(Map<String,Object> params)
      Creates a new DataStoreParams instance with a copy of the provided parameters. This protected constructor is used for creating new instances from existing parameter maps.
      Parameters:
      params - the parameter map to copy, must not be null
  • Method Details

    • put

      public void put(String key, Object value)
      Stores a parameter value with the specified key.
      Parameters:
      key - the parameter key, must not be null
      value - the parameter value, may be null
    • get

      public Object get(String key)
      Retrieves a parameter value by key.
      Parameters:
      key - the parameter key to look up
      Returns:
      the parameter value if found, null otherwise
    • getAsString

      public String getAsString(String key)
      Retrieves a parameter value as a String. If the stored value is already a String, it is returned directly. Otherwise, the toString() method is called on the value.
      Parameters:
      key - the parameter key to look up
      Returns:
      the parameter value as a String, null if not found or value is null
    • getAsString

      public String getAsString(String key, String defaultValue)
      Retrieves a parameter value as a String with a default value fallback.
      Parameters:
      key - the parameter key to look up
      defaultValue - the default value to return if key is not found or value is null
      Returns:
      the parameter value as a String, or defaultValue if not found
    • newInstance

      public DataStoreParams newInstance()
      Creates a new DataStoreParams instance with a copy of the current parameters. This provides an independent copy that can be modified without affecting the original.
      Returns:
      a new DataStoreParams instance containing a copy of the current parameters
    • putAll

      public void putAll(Map<String,String> map)
      Adds all key-value pairs from the specified map to this parameter container.
      Parameters:
      map - the map containing parameters to add, must not be null
    • containsKey

      public boolean containsKey(String key)
      Checks if the specified key exists in the parameter map.
      Parameters:
      key - the key to check for existence
      Returns:
      true if the key exists, false otherwise
    • asMap

      public Map<String,Object> asMap()
      Returns a copy of the internal parameter map as a standard Map. The returned map is a copy and modifications will not affect this instance.
      Returns:
      a new Map containing all current parameters
    • getDataMap

      protected static Map<String,Object> getDataMap(Map<String,Object> params)
      Extracts the underlying data map from a parameter map. If the provided map is a ParamMap instance, returns its parent map. Otherwise, returns the map as-is.
      Parameters:
      params - the parameter map to extract data from
      Returns:
      the underlying data map