ObjectExamplePair.java

00001 /* 
00002 ** Author(s): Miguel Calejo
00003 ** Contact:   interprolog@declarativa.com, http://www.declarativa.com
00004 ** Copyright (C) Declarativa, Portugal, 2000-2002
00005 ** Use and distribution, without any warranties, under the terms of the 
00006 ** GNU Library General Public License, readable in http://www.fsf.org/copyleft/lgpl.html
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 

Generated on Wed Jul 26 13:30:44 2006 for XSB by  doxygen 1.4.5