Package com.crawljax.core
Class CandidateElementManager
- java.lang.Object
-
- com.crawljax.core.CandidateElementManager
-
- All Implemented Interfaces:
ExtractorManager
public class CandidateElementManager extends Object implements ExtractorManager
The class is a ExtractorManager for the CandidateElements. It basically implements the ExtractorManager.
-
-
Field Summary
Fields Modifier and Type Field Description private AtomicIntegercounterUse the AtomicInteger to prevent Problems when increasing.private ConditionTypeChecker<CrawlCondition>crawlConditionCheckerThe CrawlConditionChecker to use in thecheckCrawlCondition(EmbeddedBrowser)operation.private Collection<String>elementsUse the ConcurrentLinkedQueue to prevent Thread problems when checking and storing checkedElements.private ObjectelementsLockUsed to lock the elements when adding multiple elements.private EventableConditionCheckereventableConditionCheckerThe eventableConditionChecker where to load the EventableConditions from into the new Candidates.
-
Constructor Summary
Constructors Constructor Description CandidateElementManager(EventableConditionChecker eventableConditionChecker, ConditionTypeChecker<CrawlCondition> crawlConditionChecker)Create a new CandidateElementManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckCrawlCondition(EmbeddedBrowser browser)Check if one or more CrawlConditions matches the current state in the browser.EventableConditionCheckergetEventableConditionChecker()Retrieve the eventable condition checker.voidincreaseElementsCounter()increase the number of checked elements, as a statistics measure to know how many elements were actually examined.booleanisChecked(String element)Check if a given element is already checked, preventing duplicate work.booleanmarkChecked(CandidateElement element)Mark a given element as checked to prevent duplicate work.intnumberOfExaminedElements()Return internal counter for the examined elements.
-
-
-
Field Detail
-
counter
private final AtomicInteger counter
Use the AtomicInteger to prevent Problems when increasing.
-
elements
private final Collection<String> elements
Use the ConcurrentLinkedQueue to prevent Thread problems when checking and storing checkedElements.
-
eventableConditionChecker
private final EventableConditionChecker eventableConditionChecker
The eventableConditionChecker where to load the EventableConditions from into the new Candidates.
-
crawlConditionChecker
private final ConditionTypeChecker<CrawlCondition> crawlConditionChecker
The CrawlConditionChecker to use in thecheckCrawlCondition(EmbeddedBrowser)operation.
-
elementsLock
private final Object elementsLock
Used to lock the elements when adding multiple elements.
-
-
Constructor Detail
-
CandidateElementManager
@Inject public CandidateElementManager(EventableConditionChecker eventableConditionChecker, ConditionTypeChecker<CrawlCondition> crawlConditionChecker)
Create a new CandidateElementManager.- Parameters:
eventableConditionChecker- the EventableConditionChecker to usecrawlConditionChecker- the CrawlConditionChecker to use
-
-
Method Detail
-
increaseElementsCounter
public void increaseElementsCounter()
increase the number of checked elements, as a statistics measure to know how many elements were actually examined. Its thread safe by using the AtomicInteger- Specified by:
increaseElementsCounterin interfaceExtractorManager- See Also:
AtomicInteger
-
isChecked
public boolean isChecked(String element)
Check if a given element is already checked, preventing duplicate work. This is implemented in a ConcurrentLinkedQueue to support thread-safety- Specified by:
isCheckedin interfaceExtractorManager- Parameters:
element- the to search for if its already checked- Returns:
- true if the element is already checked
-
markChecked
public boolean markChecked(CandidateElement element)
Mark a given element as checked to prevent duplicate work. A elements is only added when it is not already in the set of checked elements.- Specified by:
markCheckedin interfaceExtractorManager- Parameters:
element- the element that is checked- Returns:
- true if !contains(element.uniqueString)
-
numberOfExaminedElements
public int numberOfExaminedElements()
Return internal counter for the examined elements.- Specified by:
numberOfExaminedElementsin interfaceExtractorManager- Returns:
- the number of ExaminedElements
-
getEventableConditionChecker
public EventableConditionChecker getEventableConditionChecker()
Description copied from interface:ExtractorManagerRetrieve the eventable condition checker.- Specified by:
getEventableConditionCheckerin interfaceExtractorManager- Returns:
- the eventableConditionChecker
-
checkCrawlCondition
public boolean checkCrawlCondition(EmbeddedBrowser browser)
Check if one or more CrawlConditions matches the current state in the browser.- Specified by:
checkCrawlConditionin interfaceExtractorManager- Parameters:
browser- the browser to execute in the CrawlConditions.- Returns:
- true if one or more CrawlConditions stratifies or non is specified.
-
-