1 package jp.sourceforge.stigmata.birthmarks.cvfv;
7 import java.io.IOException;
8 import java.io.ObjectInputStream;
9 import java.io.Serializable;
11 import jp.sourceforge.stigmata.BirthmarkElement;
15 * @author Haruaki TAMADA
18 public class TypeAndValueBirthmarkElement extends BirthmarkElement implements Serializable{
19 private static final long serialVersionUID = 237098465735321L;
21 private String signature;
22 private Serializable serialValue;
23 private transient Object value;
28 public TypeAndValueBirthmarkElement(String signature, Object value){
29 super(signature + "=" + value);
30 this.signature = signature;
34 public String getSignature(){
38 public void setValue(Object value){
40 if(signature.length() == 1 && value == null){
41 switch(signature.charAt(0)){
42 case 'Z': value = Boolean.FALSE; break;
43 case 'D': value = new Double(0d); break;
44 case 'F': value = new Float(0f); break;
49 default: value = new Integer(0); break;
53 if(value != null && value instanceof Serializable){
54 serialValue = (Serializable)value;
59 public Object getValue(){
64 public String toString(){
65 return signature + "=" + value;
69 public int hashCode(){
70 return signature.hashCode() + value.hashCode();
74 public boolean equals(Object o){
75 if(o instanceof TypeAndValueBirthmarkElement){
76 TypeAndValueBirthmarkElement tvbe = (TypeAndValueBirthmarkElement)o;
78 if(getSignature().equals(tvbe.getSignature())){
79 if(getValue() == null && tvbe.getValue() == null){
82 else if(getValue() != null && tvbe.getValue() != null){
83 return getValue().equals(tvbe.getValue());
90 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException{
91 in.defaultReadObject();
92 if(serialValue != null){