hsqldb

16:36:27.822 INFO  jd.cli.Main - Decompiling hsqldb.jar
import org.hsqldb.Servlet;

public class hsqlServlet
  extends Servlet
{}

/* Location:
 * Qualified Name:     hsqlServlet
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.hsqldb;

import java.io.IOException;
import org.hsqldb.rowio.RowOutputInterface;

abstract class BaseMemoryNode
  extends Node
{
  protected Node nLeft;
  protected Node nRight;
  protected Node nParent;
  
  void delete()
  {
    iBalance = -2;
    nLeft = (nRight = nParent = null);
  }
  
  Node getLeft()
    throws HsqlException
  {
    return nLeft;
  }
  
  void setLeft(Node paramNode)
    throws HsqlException
  {
    nLeft = paramNode;
  }
  
  boolean isLeft(Node paramNode)
    throws HsqlException
  {
    return nLeft == paramNode;
  }
  
  boolean isRight(Node paramNode)
    throws HsqlException
  {
    return nRight == paramNode;
  }
  
  Node getRight()
    throws HsqlException
  {
    return nRight;
  }
  
  void setRight(Node paramNode)
    throws HsqlException
  {
    nRight = paramNode;
  }
  
  Node getParent()
    throws HsqlException
  {
    return nParent;
  }
  
  boolean isRoot()
  {
    return nParent == null;
  }
  
  void setParent(Node paramNode)
    throws HsqlException
  {
    nParent = paramNode;
  }
  
  void setBalance(int paramInt)
    throws HsqlException
  {
    iBalance = paramInt;
  }
  
  boolean isFromLeft()
    throws HsqlException
  {
    if (isRoot()) {
      return true;
    }
    Node localNode = getParent();
    return equals(localNode.getLeft());
  }
  
  boolean equals(Node paramNode)
  {
    return paramNode == this;
  }
  
  void write(RowOutputInterface paramRowOutputInterface)
    throws IOException
  {}
}

/* Location:
 * Qualified Name:     org.hsqldb.BaseMemoryNode
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.hsqldb;

import org.hsqldb.index.RowIterator;

public abstract class BaseTable
{
  abstract Index getPrimaryIndex();
  
  public RowIterator rowIterator(Session paramSession)
    throws HsqlException
  {
    return getPrimaryIndex().firstRow(paramSession);
  }
}

/* Location:
 * Qualified Name:     org.hsqldb.BaseTable
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.hsqldb;

import java.io.IOException;
import org.hsqldb.rowio.RowInputInterface;
import org.hsqldb.rowio.RowOutputInterface;

class CachedDataRow
  extends CachedRow
{
  CachedDataRow(Table paramTable, Object[] paramArrayOfObject)
    throws HsqlException
  {
    super(paramTable, paramArrayOfObject);
    hasDataChanged = true;
  }
  
  CachedDataRow(Table paramTable, RowInputInterface paramRowInputInterface)
    throws IOException, HsqlException
  {
    tTable = paramTable;
    iPos = paramRowInputInterface.getPos();
    storageSize = paramRowInputInterface.getSize();
    oData = paramRowInputInterface.readData(tTable.getColumnTypes());
    hasDataChanged = false;
  }
  
  Row getUpdatedRow()
    throws HsqlException
  {
    return tTable.getRow(iPos, nPrimaryNode);
  }
  
  void setNewNodes()
  {
    int i = tTable.getIndexCount();
    nPrimaryNode = Node.newNode(this, 0, tTable);
    Node localNode = nPrimaryNode;
    for (int j = 1; j < i; j++)
    {
      nNext = Node.newNode(this, j, tTable);
      localNode = nNext;
    }
  }
  
  void setPrimaryNode(Node paramNode)
  {
    nPrimaryNode = paramNode;
  }
  
  public int getRealSize(RowOutputInterface paramRowOutputInterface)
  {
    return paramRowOutputInterface.getSize(this);
  }
  
  public void write(RowOutputInterface paramRowOutputInterface)
  {
    paramRowOutputInterface.writeSize(storageSize);
    paramRowOutputInterface.writeData(oData, tTable);
    paramRowOutputInterface.writeEnd();
    hasDataChanged = false;
  }
  
  public boolean hasChanged()
  {
    return hasDataChanged;
  }
  
  public void setPos(int paramInt)
  {
    iPos = paramInt;
    for (Node localNode = nPrimaryNode; localNode != null; localNode = nNext) {
      iData = iPos;
    }
  }
  
  public boolean equals(Object paramObject)
  {
    if (paramObject == this) {
      return true;
    }
    if ((paramObject instanceof CachedDataRow)) {
      return (iPos == iPos) && (tTable == tTable);
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.hsqldb.CachedDataRow
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.hsqldb;

import java.io.IOException;
import org.hsqldb.lib.IntLookup;
import org.hsqldb.persist.PersistentStore;
import org.hsqldb.rowio.RowInputInterface;
import org.hsqldb.rowio.RowOutputInterface;

public class CachedRow
  extends Row
{
  static final int NO_POS = -1;
  protected Table tTable;
  int storageSize;
  protected boolean hasDataChanged;
  boolean hasNodesChanged;
  
  CachedRow() {}
  
  public static CachedRow newCachedRow(Table paramTable, Object[] paramArrayOfObject)
    throws HsqlException
  {
    if (isText) {
      return new CachedDataRow(paramTable, paramArrayOfObject);
    }
    return new CachedRow(paramTable, paramArrayOfObject);
  }
  
  CachedRow(Table paramTable, Object[] paramArrayOfObject)
    throws HsqlException
  {
    tTable = paramTable;
    int i = paramTable.getIndexCount();
    nPrimaryNode = Node.newNode(this, 0, paramTable);
    Node localNode = nPrimaryNode;
    for (int j = 1; j < i; j++)
    {
      nNext = Node.newNode(this, j, paramTable);
      localNode = nNext;
    }
    oData = paramArrayOfObject;
    hasDataChanged = (hasNodesChanged = 1);
  }
  
  public CachedRow(Table paramTable, RowInputInterface paramRowInputInterface)
    throws IOException, HsqlException
  {
    tTable = paramTable;
    iPos = paramRowInputInterface.getPos();
    storageSize = paramRowInputInterface.getSize();
    int i = paramTable.getIndexCount();
    nPrimaryNode = Node.newNode(this, paramRowInputInterface, 0, paramTable);
    Node localNode = nPrimaryNode;
    for (int j = 1; j < i; j++)
    {
      nNext = Node.newNode(this, paramRowInputInterface, j, paramTable);
      localNode = nNext;
    }
    oData = paramRowInputInterface.readData(tTable.getColumnTypes());
  }
  
  private void readRowInfo(RowInputInterface paramRowInputInterface)
    throws IOException, HsqlException
  {}
  
  public void delete()
    throws HsqlException
  {
    super.delete();
    hasNodesChanged = (hasDataChanged = 0);
    tTable = null;
  }
  
  public int getStorageSize()
  {
    return storageSize;
  }
  
  public void setPos(int paramInt)
  {
    iPos = paramInt;
  }
  
  void setChanged()
  {
    hasNodesChanged = true;
  }
  
  public boolean hasChanged()
  {
    return hasNodesChanged;
  }
  
  public Table getTable()
  {
    return tTable;
  }
  
  public int getRealSize(RowOutputInterface paramRowOutputInterface)
  {
    return tTable.getIndexCount() * 16 + paramRowOutputInterface.getSize(this);
  }
  
  public void setStorageSize(int paramInt)
  {
    storageSize = paramInt;
  }
  
  public synchronized boolean isKeepInMemory()
  {
    for (Node localNode = nPrimaryNode; localNode != null; localNode = nNext) {
      if (localNode.isRoot()) {
        return true;
      }
    }
    return false;
  }
  
  synchronized Row getUpdatedRow()
    throws HsqlException
  {
    return tTable == null ? null : (CachedRow)tTable.rowStore.get(iPos);
  }
  
  void setNewNodes() {}
  
  public void write(RowOutputInterface paramRowOutputInterface)
  {
    try
    {
      writeNodes(paramRowOutputInterface);
      if (hasDataChanged)
      {
        paramRowOutputInterface.writeData(oData, tTable);
        paramRowOutputInterface.writeEnd();
        hasDataChanged = false;
      }
    }
    catch (IOException localIOException) {}
  }
  
  private void writeRowInfo(RowOutputInterface paramRowOutputInterface) {}
  
  public void write(RowOutputInterface paramRowOutputInterface, IntLookup paramIntLookup)
  {
    paramRowOutputInterface.writeSize(storageSize);
    for (Node localNode = nPrimaryNode; localNode != null; localNode = nNext) {
      ((DiskNode)localNode).writeTranslate(paramRowOutputInterface, paramIntLookup);
    }
    paramRowOutputInterface.writeData(getData(), getTable());
    paramRowOutputInterface.writeEnd();
  }
  
  private void writeNodes(RowOutputInterface paramRowOutputInterface)
    throws IOException
  {
    paramRowOutputInterface.writeSize(storageSize);
    for (Node localNode = nPrimaryNode; localNode != null; localNode = nNext) {
      localNode.write(paramRowOutputInterface);
    }
    hasNodesChanged = false;
  }
  
  public boolean equals(Object paramObject)
  {
    if (paramObject == this) {
      return true;
    }
    if ((paramObject instanceof CachedRow)) {
      return iPos == iPos;
    }
    return false;
  }
  
  public int hashCode()
  {
    return iPos;
  }
}

/* Location:
 * Qualified Name:     org.hsqldb.CachedRow
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.hsqldb;

import java.text.Collator;
import java.util.Locale;
import org.hsqldb.lib.Collection;
import org.hsqldb.lib.HashMap;
import org.hsqldb.lib.Iterator;
import org.hsqldb.lib.Set;
import org.hsqldb.lib.StringUtil;
import org.hsqldb.lib.java.JavaSystem;

public class Collation
{
  static final HashMap nameToJavaName = new HashMap(101);
  String name;
  Collator collator;
  Locale locale = Locale.ENGLISH;
  
  public Iterator getCollationsIterator()
  {
    return nameToJavaName.keySet().iterator();
  }
  
  public Iterator getLocalesIterator()
  {
    return nameToJavaName.values().iterator();
  }
  
  public void setCollationAsLocale()
  {
    Locale localLocale = Locale.getDefault();
    String str = localLocale.getDisplayLanguage(Locale.ENGLISH);
    try
    {
      setCollation(str);
    }
    catch (HsqlException localHsqlException) {}
  }
  
  void setCollation(String paramString)
    throws HsqlException
  {
    String str1 = (String)nameToJavaName.get(paramString);
    if (str1 == null) {
      throw Trace.error(208);
    }
    name = paramString;
    String[] arrayOfString = StringUtil.split(str1, "-");
    String str2 = arrayOfString[0];
    String str3 = arrayOfString.length == 2 ? arrayOfString[1] : "";
    locale = new Locale(str2, str3);
    collator = Collator.getInstance(locale);
  }
  
  int compare(String paramString1, String paramString2)
  {
    int i;
    if (collator == null) {
      i = paramString1.compareTo(paramString2);
    } else {
      i = collator.compare(paramString1, paramString2);
    }
    return i < 0 ? -1 : i == 0 ? 0 : 1;
  }
  
  int compareIgnoreCase(String paramString1, String paramString2)
  {
    int i;
    if (collator == null) {
      i = JavaSystem.CompareIngnoreCase(paramString1, paramString2);
    } else {
      i = collator.compare(toUpperCase(paramString1), toUpperCase(paramString2));
    }
    return i < 0 ? -1 : i == 0 ? 0 : 1;
  }
  
  String toUpperCase(String paramString)
  {
    return paramString.toUpperCase(locale);
  }
  
  static
  {
    nameToJavaName.put("Afrikaans", "af-ZA");
    nameToJavaName.put("Amharic", "am-ET");
    nameToJavaName.put("Arabic", "ar");
    nameToJavaName.put("Assamese", "as-IN");
    nameToJavaName.put("Azerbaijani_Latin", "az-AZ");
    nameToJavaName.put("Azerbaijani_Cyrillic", "az-cyrillic");
    nameToJavaName.put("Belarusian", "be-BY");
    nameToJavaName.put("Bulgarian", "bg-BG");
    nameToJavaName.put("Bengali", "bn-IN");
    nameToJavaName.put("Tibetan", "bo-CN");
    nameToJavaName.put("Bosnian", "bs-BA");
    nameToJavaName.put("Catalan", "ca-ES");
    nameToJavaName.put("Czech", "cs-CZ");
    nameToJavaName.put("Welsh", "cy-GB");
    nameToJavaName.put("Danish", "da-DK");
    nameToJavaName.put("German", "de-DE");
    nameToJavaName.put("Greek", "el-GR");
    nameToJavaName.put("Latin1_General", "en-US");
    nameToJavaName.put("Spanish", "es-ES");
    nameToJavaName.put("Estonian", "et-EE");
    nameToJavaName.put("Basque", "eu");
    nameToJavaName.put("Finnish", "fi-FI");
    nameToJavaName.put("French", "fr-FR");
    nameToJavaName.put("Guarani", "gn-PY");
    nameToJavaName.put("Gujarati", "gu-IN");
    nameToJavaName.put("Hausa", "ha-NG");
    nameToJavaName.put("Hebrew", "he-IL");
    nameToJavaName.put("Hindi", "hi-IN");
    nameToJavaName.put("Croatian", "hr-HR");
    nameToJavaName.put("Hungarian", "hu-HU");
    nameToJavaName.put("Armenian", "hy-AM");
    nameToJavaName.put("Indonesian", "id-ID");
    nameToJavaName.put("Igbo", "ig-NG");
    nameToJavaName.put("Icelandic", "is-IS");
    nameToJavaName.put("Italian", "it-IT");
    nameToJavaName.put("Inuktitut", "iu-CA");
    nameToJavaName.put("Japanese", "ja-JP");
    nameToJavaName.put("Georgian", "ka-GE");
    nameToJavaName.put("Kazakh", "kk-KZ");
    nameToJavaName.put("Khmer", "km-KH");
    nameToJavaName.put("Kannada", "kn-IN");
    nameToJavaName.put("Korean", "ko-KR");
    nameToJavaName.put("Konkani", "kok-IN");
    nameToJavaName.put("Kashmiri", "ks");
    nameToJavaName.put("Kirghiz", "ky-KG");
    nameToJavaName.put("Lao", "lo-LA");
    nameToJavaName.put("Lithuanian", "lt-LT");
    nameToJavaName.put("Latvian", "lv-LV");
    nameToJavaName.put("Maori", "mi-NZ");
    nameToJavaName.put("Macedonian", "mk-MK");
    nameToJavaName.put("Malayalam", "ml-IN");
    nameToJavaName.put("Mongolian", "mn-MN");
    nameToJavaName.put("Manipuri", "mni-IN");
    nameToJavaName.put("Marathi", "mr-IN");
    nameToJavaName.put("Malay", "ms-MY");
    nameToJavaName.put("Maltese", "mt-MT");
    nameToJavaName.put("Burmese", "my-MM");
    nameToJavaName.put("Danish_Norwegian", "nb-NO");
    nameToJavaName.put("Nepali", "ne-NP");
    nameToJavaName.put("Dutch", "nl-NL");
    nameToJavaName.put("Norwegian", "nn-NO");
    nameToJavaName.put("Oriya", "or-IN");
    nameToJavaName.put("Punjabi", "pa-IN");
    nameToJavaName.put("Polish", "pl-PL");
    nameToJavaName.put("Pashto", "ps-AF");
    nameToJavaName.put("Portuguese", "pt-PT");
    nameToJavaName.put("Romanian", "ro-RO");
    nameToJavaName.put("Russian", "ru-RU");
    nameToJavaName.put("Sanskrit", "sa-IN");
    nameToJavaName.put("Sindhi", "sd-IN");
    nameToJavaName.put("Slovak", "sk-SK");
    nameToJavaName.put("Slovenian", "sl-SI");
    nameToJavaName.put("Somali", "so-SO");
    nameToJavaName.put("Albanian", "sq-AL");
    nameToJavaName.put("Serbian_Cyrillic", "sr-YU");
    nameToJavaName.put("Serbian_Latin", "sh-BA");
    nameToJavaName.put("Swedish", "sv-SE");
    nameToJavaName.put("Swahili", "sw-KE");
    nameToJavaName.put("Tamil", "ta-IN");
    nameToJavaName.put("Telugu", "te-IN");
    nameToJavaName.put("Tajik", "tg-TJ");
    nameToJavaName.put("Thai", "th-TH");
    nameToJavaName.put("Turkmen", "tk-TM");
    nameToJavaName.put("Tswana", "tn-BW");
    nameToJavaName.put("Turkish", "tr-TR");
    nameToJavaName.put("Tatar", "tt-RU");
    nameToJavaName.put("Ukrainian", "uk-UA");
    nameToJavaName.put("Urdu", "ur-PK");
    nameToJavaName.put("Uzbek_Latin", "uz-UZ");
    nameToJavaName.put("Venda", "ven-ZA");
    nameToJavaName.put("Vietnamese", "vi-VN");
    nameToJavaName.put("Yoruba", "yo-NG");
    nameToJavaName.put("Chinese", "zh-CN");
    nameToJavaName.put("Zulu", "zu-ZA");
  }
}

/* Location:
 * Qualified Name:     org.hsqldb.Collation
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.hsqldb;

import java.io.IOException;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import org.hsqldb.lib.StringConverter;
import org.hsqldb.lib.java.JavaSystem;
import org.hsqldb.store.ValuePool;
import org.hsqldb.types.Binary;
import org.hsqldb.types.JavaObject;

public class Column
{
  public HsqlNameManager.HsqlName columnName;
  private int colType;
  private int colSize;
  private int colScale;
  private boolean isNullable;
  private boolean isIdentity;
  private boolean isPrimaryKey;
  private Expression defaultExpression;
  long identityStart;
  long identityIncrement;
  static final BigInteger MAX_LONG = BigInteger.valueOf(Long.MAX_VALUE);
  static final BigInteger MIN_LONG = BigInteger.valueOf(Long.MIN_VALUE);
  static final BigInteger MAX_INT = BigInteger.valueOf(2147483647L);
  static final BigInteger MIN_INT = BigInteger.valueOf(-2147483648L);
  static final BigDecimal BIG_DECIMAL_0 = new BigDecimal(0.0D);
  static final BigDecimal BIG_DECIMAL_1 = new BigDecimal(1.0D);
  static int[] tenPower = { 1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000 };
  
  Column(HsqlNameManager.HsqlName paramHsqlName, boolean paramBoolean1, int paramInt1, int paramInt2, int paramInt3, boolean paramBoolean2, Expression paramExpression)
    throws HsqlException
  {
    columnName = paramHsqlName;
    isNullable = paramBoolean1;
    colType = paramInt1;
    colSize = paramInt2;
    colScale = paramInt3;
    isPrimaryKey = paramBoolean2;
    defaultExpression = paramExpression;
  }
  
  void setIdentity(boolean paramBoolean, long paramLong1, long paramLong2)
    throws HsqlException
  {
    isIdentity = paramBoolean;
    identityStart = paramLong1;
    identityIncrement = paramLong2;
    if ((isIdentity) && (colType == 4) && ((identityStart > 2147483647L) || (identityIncrement > 2147483647L))) {
      throw Trace.error(65, columnName.statementName);
    }
  }
  
  private Column() {}
  
  Column duplicate(boolean paramBoolean)
    throws HsqlException
  {
    Column localColumn = new Column();
    columnName = columnName;
    isNullable = isNullable;
    colType = colType;
    colSize = colSize;
    colScale = colScale;
    defaultExpression = defaultExpression;
    if (paramBoolean) {
      localColumn.setIdentity(isIdentity, identityStart, identityIncrement);
    }
    return localColumn;
  }
  
  void setType(Column paramColumn)
  {
    isNullable = isNullable;
    colType = colType;
    colSize = colSize;
    colScale = colScale;
  }
  
  boolean isIdentity()
  {
    return isIdentity;
  }
  
  boolean isNullable()
  {
    return isNullable;
  }
  
  void setNullable(boolean paramBoolean)
  {
    isNullable = paramBoolean;
  }
  
  public boolean isPrimaryKey()
  {
    return isPrimaryKey;
  }
  
  void setPrimaryKey(boolean paramBoolean)
  {
    isPrimaryKey = paramBoolean;
  }
  
  Object getDefaultValue(Session paramSession)
    throws HsqlException
  {
    return defaultExpression == null ? null : defaultExpression.getValue(paramSession, colType);
  }
  
  String getDefaultDDL()
  {
    String str = null;
    try
    {
      str = defaultExpression == null ? null : defaultExpression.getDDL();
    }
    catch (HsqlException localHsqlException) {}
    return str;
  }
  
  Expression getDefaultExpression()
  {
    return defaultExpression;
  }
  
  void setDefaultExpression(Expression paramExpression)
  {
    defaultExpression = paramExpression;
  }
  
  int getType()
  {
    return colType;
  }
  
  int getDIType()
  {
    return colType == 100 ? 12 : colType;
  }
  
  int getDITypeSub()
  {
    if (colType == 100) {
      return 4;
    }
    return 1;
  }
  
  int getSize()
  {
    return colSize;
  }
  
  int getScale()
  {
    return colScale;
  }
  
  static Object add(Object paramObject1, Object paramObject2, int paramInt)
    throws HsqlException
  {
    if ((paramObject1 == null) || (paramObject2 == null)) {
      return null;
    }
    switch (paramInt)
    {
    case 0: 
      return null;
    case 6: 
    case 7: 
    case 8: 
      double d1 = ((Number)paramObject1).doubleValue();
      double d2 = ((Number)paramObject2).doubleValue();
      return ValuePool.getDouble(Double.doubleToLongBits(d1 + d2));
    case -1: 
    case 1: 
    case 12: 
    case 100: 
      return (String)paramObject1 + (String)paramObject2;
    case 2: 
    case 3: 
      BigDecimal localBigDecimal1 = (BigDecimal)paramObject1;
      BigDecimal localBigDecimal2 = (BigDecimal)paramObject2;
      return localBigDecimal1.add(localBigDecimal2);
    case -6: 
    case 4: 
    case 5: 
      int i = ((Number)paramObject1).intValue();
      int j = ((Number)paramObject2).intValue();
      return ValuePool.getInt(i + j);
    case -5: 
      long l1 = ((Number)paramObject1).longValue();
      long l2 = ((Number)paramObject2).longValue();
      return ValuePool.getLong(l1 + l2);
    }
    throw Trace.error(20, Types.getTypeString(paramInt));
  }
  
  static Object concat(Object paramObject1, Object paramObject2)
    throws HsqlException
  {
    if ((paramObject1 == null) || (paramObject2 == null)) {
      return null;
    }
    return paramObject1.toString() + paramObject2.toString();
  }
  
  static Object negate(Object paramObject, int paramInt)
    throws HsqlException
  {
    if (paramObject == null) {
      return null;
    }
    switch (paramInt)
    {
    case 0: 
      return null;
    case 6: 
    case 7: 
    case 8: 
      double d = -((Number)paramObject).doubleValue();
      return ValuePool.getDouble(Double.doubleToLongBits(d));
    case 2: 
    case 3: 
      return ((BigDecimal)paramObject).negate();
    case -6: 
    case 4: 
    case 5: 
      return ValuePool.getInt(-((Number)paramObject).intValue());
    case -5: 
      return ValuePool.getLong(-((Number)paramObject).longValue());
    }
    throw Trace.error(20, Types.getTypeString(paramInt));
  }
  
  static Object multiply(Object paramObject1, Object paramObject2, int paramInt)
    throws HsqlException
  {
    if ((paramObject1 == null) || (paramObject2 == null)) {
      return null;
    }
    if ((!(paramObject1 instanceof Number)) || (!(paramObject2 instanceof Number)))
    {
      paramObject1 = convertObject(paramObject1, paramInt);
      paramObject2 = convertObject(paramObject2, paramInt);
    }
    switch (paramInt)
    {
    case 0: 
      return null;
    case 6: 
    case 7: 
    case 8: 
      double d1 = ((Number)paramObject1).doubleValue();
      double d2 = ((Number)paramObject2).doubleValue();
      return ValuePool.getDouble(Double.doubleToLongBits(d1 * d2));
    case 2: 
    case 3: 
      BigDecimal localBigDecimal1 = (BigDecimal)paramObject1;
      BigDecimal localBigDecimal2 = (BigDecimal)paramObject2;
      return localBigDecimal1.multiply(localBigDecimal2);
    case -6: 
    case 4: 
    case 5: 
      int i = ((Number)paramObject1).intValue();
      int j = ((Number)paramObject2).intValue();
      return ValuePool.getInt(i * j);
    case -5: 
      long l1 = ((Number)paramObject1).longValue();
      long l2 = ((Number)paramObject2).longValue();
      return ValuePool.getLong(l1 * l2);
    }
    throw Trace.error(20, Types.getTypeString(paramInt));
  }
  
  static Object divide(Object paramObject1, Object paramObject2, int paramInt)
    throws HsqlException
  {
    if ((paramObject1 == null) || (paramObject2 == null)) {
      return null;
    }
    switch (paramInt)
    {
    case 0: 
      return null;
    case 6: 
    case 7: 
    case 8: 
      double d1 = ((Number)paramObject1).doubleValue();
      double d2 = ((Number)paramObject2).doubleValue();
      return ValuePool.getDouble(Double.doubleToLongBits(d1 / d2));
    case 2: 
    case 3: 
      BigDecimal localBigDecimal1 = (BigDecimal)paramObject1;
      BigDecimal localBigDecimal2 = (BigDecimal)paramObject2;
      int k = localBigDecimal1.scale() > localBigDecimal2.scale() ? localBigDecimal1.scale() : localBigDecimal2.scale();
      return localBigDecimal2.signum() == 0 ? null : localBigDecimal1.divide(localBigDecimal2, k, 5);
    case -6: 
    case 4: 
    case 5: 
      int i = ((Number)paramObject1).intValue();
      int j = ((Number)paramObject2).intValue();
      if (j == 0) {
        throw Trace.error(6);
      }
      return ValuePool.getInt(i / j);
    case -5: 
      long l1 = ((Number)paramObject1).longValue();
      long l2 = ((Number)paramObject2).longValue();
      return l2 == 0L ? null : ValuePool.getLong(l1 / l2);
    }
    throw Trace.error(20, Types.getTypeString(paramInt));
  }
  
  static Object subtract(Object paramObject1, Object paramObject2, int paramInt)
    throws HsqlException
  {
    if ((paramObject1 == null) || (paramObject2 == null)) {
      return null;
    }
    switch (paramInt)
    {
    case 0: 
      return null;
    case 6: 
    case 7: 
    case 8: 
      double d1 = ((Number)paramObject1).doubleValue();
      double d2 = ((Number)paramObject2).doubleValue();
      return ValuePool.getDouble(Double.doubleToLongBits(d1 - d2));
    case 2: 
    case 3: 
      BigDecimal localBigDecimal1 = (BigDecimal)paramObject1;
      BigDecimal localBigDecimal2 = (BigDecimal)paramObject2;
      return localBigDecimal1.subtract(localBigDecimal2);
    case -6: 
    case 4: 
    case 5: 
      int i = ((Number)paramObject1).intValue();
      int j = ((Number)paramObject2).intValue();
      return ValuePool.getInt(i - j);
    case -5: 
      long l1 = ((Number)paramObject1).longValue();
      long l2 = ((Number)paramObject2).longValue();
      return ValuePool.getLong(l1 - l2);
    }
    throw Trace.error(20, Types.getTypeString(paramInt));
  }
  
  static int compare(Collation paramCollation, Object paramObject1, Object paramObject2, int paramInt)
  {
    int i = 0;
    if (paramObject1 == paramObject2) {
      return 0;
    }
    if (paramObject1 == null) {
      return -1;
    }
    if (paramObject2 == null) {
      return 1;
    }
    switch (paramInt)
    {
    case 0: 
      return 0;
    case -1: 
    case 12: 
      return paramCollation.compare((String)paramObject1, (String)paramObject2);
    case 1: 
      return paramCollation.compare(Library.rtrim((String)paramObject1), Library.rtrim((String)paramObject2));
    case 100: 
      return paramCollation.compareIgnoreCase((String)paramObject1, (String)paramObject2);
    case -6: 
    case 4: 
    case 5: 
      int j = ((Number)paramObject1).intValue();
      int k = ((Number)paramObject2).intValue();
      return k > j ? -1 : j > k ? 1 : 0;
    case -5: 
      long l1 = ((Number)paramObject1).longValue();
      long l2 = ((Number)paramObject2).longValue();
      return l2 > l1 ? -1 : l1 > l2 ? 1 : 0;
    case 6: 
    case 7: 
    case 8: 
      double d1 = ((Number)paramObject1).doubleValue();
      double d2 = ((Number)paramObject2).doubleValue();
      return d2 > d1 ? -1 : d1 > d2 ? 1 : 0;
    case 2: 
    case 3: 
      i = ((BigDecimal)paramObject1).compareTo((BigDecimal)paramObject2);
      break;
    case 91: 
      return HsqlDateTime.compare((Date)paramObject1, (Date)paramObject2);
    case 92: 
      return HsqlDateTime.compare((Time)paramObject1, (Time)paramObject2);
    case 93: 
      return HsqlDateTime.compare((Timestamp)paramObject1, (Timestamp)paramObject2);
    case 16: 
      boolean bool1 = ((Boolean)paramObject1).booleanValue();
      boolean bool2 = ((Boolean)paramObject2).booleanValue();
      return bool2 ? -1 : bool1 == bool2 ? 0 : 1;
    case -4: 
    case -3: 
    case -2: 
      if (((paramObject1 instanceof Binary)) && ((paramObject2 instanceof Binary))) {
        i = compareTo(((Binary)paramObject1).getBytes(), ((Binary)paramObject2).getBytes());
      }
      break;
    case 1111: 
      return 0;
    }
    return i < 0 ? -1 : i == 0 ? 0 : 1;
  }
  
  public static Object convertObject(Object paramObject, int paramInt)
    throws HsqlException
  {
    try
    {
      if (paramObject == null) {
        return null;
      }
      long l3;
      switch (paramInt)
      {
      case 0: 
        return null;
      case -6: 
        int i;
        if ((paramObject instanceof String))
        {
          paramObject = Library.trim((String)paramObject, " ", true, true);
          i = Integer.parseInt((String)paramObject);
          paramObject = ValuePool.getInt(i);
        }
        if ((paramObject instanceof Integer))
        {
          i = ((Number)paramObject).intValue();
          if ((127 < i) || (i < -128)) {
            throw Trace.error(65);
          }
          return paramObject;
        }
        if ((paramObject instanceof Long))
        {
          long l1 = ((Number)paramObject).longValue();
          if ((127L < l1) || (l1 < -128L)) {
            throw Trace.error(65);
          }
          return ValuePool.getInt(((Number)paramObject).intValue());
        }
        if ((paramObject instanceof Byte)) {
          return ValuePool.getInt(((Number)paramObject).intValue());
        }
        if ((paramObject instanceof Number)) {
          return convertObject(convertToInt(paramObject), paramInt);
        }
        if ((paramObject instanceof Boolean)) {
          return ((Boolean)paramObject).booleanValue() ? ValuePool.getInt(1) : ValuePool.getInt(0);
        }
        break;
      case 5: 
        int j;
        if ((paramObject instanceof String))
        {
          paramObject = Library.trim((String)paramObject, " ", true, true);
          j = Integer.parseInt((String)paramObject);
          paramObject = ValuePool.getInt(j);
        }
        if ((paramObject instanceof Integer))
        {
          j = ((Number)paramObject).intValue();
          if ((32767 < j) || (j < 32768)) {
            throw Trace.error(65);
          }
          return paramObject;
        }
        if ((paramObject instanceof Long))
        {
          long l2 = ((Number)paramObject).longValue();
          if ((32767L < l2) || (l2 < -32768L)) {
            throw Trace.error(65);
          }
          return ValuePool.getInt(((Number)paramObject).intValue());
        }
        if (((paramObject instanceof Byte)) || ((paramObject instanceof Short))) {
          return ValuePool.getInt(((Number)paramObject).intValue());
        }
        if ((paramObject instanceof Number)) {
          return convertObject(convertToInt(paramObject), paramInt);
        }
        if ((paramObject instanceof Boolean)) {
          return ((Boolean)paramObject).booleanValue() ? ValuePool.getInt(1) : ValuePool.getInt(0);
        }
        break;
      case 4: 
        if ((paramObject instanceof Integer)) {
          return paramObject;
        }
        if ((paramObject instanceof String))
        {
          paramObject = Library.trim((String)paramObject, " ", true, true);
          int k = Integer.parseInt((String)paramObject);
          return ValuePool.getInt(k);
        }
        if ((paramObject instanceof Long))
        {
          l3 = ((Number)paramObject).longValue();
          if ((2147483647L < l3) || (l3 < -2147483648L)) {
            throw Trace.error(65);
          }
          return ValuePool.getInt(((Number)paramObject).intValue());
        }
        if (((paramObject instanceof Byte)) || ((paramObject instanceof Short))) {
          return ValuePool.getInt(((Number)paramObject).intValue());
        }
        if ((paramObject instanceof Number)) {
          return convertToInt(paramObject);
        }
        if ((paramObject instanceof Boolean)) {
          return ((Boolean)paramObject).booleanValue() ? ValuePool.getInt(1) : ValuePool.getInt(0);
        }
        break;
      case -5: 
        if ((paramObject instanceof Long)) {
          return paramObject;
        }
        if ((paramObject instanceof String))
        {
          paramObject = Library.trim((String)paramObject, " ", true, true);
          l3 = Long.parseLong((String)paramObject);
          return ValuePool.getLong(l3);
        }
        if ((paramObject instanceof Integer)) {
          return ValuePool.getLong(((Integer)paramObject).longValue());
        }
        if (((paramObject instanceof Byte)) || ((paramObject instanceof Short))) {
          return ValuePool.getLong(((Number)paramObject).intValue());
        }
        if ((paramObject instanceof Number)) {
          return convertToLong(paramObject);
        }
        if ((paramObject instanceof Boolean)) {
          return ((Boolean)paramObject).booleanValue() ? ValuePool.getLong(1L) : ValuePool.getLong(0L);
        }
        break;
      case 6: 
      case 7: 
      case 8: 
        if ((paramObject instanceof Double)) {
          return paramObject;
        }
        if ((paramObject instanceof String))
        {
          paramObject = Library.trim((String)paramObject, " ", true, true);
          double d = JavaSystem.parseDouble((String)paramObject);
          long l4 = Double.doubleToLongBits(d);
          return ValuePool.getDouble(l4);
        }
        if ((paramObject instanceof Number)) {
          return convertToDouble(paramObject);
        }
        if ((paramObject instanceof Boolean)) {
          return ((Boolean)paramObject).booleanValue() ? ValuePool.getDouble(1L) : ValuePool.getDouble(0L);
        }
        break;
      case 2: 
      case 3: 
        if ((paramObject instanceof BigDecimal)) {
          return paramObject;
        }
        if ((paramObject instanceof Long)) {
          return BigDecimal.valueOf(((Long)paramObject).longValue());
        }
        if ((paramObject instanceof Boolean)) {
          return ((Boolean)paramObject).booleanValue() ? BIG_DECIMAL_1 : BIG_DECIMAL_0;
        }
        break;
      case 16: 
        if ((paramObject instanceof Boolean)) {
          return (Boolean)paramObject;
        }
        if ((paramObject instanceof String))
        {
          paramObject = Library.trim((String)paramObject, " ", true, true);
          return ((String)paramObject).equalsIgnoreCase("TRUE") ? Boolean.TRUE : Boolean.FALSE;
        }
        if ((paramObject instanceof Integer)) {
          return ((Integer)paramObject).intValue() == 0 ? Boolean.FALSE : Boolean.TRUE;
        }
        if ((paramObject instanceof Long)) {
          return ((Long)paramObject).longValue() == 0L ? Boolean.FALSE : Boolean.TRUE;
        }
        if ((paramObject instanceof Double)) {
          return ((Double)paramObject).doubleValue() == 0.0D ? Boolean.FALSE : Boolean.TRUE;
        }
        if ((paramObject instanceof BigDecimal)) {
          return ((BigDecimal)paramObject).equals(BIG_DECIMAL_0) ? Boolean.FALSE : Boolean.TRUE;
        }
        throw Trace.error(16);
      case -1: 
      case 1: 
      case 12: 
      case 100: 
        if ((paramObject instanceof String)) {
          return paramObject;
        }
        if ((paramObject instanceof Time)) {
          return HsqlDateTime.getTimeString((Time)paramObject, null);
        }
        if ((paramObject instanceof Timestamp)) {
          return HsqlDateTime.getTimestampString((Timestamp)paramObject, null);
        }
        if ((paramObject instanceof Date)) {
          return HsqlDateTime.getDateString((Date)paramObject, null);
        }
        if ((paramObject instanceof byte[])) {
          return StringConverter.byteToHex((byte[])paramObject);
        }
        break;
      case 92: 
        if ((paramObject instanceof Time)) {
          return HsqlDateTime.getNormalisedTime((Time)paramObject);
        }
        if ((paramObject instanceof Timestamp)) {
          return HsqlDateTime.getNormalisedTime((Timestamp)paramObject);
        }
        if ((paramObject instanceof String)) {
          return HsqlDateTime.timeValue((String)paramObject);
        }
        if ((paramObject instanceof Date)) {
          throw Trace.error(95, Types.getTypeString(paramInt));
        }
        break;
      case 93: 
        if ((paramObject instanceof Timestamp)) {
          return paramObject;
        }
        if ((paramObject instanceof Time)) {
          return HsqlDateTime.getNormalisedTimestamp((Time)paramObject);
        }
        if ((paramObject instanceof Date)) {
          return HsqlDateTime.getNormalisedTimestamp((Date)paramObject);
        }
        if ((paramObject instanceof String)) {
          return HsqlDateTime.timestampValue((String)paramObject);
        }
        break;
      case 91: 
        if ((paramObject instanceof Date)) {
          return HsqlDateTime.getNormalisedDate((Date)paramObject);
        }
        if ((paramObject instanceof Timestamp)) {
          return HsqlDateTime.getNormalisedDate((Timestamp)paramObject);
        }
        if ((paramObject instanceof String)) {
          return HsqlDateTime.dateValue((String)paramObject);
        }
        if ((paramObject instanceof Time)) {
          throw Trace.error(95, Types.getTypeString(paramInt));
        }
        break;
      case -4: 
      case -3: 
      case -2: 
        if ((paramObject instanceof Binary)) {
          return paramObject;
        }
        if ((paramObject instanceof byte[])) {
          return new Binary((byte[])paramObject, false);
        }
        if ((paramObject instanceof String)) {
          return new Binary(StringConverter.hexToByte((String)paramObject), false);
        }
        throw Trace.error(95, Types.getTypeString(paramInt));
      case 1111: 
        if ((paramObject instanceof JavaObject)) {
          return paramObject;
        }
        if ((paramObject instanceof String)) {
          return new JavaObject(StringConverter.hexToByte((String)paramObject));
        }
        if ((paramObject instanceof Binary)) {
          return new JavaObject(((Binary)paramObject).getBytes());
        }
        return new JavaObject((Serializable)paramObject);
      }
      if ((paramObject instanceof JavaObject))
      {
        paramObject = ((JavaObject)paramObject).getObject();
        return convertObject(paramObject, paramInt);
      }
      return convertString(paramObject.toString(), paramInt);
    }
    catch (HsqlException localHsqlException)
    {
      throw localHsqlException;
    }
    catch (Exception localException)
    {
      throw Trace.error(16, localException.toString());
    }
  }
  
  private static Object convertString(String paramString, int paramInt)
    throws HsqlException
  {
    switch (paramInt)
    {
    case -6: 
    case 5: 
      return convertObject(paramString, paramInt);
    case 4: 
      int i = Integer.parseInt(paramString);
      return ValuePool.getInt(i);
    case -5: 
      return ValuePool.getLong(Long.parseLong(paramString));
    case 6: 
    case 7: 
    case 8: 
      double d = JavaSystem.parseDouble(paramString);
      long l = Double.doubleToLongBits(d);
      return ValuePool.getDouble(l);
    case -1: 
    case 1: 
    case 12: 
    case 100: 
      return paramString;
    case 91: 
      return HsqlDateTime.dateValue(paramString);
    case 92: 
      return HsqlDateTime.timeValue(paramString);
    case 93: 
      return HsqlDateTime.timestampValue(paramString);
    case 2: 
    case 3: 
      paramString = Library.trim(paramString, " ", true, true);
      return new BigDecimal(paramString);
    case 16: 
      return paramString.equalsIgnoreCase("TRUE") ? Boolean.TRUE : Boolean.FALSE;
    }
    throw Trace.error(95, Types.getTypeString(paramInt));
  }
  
  static String createSQLString(Object paramObject, int paramInt)
    throws HsqlException
  {
    if (paramObject == null) {
      return "NULL";
    }
    switch (paramInt)
    {
    case 0: 
      return "NULL";
    case 6: 
    case 7: 
    case 8: 
      return createSQLString(((Number)paramObject).doubleValue());
    case 91: 
    case 92: 
    case 93: 
      return StringConverter.toQuotedString(paramObject.toString(), '\'', false);
    case -4: 
    case -3: 
    case -2: 
      if (!(paramObject instanceof Binary)) {
        throw Trace.error(95);
      }
      return StringConverter.toQuotedString(StringConverter.byteToHex(((Binary)paramObject).getBytes()), '\'', false);
    case 1111: 
      if (!(paramObject instanceof JavaObject)) {
        throw Trace.error(18);
      }
      return StringConverter.toQuotedString(StringConverter.byteToHex(((JavaObject)paramObject).getBytes()), '\'', false);
    case -1: 
    case 1: 
    case 12: 
    case 100: 
      return createSQLString((String)paramObject);
    }
    return paramObject.toString();
  }
  
  public static String createSQLString(double paramDouble)
  {
    if (paramDouble == Double.NEGATIVE_INFINITY) {
      return "-1E0/0";
    }
    if (paramDouble == Double.POSITIVE_INFINITY) {
      return "1E0/0";
    }
    if (Double.isNaN(paramDouble)) {
      return "0E0/0E0";
    }
    String str = Double.toString(paramDouble);
    if (str.indexOf('E') < 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd