BasicTypeWrapper.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 
00009 package com.declarativa.interprolog.util;
00010 import java.io.*;
00014 public class BasicTypeWrapper implements Serializable{
00015         public Object wrapper; // a (serializable...) basic type wrapper
00016         public Class basicTypeClass(){
00017                 if (wrapper instanceof Boolean) return Boolean.TYPE;
00018                 if (wrapper instanceof Character) return Character.TYPE;
00019                 if (wrapper instanceof Byte) return Byte.TYPE;
00020                 if (wrapper instanceof Double) return Double.TYPE;
00021                 if (wrapper instanceof Float) return Float.TYPE;
00022                 if (wrapper instanceof Integer) return Integer.TYPE;
00023                 if (wrapper instanceof Long) return Long.TYPE;
00024                 if (wrapper instanceof Short) return Short.TYPE;
00025                 throw new RuntimeException("Bad BasicTypeWrapper:"+wrapper);
00026         }
00027         public BasicTypeWrapper(Object w){
00028                 wrapper=w;
00029         }
00030         public String toString(){return "BasicTypeWrapper:"+wrapper.toString();}
00031         
00032         public static boolean instanceOfWrapper(Object x){
00033                 if (x instanceof Boolean) return true;
00034                 else if (x instanceof Character) return true;
00035                 else if (x instanceof Byte) return true;
00036                 else if (x instanceof Double) return true;
00037                 else if (x instanceof Float) return true;
00038                 else if (x instanceof Integer) return true;
00039                 else if (x instanceof Long) return true;
00040                 else if (x instanceof Short) return true;
00041                 else return false;
00042         }
00043 }

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