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
17 public class TypeAndValueBirthmarkElement extends BirthmarkElement implements Serializable{
18 private static final long serialVersionUID = 237098465735321L;
20 private String signature;
21 private Serializable serialValue;
22 private transient Object value;
27 public TypeAndValueBirthmarkElement(String signature, Object value){
28 super(signature + "=" + value);
29 this.signature = signature;
33 public String getSignature(){
37 public void setValue(Object value){
39 if(signature.length() == 1 && value == null){
40 switch(signature.charAt(0)){
41 case 'Z': value = Boolean.FALSE; break;
42 case 'D': value = new Double(0d); break;
43 case 'F': value = new Float(0f); break;
48 default: value = new Integer(0); break;
52 if(value != null && value instanceof Serializable){
53 serialValue = (Serializable)value;
58 public Object getValue(){
63 public String toString(){
64 return signature + "=" + value;
68 public int hashCode(){
69 return signature.hashCode() + value.hashCode();
73 public boolean equals(Object o){
74 if(o instanceof TypeAndValueBirthmarkElement){
75 TypeAndValueBirthmarkElement tvbe = (TypeAndValueBirthmarkElement)o;
77 if(getSignature().equals(tvbe.getSignature())){
78 if(getValue() == null && tvbe.getValue() == null){
81 else if(getValue() != null && tvbe.getValue() != null){
82 return getValue().equals(tvbe.getValue());
89 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException{
90 in.defaultReadObject();
91 if(serialValue != null){