1 19 20 package com.sslexplorer.boot; 21 22 import java.io.Serializable ; 23 import java.util.Properties ; 24 25 26 31 public class NameValuePair implements Serializable { 32 33 35 private String name = null; 36 private String value = null; 37 38 42 public NameValuePair() { 43 this (null, null); 44 } 45 46 51 public NameValuePair(String name, String value) { 52 this.name = name; 53 this.value = value; 54 } 55 56 63 public NameValuePair(String nameValuePair) { 64 int idx = nameValuePair.indexOf('='); 65 if(idx == -1) { 66 name = nameValuePair; 67 value = ""; 68 } 69 else { 70 name = nameValuePair.substring(0, idx); 71 value = nameValuePair.substring(idx + 1); 72 } 73 } 74 75 81 public void setName(String name) { 82 this.name = name; 83 } 84 85 91 public String getName() { 92 return name; 93 } 94 95 100 public void setValue(String value) { 101 this.value = value; 102 } 103 104 105 110 public String getValue() { 111 return value; 112 } 113 114 116 120 public String toString() { 121 return ("name=" + name + ", " + "value=" + value); 122 } 123 124 132 public boolean equals(Object object) { 133 if (object == null) return false; 134 if (this == object) return true; 135 if (!(object instanceof NameValuePair)) return false; 136 137 NameValuePair pair = (NameValuePair) object; 138 return ((null == name ? null == pair.name : name.equals(pair.name)) 139 && (null == value ? null == pair.value : value.equals(pair.value))); 140 } 141 142 147 public int hashCode() { 148 return (this.getClass().hashCode() 149 ^ (null == name ? 0 : name.hashCode()) 150 ^ (null == value ? 0 : value.hashCode())); 151 } 152 153 158 public void add(Properties p) { 159 p.setProperty(name, value); 160 } 161 } 162 | Popular Tags |