Class 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 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.
      • 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 use
        crawlConditionChecker - 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:
        increaseElementsCounter in interface ExtractorManager
        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:
        isChecked in interface ExtractorManager
        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:
        markChecked in interface ExtractorManager
        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:
        numberOfExaminedElements in interface ExtractorManager
        Returns:
        the number of ExaminedElements
      • checkCrawlCondition

        public boolean checkCrawlCondition​(EmbeddedBrowser browser)
        Check if one or more CrawlConditions matches the current state in the browser.
        Specified by:
        checkCrawlCondition in interface ExtractorManager
        Parameters:
        browser - the browser to execute in the CrawlConditions.
        Returns:
        true if one or more CrawlConditions stratifies or non is specified.