2 * Copyright 2005 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.wamblee.crawler.impl;
19 import java.util.regex.Pattern;
22 * Configuration item for obtaining an object in case a pattern matches.
24 * @author Erik Brakkee
26 class ConfigItem<ValueType> {
28 private Pattern _pattern;
30 private ValueType _value;
33 * Constructs the item.
34 * @param aPattern Pattern.
35 * @param aValue Value.
37 protected ConfigItem(String aPattern, ValueType aValue) {
38 _pattern = Pattern.compile(aPattern);
43 * Returns the object in case the value matches.
44 * @param aValue Value to match.
45 * @return Object in case there is a match, null otherwise.
47 protected ValueType match(String aValue) {
48 if (!_pattern.matcher(aValue).matches()) {