1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.services.sanity.SanityManager; 25 import org.apache.derby.iapi.sql.compile.Visitable; 26 import org.apache.derby.iapi.sql.compile.Visitor; 27 28 29 import org.apache.derby.iapi.store.access.Qualifier; 30 import org.apache.derby.iapi.error.StandardException; 31 32 51 public class HasVariantValueNodeVisitor implements Visitor 52 { 53 private boolean hasVariant; 54 private int variantType; 55 private boolean ignoreParameters; 56 57 58 61 public HasVariantValueNodeVisitor() 62 { 63 this.variantType = Qualifier.VARIANT; 64 this.ignoreParameters = false; 65 if (SanityManager.DEBUG) 66 { 67 SanityManager.ASSERT(Qualifier.VARIANT < Qualifier.SCAN_INVARIANT, "qualifier constants not ordered as expected"); 68 SanityManager.ASSERT(Qualifier.SCAN_INVARIANT < Qualifier.QUERY_INVARIANT, "qualifier constants not ordered as expected"); 69 } 70 } 71 72 73 86 public HasVariantValueNodeVisitor(int variantType, boolean ignoreParameters) 87 { 88 this.variantType = variantType; 89 this.ignoreParameters = ignoreParameters; 90 91 if (SanityManager.DEBUG) 92 { 93 SanityManager.ASSERT(variantType >= Qualifier.VARIANT, "bad variantType"); 94 SanityManager.ASSERT(variantType <= Qualifier.QUERY_INVARIANT, "bad variantType"); 97 } 98 } 99 100 106 115 public Visitable visit(Visitable node) throws StandardException 116 { 117 if (node instanceof ValueNode) 118 { 119 if (ignoreParameters && ((ValueNode)node).requiresTypeFromContext()) 120 return node; 121 122 if (((ValueNode)node).getOrderableVariantType() <= variantType) 123 { 124 hasVariant = true; 125 } 126 } 127 return node; 128 } 129 130 public boolean skipChildren(Visitable node) 131 { 132 return false; 133 } 134 135 140 public boolean stopTraversal() 141 { 142 return hasVariant; 143 } 144 145 156 public boolean hasVariant() 157 { 158 return hasVariant; 159 } 160 } 161 | Popular Tags |