package com.jscape.inet.http.protocol.messages;

import static com.jscape.util.Parameters.assertNotNull;

/**
 * @author Alex Usun
 */
public class Header {

    public final String name;
    public final String value;

    public Header(String name, String value) {
        assertNotNull(name);
        this.name = name;

        assertNotNull(value);
        this.value = value;
    }
    
    public Integer intValue(int radix) {
        try {
            return Integer.valueOf(this.value, radix);
        } catch (Exception e) {
            return null;
        }
    }
    
    public Long longValue(int radix) {
        try {
            return Long.valueOf(this.value, radix);
        } catch (Exception e) {
            return null;
        }
    }

    @Override
    public String toString() {
        return "Header {"
               + "name='" + this.name + '\''
               + ", value='" + this.value + '\''
               + '}';
    }
}
