001: /*
002: * regain - A file search engine providing plenty of formats
003: * Copyright (C) 2004 Til Schneider
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * Contact: Til Schneider, info@murfman.de
020: *
021: * CVS information:
022: * $RCSfile$
023: * $Source$
024: * $Date: 2005-08-13 13:33:30 +0200 (Sa, 13 Aug 2005) $
025: * $Author: til132 $
026: * $Revision: 160 $
027: */
028: package net.sf.regain.crawler.config;
029:
030: import org.apache.regexp.RE;
031:
032: /**
033: * The settings of a preparator
034: *
035: * @see net.sf.regain.crawler.document.Preparator
036: * @author Til Schneider, www.murfman.de
037: */
038: public class PreparatorSettings {
039:
040: /** The default preparator package. */
041: public static final String DEFAULT_PREPARATOR_PACKAGE = "net.sf.regain.crawler.preparator";
042:
043: /** Specifies whether the preparator is enabled. */
044: private boolean mIsEnabled;
045:
046: /**
047: * The class name of the preparator. The class must implement
048: * {@link net.sf.regain.crawler.document.Preparator Preparator}.
049: */
050: private String mPreparatorClassName;
051:
052: /**
053: * The regular expression a URL must match to, to be prepared by this
054: * preparator.
055: */
056: private String mUrlRegex;
057:
058: /**
059: * The configuration of the preparator.
060: */
061: private PreparatorConfig mPreparatorConfig;
062:
063: /**
064: * Creates a new instance of PreparatorSettings.
065: *
066: * @param isEnabled Specifies whether the preparator is enabled.
067: * @param preparatorClassName The class name of the preparator. The class must
068: * implement {@link net.sf.regain.crawler.document.Preparator Preparator}.
069: * @param urlRegex The regular expression a URL must match to, to be prepared
070: * by this preparator. If <code>null</code> the default regex of the
071: * preparator should be used.
072: * @param preparatorConfig The configuration of the preparator.
073: */
074: public PreparatorSettings(boolean isEnabled,
075: String preparatorClassName, String urlRegex,
076: PreparatorConfig preparatorConfig) {
077: mIsEnabled = isEnabled;
078: mUrlRegex = urlRegex;
079: mPreparatorConfig = preparatorConfig;
080:
081: if (preparatorClassName.startsWith(".")) {
082: mPreparatorClassName = DEFAULT_PREPARATOR_PACKAGE
083: + preparatorClassName;
084: } else {
085: mPreparatorClassName = preparatorClassName;
086: }
087: }
088:
089: /**
090: * Gets whether the preparator is enabled.
091: *
092: * @return Whether the preparator is enabled.
093: */
094: public boolean isEnabled() {
095: return mIsEnabled;
096: }
097:
098: /**
099: * Gets the class name of the preparator.
100: *
101: * @return The class name of the preparator.
102: */
103: public String getPreparatorClassName() {
104: return mPreparatorClassName;
105: }
106:
107: /**
108: * Gets the regular expression a URL must match to, to be prepared this
109: * preparator.
110: *
111: * @return The regular expression a URL must match to, to be prepared
112: * by this preparator. If <code>null</code> the default regex of the
113: * preparator should be used.
114: */
115: public String getUrlRegex() {
116: return mUrlRegex;
117: }
118:
119: /**
120: * Gets the configuration of the preparator.
121: *
122: * @return The configuration of the preparator.
123: */
124: public PreparatorConfig getPreparatorConfig() {
125: return mPreparatorConfig;
126: }
127:
128: }
|