d6c73859469a8d86fc235005a460557eb9007e62
[utils] / crawler / basic / src / org / wamblee / crawler / impl / ConfigItem.java
1 /*
2  * Copyright 2005 the original author or authors.
3  * 
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
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
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.
15  */
16
17 package org.wamblee.crawler.impl;
18
19 import java.util.regex.Pattern;
20
21 /**
22  * 
23  */
24 class ConfigItem<ValueType> {
25
26     private Pattern _pattern;
27
28     private ValueType _value;
29
30     protected ConfigItem(String aPattern, ValueType aValue) {
31         _pattern = Pattern.compile(aPattern);
32         _value = aValue;
33     }
34
35     protected ValueType match(String aValue) {
36         if (!_pattern.matcher(aValue).matches()) {
37             return null;
38         }
39         return _value;
40     }
41
42 }