00001
00002
00003
00004
00005
00006
00007
00008 package com.declarativa.interprolog;
00009 import java.io.Serializable;
00010 import com.declarativa.interprolog.util.*;
00015 public class ObjectExamplePair implements Serializable{
00016 String name;
00017 Object A,B;
00018 public ObjectExamplePair(Object A){this(null,A,A);}
00019 public ObjectExamplePair(String n,Object A){this(n,A,A);}
00020 public ObjectExamplePair(Object A,Object B){this(null,A,B);}
00028 public ObjectExamplePair(String n,Object A,Object B){
00029 if (A==null | B==null)
00030 throw new Error("Bad ObjectExamplePair, at least first object must be non-null");
00031 if (n==null)
00032 name=A.getClass().getName();
00033 else
00034 name=n;
00035 if (A.getClass()!=B.getClass())
00036 throw new IPException("Bad ObjectExamplePair, objects must belong to same class");
00037 if (!(A instanceof Serializable)|| !(B instanceof Serializable))
00038 throw new IPException("Bad ObjectExamplePair, objects must be Serializable");
00039 this.A=A; this.B=B;
00040 }
00041
00042 public String toString(){
00043 return "ObjectExamplePair for class named "+name+". A:"+A+" B:"+B;
00044 }
00045 }
00046