1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.types.TypeId; 25 26 import org.apache.derby.iapi.error.StandardException; 27 28 import org.apache.derby.iapi.services.compiler.MethodBuilder; 29 30 import org.apache.derby.impl.sql.compile.ExpressionClassBuilder; 31 import org.apache.derby.iapi.types.BooleanDataValue; 32 33 import org.apache.derby.iapi.services.sanity.SanityManager; 34 35 import org.apache.derby.iapi.util.ReuseFactory; 36 import org.apache.derby.iapi.util.StringUtil; 37 import java.sql.Types ; 38 39 public class SQLBooleanConstantNode extends ConstantNode 40 { 41 48 49 public void init( 50 Object newValue) 51 throws StandardException 52 { 53 String strVal = (String ) newValue; 54 Boolean val = null; 55 56 if (SanityManager.DEBUG) 57 { 58 SanityManager.ASSERT((StringUtil.SQLEqualsIgnoreCase(strVal,"true")) || 59 (StringUtil.SQLEqualsIgnoreCase(strVal,"false")) || 60 (StringUtil.SQLEqualsIgnoreCase(strVal,"unknown")), 61 "String \"" + strVal + 62 "\" cannot be converted to a SQLBoolean"); 63 } 64 65 if (StringUtil.SQLEqualsIgnoreCase(strVal,"true")) 66 val = Boolean.TRUE; 67 else if (StringUtil.SQLEqualsIgnoreCase(strVal,"false")) 68 val = Boolean.FALSE; 69 70 74 75 76 super.init( 77 TypeId.BOOLEAN_ID, 78 Boolean.TRUE, 79 ReuseFactory.getInteger(1)); 80 81 if ( val == null ) 82 { 83 setValue(getTypeServices().getNull() ); 84 } 85 else 86 { 87 setValue(getDataValueFactory().getDataValue(val.booleanValue())); 88 } 89 } 90 91 101 void generateConstant(ExpressionClassBuilder acb, MethodBuilder mb) 102 throws StandardException 103 { 104 mb.push(value.getBoolean()); 105 } 106 } 107 | Popular Tags |