Class CrawlerAttributes
java.lang.Object
com.norconex.crawler.core.session.CrawlerAttributes
Wrapper around an existing cluster string cache, offering generic attribute
setters and getters for convenience. Whether and how the attributes are
persisted is dependent on the underlying cache implementation.
-
Constructor Summary
ConstructorsConstructorDescriptionCrawlerAttributes(CacheMap<String> cache) Creates a newCrawlerAttributesinstance. -
Method Summary
Modifier and TypeMethodDescriptionbooleangetBoolean(String key) Gets an attribute as a boolean.getCache()The underlying cache.intgetInteger(String key) Gets an attribute as an integer.Gets an attribute as a string.voidsetBoolean(String key, boolean value) Sets an attribute as a boolean.booleansetBooleanIfAbsent(String key, boolean value) Atomically sets an attribute as a boolean if it is not already set.voidsetInteger(String key, int value) Sets an attribute as an integer.booleansetIntegerIfAbsent(String key, int value) Atomically sets an attribute as an integer if it is not already set.voidSets an attribute as a string.booleansetStringIfAbsent(String key, String value) Atomically sets an attribute as a string if it is not already set.
-
Constructor Details
-
CrawlerAttributes
Creates a newCrawlerAttributesinstance.- Parameters:
cache- The underlying cache.
-
-
Method Details
-
setString
Sets an attribute as a string.- Parameters:
key- attribute keyvalue- attribute value
-
setStringIfAbsent
Atomically sets an attribute as a string if it is not already set. This is a cluster-safe operation that prevents race conditions in distributed environments.- Parameters:
key- attribute keyvalue- attribute value to set if key is absent- Returns:
- true if the value was set (key was absent), false if the key already existed
-
getString
Gets an attribute as a string.- Parameters:
key- attribute key- Returns:
- value attribute value
-
setBoolean
Sets an attribute as a boolean.- Parameters:
key- attribute keyvalue- attribute value
-
setBooleanIfAbsent
Atomically sets an attribute as a boolean if it is not already set. This is a cluster-safe operation that prevents race conditions in distributed environments.- Parameters:
key- attribute keyvalue- attribute value to set if key is absent- Returns:
- true if the value was set (key was absent), false if the key already existed
-
getBoolean
Gets an attribute as a boolean.- Parameters:
key- attribute key- Returns:
- value attribute value
-
setInteger
Sets an attribute as an integer.- Parameters:
key- attribute keyvalue- attribute value
-
setIntegerIfAbsent
Atomically sets an attribute as an integer if it is not already set. This is a cluster-safe operation that prevents race conditions in distributed environments.- Parameters:
key- attribute keyvalue- attribute value to set if key is absent- Returns:
- true if the value was set (key was absent), false if the key already existed
-
getInteger
Gets an attribute as an integer. If no value is set, zero is returned.- Parameters:
key- attribute key- Returns:
- value attribute value, or zero
-
getCache
The underlying cache.
-