Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

TInteger.java

00001 /*
00002 *  Name:      TInteger.java
00003 *  Author:    Rafael Jesus Alcantara Perez
00004 *  Summary:   SQL type integer.
00005 *  Date:      $Date: 2003/07/10 00:42:28 $
00006 *  Revision:  $Revision: 1.4 $
00007 *
00008 *  Copyright (C) 2002-2003  Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00009 *
00010 *  This program is free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  This program is distributed in the hope that it will be useful,
00016 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 *  GNU General Public License for more details.
00019 *
00020 *  You should have received a copy of the GNU General Public License
00021 *  along with this program; if not, write to the Free Software
00022 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023 *  MA 02111-1307, USA.
00024 */
00025 
00027 package org.uesqlc;
00028 
00029 
00031 public class TInteger implements IType
00032 {
00033 
00035   private Long   tValue = null;
00036 
00037 
00038   //
00039   //  C O N S T R U C T O R S
00040   //
00041 
00046   public TInteger() {}
00047 
00053   public TInteger (final boolean kgVALUE)
00054   {
00055     tValue = new Long (( kgVALUE ) ? 1 : 0);
00056   }
00057 
00063   public TInteger (final long kiVALUE)
00064   {
00065     tValue = new Long (kiVALUE);
00066   }
00067 
00073   public TInteger (final Integer ktVALUE)
00074   {
00075     if ( ktVALUE != null )
00076     {
00077       tValue = new Long (ktVALUE.longValue());
00078     }
00079   }
00080 
00086   public TInteger (final Short ktVALUE)
00087   {
00088     if ( ktVALUE != null )
00089     {
00090       tValue = new Long (ktVALUE.longValue());
00091     }
00092   }
00093 
00099   public TInteger (final String kyINTEGER)
00100   {
00101     if ( kyINTEGER != null )
00102     {
00103       tValue = new Long (kyINTEGER);
00104     }
00105   }
00106 
00107   public IType set (final Object ktVALUE)
00108   {
00109 
00110     if ( ktVALUE == null )
00111     {
00112       tValue = null;
00113     }
00114     else if ( ktVALUE instanceof Integer )
00115     {
00116       tValue = new Long (((Integer) ktVALUE).longValue());
00117     }
00118     else if ( ktVALUE instanceof Long )
00119     {
00120       tValue = new Long (((Long) ktVALUE).longValue());
00121     }
00122     else if ( ktVALUE instanceof Short )
00123     {
00124       tValue = new Long (((Short) ktVALUE).longValue());
00125     }
00126     else if ( ktVALUE instanceof String )
00127     {
00128       tValue = new Long ((String) ktVALUE);
00129     }
00130     else
00131     {
00132       throw new IllegalArgumentException ("invalid instance of " + ktVALUE.getClass());
00133     }
00134     return this;
00135 
00136   }  // set()
00137 
00138 
00139   //
00140   //  S E L E C T O R S
00141   //
00142 
00148   public static TInteger _valueOf (final int kiSOURCE)
00149   {
00150     return new TInteger (kiSOURCE);
00151   }
00152 
00159   public static TInteger _valueOf (final boolean kgSOURCE)
00160   {
00161     return new TInteger (kgSOURCE);
00162   }
00163 
00169   public static TInteger _valueOf (final Integer ktSOURCE)
00170   {
00171     return new TInteger (ktSOURCE);
00172   }
00173 
00179   public static TInteger _valueOf (final Short ktSOURCE)
00180   {
00181     return new TInteger (ktSOURCE);
00182   }
00183 
00184   public String get()
00185   {
00186 
00187     String   yResult = "";
00188 
00189     if ( isNull() )
00190     {
00191       yResult = "null";
00192     }
00193     else
00194     {
00195       yResult = tValue.toString();
00196     }
00197     return yResult;
00198 
00199   }  // get()
00200 
00205   public boolean booleanValue()
00206   {
00207     return ( tValue.intValue() != 0 );
00208   }
00209 
00210   public int intValue()
00211   {
00212     return tValue.intValue();
00213   }
00214 
00215   public boolean isNull()
00216   {
00217     return ( tValue == null );
00218   }
00219 
00220   public long longValue()
00221   {
00222     return tValue.longValue();
00223   }
00224 
00225   public Integer toInteger()
00226   {
00227     return ( tValue == null ) ? null : new Integer (tValue.intValue());
00228   }
00229 
00230   public String toString()
00231   {
00232     return ( tValue == null ) ? null : tValue.toString();
00233   }
00234 
00235 }  // class TInteger

Generated on Mon Oct 13 02:40:10 2003 for UESQLC by doxygen1.2.18