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 class ConfigItem<ValueType> {
26 private Pattern _pattern;
28 private ValueType _value;
31 * Constructs the item.
32 * @param aPattern Pattern.
33 * @param aValue Value.
35 protected ConfigItem(String aPattern, ValueType aValue) {
36 _pattern = Pattern.compile(aPattern);
41 * Returns the object in case the value matches.
42 * @param aValue Value to match.
43 * @return Object in case there is a match, null otherwise.
45 protected ValueType match(String aValue) {
46 if (!_pattern.matcher(aValue).matches()) {