1 package com.daffodilwoods.daffodildb.server.sql99.token; 2 3 import java.math.*; 4 5 import com.daffodilwoods.daffodildb.server.sql99.common.*; 6 import com.daffodilwoods.daffodildb.server.sql99.expression.*; 7 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.*; 8 import com.daffodilwoods.daffodildb.server.sql99.expression.rowvalueexpression.*; 9 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 10 import com.daffodilwoods.daffodildb.utils.byteconverter.*; 11 import com.daffodilwoods.daffodildb.utils.field.*; 12 import com.daffodilwoods.database.resource.*; 13 14 public class unsignedintegermultiplier extends AbstractValueExpression implements com.daffodilwoods.daffodildb.utils.parser.StatementExecuter, largeobjectlength, exactnumericliteral, Datatypes { 15 public multiplier _multiplier0; 16 public unsignedinteger _unsignedinteger1; 17 18 private ColumnDetails cd; 19 private BigDecimal identifier; 20 private byte[] returningBytes = null; 21 private FieldBase fieldBase; 22 23 public int getCardinality() throws DException { 24 return 1; 25 } 26 27 public Object run(Object object) throws com.daffodilwoods.database.resource.DException { 28 ColumnDetails cd = getColumnDetails()[0]; 29 if (fieldBase == null) { 30 fieldBase = new FieldLiteral(cd.getObject().toString(), -1); 31 } 32 return fieldBase; 33 } 34 35 private int getMultiplierPart() throws com.daffodilwoods.database.resource.DException { 36 String str = ( (String ) _multiplier0.run(null)).trim(); 37 int hashCOde = str.hashCode(); 38 switch (hashCOde) { 39 case 75: 40 case 107: 41 return 1024; case 77: 43 case 109: 44 return 1048576; case 71: 46 case 103: 47 return 1073741824; } 49 throw new DException("DSE412", new Object [] {str}); 50 } 51 52 public ColumnDetails[] getColumnDetails() throws DException { 53 cd = new ColumnDetails(); 54 cd.setType(CONSTANT); 55 Object ob = ( (FieldBase) _unsignedinteger1.run(null)).getObject(); 56 java.math.BigDecimal number = new BigDecimal("" + ob); 57 number = number.multiply(new BigDecimal("" + getMultiplierPart())); 58 cd.setColumnName(new String [] {number.toString()}); 59 cd.setObject(number); 60 return new ColumnDetails[] {cd}; 61 } 62 63 public Object [] getParameters(Object object) throws DException { 64 return null; 65 } 66 67 public int getType() { 68 return OTHERS; 69 } 70 71 private byte[] getAppropriateBytes() throws DException { 72 int datatype = cd.getDatatype(); 73 switch (datatype) { 74 case INT: 75 return CCzufDpowfsufs.getBytes(new Integer (identifier.intValue())); 76 case TINYINT: 77 return CCzufDpowfsufs.getBytes(new Integer (identifier.intValue())); 78 case INTEGER: 79 return CCzufDpowfsufs.getBytes(new Integer (identifier.intValue())); 80 case LONG: 81 return CCzufDpowfsufs.getBytes(new Long (identifier.longValue())); 82 case SHORT: 83 return CCzufDpowfsufs.getBytes(new Short (identifier.shortValue())); 84 case SMALLINT: 85 return CCzufDpowfsufs.getBytes(new Short (identifier.shortValue())); 86 case BYTE: 87 return new byte[] {identifier.byteValue()}; 88 case FLOAT: 89 return CCzufDpowfsufs.getBytes(new Float (identifier.floatValue())); 90 case DOUBLE: 91 return CCzufDpowfsufs.getBytes(new Double (identifier.doubleValue())); 92 case BIGDECIMAL: 93 return CCzufDpowfsufs.getBytes(identifier); 94 default: 95 throw new DException("DSE514", new Object [] {new Integer (datatype)}); 96 } 97 } 98 99 public AbstractRowValueExpression[] getChilds() { 100 AbstractRowValueExpression[] childs = new AbstractRowValueExpression[] {}; 101 return childs; 102 } 103 104 public String toString() { 105 StringBuffer sb = new StringBuffer (); 106 sb.append(" "); 107 sb.append(_unsignedinteger1); 108 sb.append(" "); 109 sb.append(_multiplier0); 110 return sb.toString(); 111 } 112 113 public Object clone() throws CloneNotSupportedException { 114 unsignedintegermultiplier tempClass = new unsignedintegermultiplier(); 115 tempClass._multiplier0 = (multiplier) _multiplier0.clone(); 116 tempClass._unsignedinteger1 = (unsignedinteger) _unsignedinteger1.clone(); 117 return tempClass; 118 } 119 120 public ParameterInfo[] getParameterInfo() throws DException { 121 ParameterInfo parameterInfo = new ParameterInfo(); 122 parameterInfo.setDataType(cd.getDatatype()); 123 return new ParameterInfo[] {parameterInfo}; 124 } 125 126 public ByteComparison getByteComparison(Object object) throws DException { 127 return new ByteComparison(true, new int[] {cd.getDatatype()}); 128 } 129 130 public void releaseResource() throws DException { 131 } 132 } 133 | Popular Tags |