Subversion Repositories XServices

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
63 brianR 1
/*
2
 *   Copyright 2010 Brian Rosenberger (Brutex Network)
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
package net.brutex.xservices.types;
17
 
18
import java.util.ArrayList;
19
import java.util.List;
20
import java.util.Map;
21
import javax.xml.bind.annotation.XmlElement;
22
import javax.xml.bind.annotation.XmlRootElement;
23
 
24
/**
25
 * Generic key/ value pairs.
26
 *
27
 * @author Brian Rosenberger
28
 */
29
@XmlRootElement
30
public class ReplacePattern {
31
 
32
    /**
33
     * Search string.
34
     */
35
    @XmlElement(required=true)
36
    public String search ="";
37
 
38
    /**
39
     * Replace string.
40
     */
41
    @XmlElement(required=true)
42
    public String replace="";
43
 
44
    /**
45
     * Converts a Map<String, String> into a list of
46
     * ReplacePattern.
47
     * @param map   The map to convert
48
     * @return      A list of key/value pairs
49
     */
50
    public static List<ReplacePattern> createAntPropertyList(Map<String, String> map) {
51
        List<ReplacePattern> list = new ArrayList<ReplacePattern>();
52
        for(Map.Entry<String, String> e : map.entrySet()) {
53
            list.add(new ReplacePattern(e.getKey(), e.getValue()));
54
        }
55
        return list;
56
    }
57
 
58
    /**
59
     * Creates a new ReplacePattern.
60
     * @param name
61
     * @param value
62
     */
63
    public ReplacePattern(String search, String replace) {
64
        this.search = search;
65
        this.replace = replace;
66
    }
67
 
68
    /**
69
     * Creates a new ReplacePattern.
70
     */
71
    public ReplacePattern() {
72
    }
73
 
74
 
75
}