View Javadoc

    1   /* RefinedScope
    2   *
    3   * $Id: RefinedScope.java 4651 2006-09-25 18:31:13Z paul_jack $
    4   *
    5   * Created on Jul 16, 2004
    6   *
    7   * Copyright (C) 2004 Internet Archive.
    8   *
    9   * This file is part of the Heritrix web crawler (crawler.archive.org).
    10  *
    11  * Heritrix is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU Lesser Public License as published by
    13  * the Free Software Foundation; either version 2.1 of the License, or
    14  * any later version.
    15  *
    16  * Heritrix is distributed in the hope that it will be useful,
    17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU Lesser Public License for more details.
    20  *
    21  * You should have received a copy of the GNU Lesser Public License
    22  * along with Heritrix; if not, write to the Free Software
    23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    24  */
    25  package org.archive.crawler.scope;
    26
    27
    28  import org.archive.crawler.framework.Filter;
    29
    30  /***
    31   * Superclass for Scopes which make use of "additional focus"
    32   * to add items by pattern, or want to swap in alternative
    33   * transitive filter.
    34   *
    35   * @author gojomo
    36   */
    37  public abstract class RefinedScope extends ClassicScope {
    38      public static final String ATTR_TRANSITIVE_FILTER = "transitiveFilter";
    39      public static final String ATTR_ADDITIONAL_FOCUS_FILTER =
    40          "additionalScopeFocus";
    41
    42      Filter additionalFocusFilter;
    43      Filter transitiveFilter;
    44
    45      @SuppressWarnings("deprecation")
    46      public RefinedScope(String name) {
    47          super(name);
    48
    49          this.additionalFocusFilter = (Filter) addElementToDefinition(
    50                  new org.archive.crawler.filter.FilePatternFilter(
    51                          ATTR_ADDITIONAL_FOCUS_FILTER));
    52          this.transitiveFilter = (Filter) addElementToDefinition(
    53                  new org.archive.crawler.filter.TransclusionFilter(
    54                          ATTR_TRANSITIVE_FILTER));
    55      }
    56
    57      /***
    58       * @param o
    59       * @return True if transitive filter accepts passed object.
    60       */
    61      protected boolean transitiveAccepts(Object o) {
    62          return this.transitiveFilter.accepts(o);
    63      }
    64
    65      protected boolean additionalFocusAccepts(Object o) {
    66          return additionalFocusFilter.accepts(o);
    67      }
    68  }