Class PslDataProvider
The `PslDataProvider` class is responsible for managing and providing access to the Public Suffix List (PSL) data. The PSL data is used to determine the domain suffixes that are considered public, which is essential for various domain validation and security operations. This class ensures that only one instance of the PSL data is loaded and provides methods to load, access, and reset the PSL data.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final PslDataProvider
The singleton instance of the PslDataProvider.private PslData
The PSL data. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Private constructor to prevent instantiation. -
Method Summary
Modifier and TypeMethodDescriptionstatic PslDataProvider
Returns the singleton instance of the PslDataProvider.void
Loads the default PSL data from the resource file.void
loadPslData
(Reader reader) Loads PSL data from the provided reader.(package private) void
Resets the PSL data, clearing any loaded data.
-
Field Details
-
INSTANCE
The singleton instance of the PslDataProvider. -
pslData
The PSL data.This field holds the Public Suffix List (PSL) data that is loaded by the `PslDataProvider`. The PSL data is essential for determining the public suffixes of domain names. This field is initialized when the PSL data is loaded using the `loadPslData` or `loadDefaultData` methods.
-
-
Constructor Details
-
PslDataProvider
private PslDataProvider()Private constructor to prevent instantiation.
-
-
Method Details
-
getInstance
Returns the singleton instance of the PslDataProvider.This method provides access to the single instance of the `PslDataProvider` class. It ensures that the same instance is returned every time it is called, maintaining the Singleton pattern. This method is thread-safe and guarantees that only one instance of the class is created, even in a multithreaded environment.
- Returns:
- the singleton instance
-
loadPslData
Loads PSL data from the provided reader.This method loads the Public Suffix List (PSL) data from the provided `Reader` object. It uses the `PslDataParser` to parse the data and initialize the `pslData` field. This method allows for flexibility in loading PSL data from various sources, such as files, network streams, or other input sources.
- Parameters:
reader
- the reader to load PSL data from
-
loadDefaultData
public void loadDefaultData()Loads the default PSL data from the resource file. If PSL data is already loaded, this method does nothing.This method loads the default Public Suffix List (PSL) data from a resource file included in the application's classpath. If the PSL data is already loaded, the method does nothing to avoid reloading the data. If the resource file cannot be found or an error occurs during loading, an `IllegalStateException` is thrown.
- Throws:
IllegalStateException
- if the default PSL data cannot be loaded
-
resetPslData
void resetPslData()Resets the PSL data, clearing any loaded data.This method clears the currently loaded Public Suffix List (PSL) data by setting the `pslData` field to `null`. This can be useful in scenarios where the PSL data needs to be reloaded or refreshed. After calling this method, the `PslDataProvider` will need to load the PSL data again before it can be used.
-