/* * WPCleaner: A tool to help on Wikipedia maintenance tasks. * Copyright (C) 2013 Nicolas Vervelle * * See README.txt file for licensing information. */ package org.wikipediacleaner.api.check.algorithm; import java.util.Collection; import java.util.List; import org.wikipediacleaner.api.check.CheckErrorResult; import org.wikipediacleaner.api.data.Namespace; import org.wikipediacleaner.api.data.PageAnalysis; import org.wikipediacleaner.api.data.PageElementTag; /** * Algorithm for analyzing error 516 of check wikipedia project. * Error 516: <br /> tags in main namespace */ public class CheckErrorAlgorithm516 extends CheckErrorAlgorithmBase { public CheckErrorAlgorithm516() { super("<br /> tags in main namespace"); } /** * Analyze a page to check if errors are present. * * @param analysis Page analysis. * @param errors Errors found in the page. * @param onlyAutomatic True if analysis could be restricted to errors automatically fixed. * @return Flag indicating if the error was found. */ @Override public boolean analyze( PageAnalysis analysis, Collection<CheckErrorResult> errors, boolean onlyAutomatic) { if ((analysis == null) || (analysis.getPage() == null)) { return false; } Integer ns = analysis.getPage().getNamespace(); if ((ns == null) || (ns.intValue() != Namespace.MAIN)) { return false; } // Check each tag List<PageElementTag> brTags = analysis.getTags(PageElementTag.TAG_HTML_BR); if ((brTags == null) || (brTags.isEmpty())) { return false; } if (errors == null) { return true; } for (PageElementTag brTag : brTags) { CheckErrorResult errorResult = createCheckErrorResult( analysis, brTag.getBeginIndex(), brTag.getEndIndex()); errors.add(errorResult); } return true; } }