hefeixia
2021-02-18 5b8c95c760840f09910730943b21391e47187315
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package frame.variant;
 
public class NameValuePair {
 
    private String name;
    private String value;
    
    
    public NameValuePair(String content) throws Exception {
        parse(content);
    }
    
    private void parse(String content) throws Exception {
        if (content == null) {
            throw new Exception("NameValuePair error : empty content");
        }
        
        int pos = content.indexOf("=");
        
        if (pos <= 0) {
            throw new Exception("NameValuePair error , wrong format : " + content);
        }
        
        name = content.substring(0, pos);
        value = content.substring(pos + 1);        
    }
 
    public String getName() {
        return name;
    }
 
 
    public String getValue() {
        return value;
    }
}