1 package com.daffodilwoods.daffodildb.server.sql99.expression.numericvalueexpression; 2 3 import java.util.*; 4 5 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.*; 6 import com.daffodilwoods.daffodildb.server.serversystem.*; 7 import com.daffodilwoods.daffodildb.server.sql99.common.*; 8 import com.daffodilwoods.daffodildb.server.sql99.expression.rowvalueexpression.*; 9 import com.daffodilwoods.daffodildb.server.sql99.token.*; 10 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 11 import com.daffodilwoods.daffodildb.utils.*; 12 import com.daffodilwoods.daffodildb.utils.field.*; 13 import com.daffodilwoods.database.resource.*; 14 15 public class randfunction extends AbstractNumericValueFunction { 16 17 public parennumericvalueexpression _parennumericvalueexpression0; 18 public SNONRESERVEDWORD136444255 _SNONRESERVEDWORD1364442551; 19 20 protected Object getResult(int type, Object object) throws DException { 21 if (object == null) { 22 return new FieldLiteral(FieldUtility.NULLBUFFERRANGE, Datatype.DOUBLE); 23 } 24 try { 25 if (type <= 15) { 26 Random random = new Random(); 27 random.setSeed( ( (Number ) object).longValue()); 28 return new FieldLiteral(new Double (random.nextFloat()), Datatype.DOUBLE); 29 } 30 throw new DException("DSE4108", 31 new Object [] {StaticClass.getDataTypeName(type), 32 "RAND"}); 33 34 49 } catch (Exception e) { 50 throw new DException("DSE419", new Object [] {"RAND"}); 51 } 52 } 53 54 95 96 public AbstractRowValueExpression[] getChilds() { 97 AbstractRowValueExpression[] childs = new AbstractRowValueExpression[] {_parennumericvalueexpression0}; 98 return childs; 99 } 100 101 public String getType() throws DException { 102 return (String ) _SNONRESERVEDWORD1364442551.run(null); 103 } 104 105 public String toString() { 106 StringBuffer sb = new StringBuffer (); 107 sb.append(" "); 108 sb.append(_SNONRESERVEDWORD1364442551); 109 sb.append(_parennumericvalueexpression0); 110 return sb.toString(); 111 } 112 113 public Object clone() throws CloneNotSupportedException { 114 randfunction tempClass = new randfunction(); 115 tempClass._parennumericvalueexpression0 = (parennumericvalueexpression) _parennumericvalueexpression0.clone(); 116 tempClass._SNONRESERVEDWORD1364442551 = (SNONRESERVEDWORD136444255) _SNONRESERVEDWORD1364442551.clone(); 117 return tempClass; 118 } 119 120 public ParameterInfo[] getParameterInfo() throws DException { 121 ParameterInfo[] paramInfo = super.getParameterInfo(); 122 for (int i = 0; i < paramInfo.length; i++) { 123 if (paramInfo[i].getQuestionMark()) { 124 paramInfo[i].setDataType(Datatypes.DOUBLE); 125 paramInfo[i].setName("RAND Arg"); 126 } 127 } 128 return paramInfo; 129 } 130 131 132 public ByteComparison getByteComparison(Object object) throws DException { 133 ByteComparison byteComparison = new ByteComparison(false, new int[] {DOUBLE}); 134 byteComparison.setSize(getColumnSize(object)); 135 return byteComparison; 136 } 137 138 public _Reference[] checkSemantic(_ServerSession parent) throws DException { 139 _Reference[] ref = super.checkSemantic(parent); 140 if(ref!=null) { 141 return ref; 142 } 143 int type = _parennumericvalueexpression0.getByteComparison(parent).getDataTypes()[0]; 144 if (type == -1 || type <= 15) { 145 return ref; 146 } 147 throw new DException("DSE4108", new Object [] {StaticClass.getDataTypeName(type), "RAND"}); 148 } 149 public int getColumnSize(Object object) throws DException { 150 return Datatypes.DOUBLESIZE; 151 } 152 153 } 154 | Popular Tags |