⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sqlparser.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	** 		  This function assumes that the leading and trailing quote from a	** 		  string or delimited identifier have already been removed.	*/        private static String compressQuotes(String source, String quotes)        {                String  result = source;                int             index;                /* Find the first occurrence of adjacent quotes. */                index = result.indexOf(quotes);                /* Replace each occurrence with a single quote and begin the		 * search for the next occurrence from where we left off.		 */                while (index != -1)                {                        result = result.substring(0, index + 1) + result.substring(index + 2);                        index = result.indexOf(quotes, index + 1);                }                return result;        }        private static void verifyImageLength(String image) throws StandardException                {                // beetle 2758.  For right now throw an error for literals > 64K                if (image.length() > MAX_UTF8_LENGTH)                        {                throw StandardException.newException(SQLState.LANG_INVALID_LITERAL_LENGTH);                        }                }        /*	** Converts a delimited id to a canonical form.	** Post process delimited identifiers to eliminate leading and	** trailing " and convert all occurrences of "" to ".	*/        private static String normalizeDelimitedID(String str)        {                str = compressQuotes(str, DOUBLEQUOTES);                return str;        }        private static boolean isDATETIME(int val)        {                if (val == DATE || val == TIME || val == TIMESTAMP)                        return true;                else                        return false;        }        /*	 * Generate a multiplicative operator node, if necessary.	 *	 * If there are two operands, generate the multiplicative operator	 * that corresponds to the multiplicativeOperator parameter.  If there	 * is no left operand, just return the right operand.	 *	 * @param leftOperand	The left operand, null if no operator	 * @param rightOperand	The right operand	 * @param multiplicativeOperator	An identifier from BinaryOperatorNode	 *									telling what operator to generate.	 *	 * @return	The multiplicative operator, or the right operand if there is	 *			no operator.	 *	 * @exception StandardException		Thrown on error	 */        ValueNode multOp(ValueNode leftOperand,                                                        ValueNode rightOperand,                                                        int multiplicativeOperator)                                        throws StandardException        {                if (leftOperand == null)                {                        return rightOperand;                }                switch (multiplicativeOperator)                {                  case BinaryOperatorNode.TIMES:                        return (ValueNode) nodeFactory.getNode(                                                                        C_NodeTypes.BINARY_TIMES_OPERATOR_NODE,                                                                        leftOperand,                                                                        rightOperand,                                                                        getContextManager());                  case BinaryOperatorNode.DIVIDE:                        return (ValueNode) nodeFactory.getNode(                                                                        C_NodeTypes.BINARY_DIVIDE_OPERATOR_NODE,                                                                        leftOperand,                                                                        rightOperand,                                                                        getContextManager());                  case BinaryOperatorNode.CONCATENATE:                        return (ValueNode) nodeFactory.getNode(                                                                        C_NodeTypes.CONCATENATION_OPERATOR_NODE,                                                                        leftOperand,                                                                        rightOperand,                                                                        getContextManager());                  default:                        if (SanityManager.DEBUG)                        SanityManager.THROWASSERT("Unexpected multiplicative operator " +                                                                                multiplicativeOperator);                        return null;                }        }        /**	 * Set up and like the parameters to the descriptors.	 * Set all the ParameterNodes to point to the array of	 * parameter descriptors.	 * 	 * @return Nothing	 *	@exception	StandardException	 */         private void setUpAndLinkParameters()                        throws StandardException         {                CompilerContext cc = getCompilerContext();                cc.setParameterList(parameterList);                /* Link the untyped parameters to the array of parameter descriptors */                DataTypeDescriptor[] descriptors = cc.getParameterTypes();                ParameterNode                           newNode;                ParameterNode                           oldNode;                int                                                     paramCount;                /*		** Iterate through the list of untyped parameter nodes, set each one		** to point to the array of parameter descriptors.		*/                paramCount = -1;                int plSize = parameterList.size();                for (int index = 0; index < plSize; index++)                {                        paramCount++;                        newNode = (ParameterNode) parameterList.elementAt(index);                        newNode.setDescriptors(descriptors );                }        }        /**	 *  Initializes the list of unnamed parameters, i.e., "?" parameters	 *	 *	Usually, this routine just gets an empty list for the unnamed parameters.	 *	 *	 */        void    initUnnamedParameterList()        {                parameterList = new Vector();        }        /**	 * Makes a new unnamed ParameterNode and chains it onto parameterList.	 *	 *	@return	new unnamed parameter.	 *	 *	@exception	StandardException	 */        ParameterNode   makeParameterNode(  )                                        throws StandardException        {                ParameterNode   parm;                DataValueDescriptor sdv = null;                if ((paramDefaults != null) && (parameterNumber < paramDefaults.length))                {                        sdv = (DataValueDescriptor) paramDefaults[parameterNumber];                }                parm = (ParameterNode) nodeFactory.getNode(                                                                C_NodeTypes.PARAMETER_NODE,                                                                ReuseFactory.getInteger(parameterNumber),                                                                sdv,                                                                getContextManager());                parameterNumber++;                parameterList.addElement(parm);                return parm;        }        /**	 * Looks up an unnamed parameter given its parameter number.	 *	 *	@param	paramNumber		Number of parameter in unnamed	 *							parameter list.	 *	 *	@return	corresponding unnamed parameter.	 *	 */        ParameterNode   lookupUnnamedParameter( int paramNumber )        {                ParameterNode           unnamedParameter;                unnamedParameter = (ParameterNode) parameterList.elementAt( paramNumber );                return unnamedParameter;        }        /**	 * Translate a String containing a number into the appropriate type	 * of Numeric node.	 *	 * @exception StandardException		Thrown on error	 */        ValueNode getNumericNode(String num) throws StandardException        {                ContextManager cm = getContextManager();                // first, see if it might be an integer                try                {                        return (ValueNode) nodeFactory.getNode(                                                                                C_NodeTypes.INT_CONSTANT_NODE,                                                                                new Integer(num),                                                                                cm);                }                catch (NumberFormatException nfe)                {                        // we catch because we want to continue on below                }                // next, see if it might be a long                try                {                        return (ValueNode) nodeFactory.getNode(                                                                                C_NodeTypes.LONGINT_CONSTANT_NODE,                                                                                new Long(num),                                                                                cm);                }                catch (NumberFormatException nfe)                {                        // we catch because we want to continue on below                }                return (ValueNode) nodeFactory.getNode(                                                                        C_NodeTypes.DECIMAL_CONSTANT_NODE,                                                                        num,                                                                        cm);        }        /**	 * Determine whether the current token represents one of	 * the built-in aliases.	 *	 * @return	TRUE iff the current token names a built-in alias	 */        private boolean isBuiltInAlias()        {                boolean retval = false;                switch (token.kind)                {                  case UCASE:                  case LCASE:                  case SQRT:                  case LOCATE:                  case ABS:                  case ABSVAL:                  case SUBSTR:                  case MOD:                        retval = true;                        break;                  default:                        retval = false;                        break;                }                return retval;        }        /**	 * Determine whether the next sequence of tokens represents one of	 * the common (built-in) datatypes.	 *	 * @return	TRUE iff the next set of tokens names a common datatype	 */        boolean commonDatatypeName(boolean checkFollowingToken)        {                boolean retval = false;                switch (getToken(1).kind)                {                  case CHARACTER:                  case CHAR:                  case VARCHAR:                  case NVARCHAR:                  case NCHAR:                  case BIT:                  case NUMERIC:                  case DECIMAL:                  case DEC:                  case INTEGER:                  case INT:                  case SMALLINT:                  case LONGINT:                  case FLOAT:                  case REAL:                  case DATE:                  case TIME:                  case TIMESTAMP:                  case BOOLEAN:                  case DOUBLE:                  case BLOB:                  case CLOB:                  case NCLOB:                  case BINARY: // LARGE OBJECT                  case XML:                        retval = true;                        break;                  case LONG:                        if (checkFollowingToken == true)                        {                                switch (getToken(2).kind)                                {                                  case VARCHAR:                                  case NVARCHAR:                                  case BINARY:                                  case VARBINARY:                                  case BIT:                                        retval = true;                                        break;                                }                                break;                        }                        else                        {                                retval = true;                                break;                        }                  case NATIONAL:                        if (checkFollowingToken == true)                        {                                switch (getToken(2).kind)                                {                                  case CHAR:                                  case CHARACTER:                                        retval = true;                                        break;                                }                                break;                        }                        else                        {                                retval = true;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -