Package org.datanucleus.query.symbol

Examples of org.datanucleus.query.symbol.Symbol


            // Load subqueries into symbol table so the compilation knows about them
            Iterator<String> subqueryIter = subqueryMap.keySet().iterator();
            while (subqueryIter.hasNext())
            {
                String subqueryName = subqueryIter.next();
                Symbol sym = new PropertySymbol(subqueryName);
                sym.setType(Symbol.VARIABLE);
                symtbl.addSymbol(sym);
            }
        }

        Expression[] exprFrom = compileFrom();
View Full Code Here


        if (exprResult != null && exprResult.length > 0)
        {
            Class[] results = new Class[exprResult.length];
            for (int i=0;i<exprResult.length;i++)
            {
                Symbol colSym = exprResult[i].getSymbol();
                results[i] = colSym.getValueType();
            }
            return results;
        }
        else
        {
View Full Code Here

        str.append(indent).append("[symbols: ");
        Iterator<String> symIter = symtbl.getSymbolNames().iterator();
        while (symIter.hasNext())
        {
            String symName = symIter.next();
            Symbol sym = symtbl.getSymbol(symName);
            if (sym.getValueType() != null)
            {
                str.append(symName + " type=" + sym.getValueType().getName());
            }
            else
            {
                str.append(symName + " type=unknown");
            }
View Full Code Here

                            while (tupleIter.hasNext())
                            {
                                String tuple = tupleIter.next();
                                if (cls == null)
                                {
                                    Symbol sym = symtbl.getSymbol(tuple);
                                    if (sym == null)
                                    {
                                        sym = symtbl.getSymbol("this");
                                        if (sym == null)
                                        {
                                            // TODO Need to get hold of candidate alias
                                            break;
                                        }
                                    }
                                    cls = sym.getValueType();
                                }
                                else
                                {
                                    // Look for member of the current class
                                    if (cls.isArray() && tuple.equals("length") && !tupleIter.hasNext())
View Full Code Here

                Node childNode = (Node)childIter.next();
                if (childNode.getNodeType() == NodeType.OPERATOR)
                {
                    Node joinedNode = childNode.getFirstChild();
                    String joinedAlias = (String)joinedNode.getNodeValue();
                    Symbol joinedSym =
                        (caseSensitiveAliases ? symtbl.getSymbol(joinedAlias) : symtbl.getSymbolIgnoreCase(joinedAlias));
                    if (joinedSym == null)
                    {
                        throw new QueryCompilerSyntaxException("FROM clause has identifier " + joinedNode.getNodeValue() + " but this is unknown");
                    }
                    AbstractClassMetaData joinedCmd = metaDataManager.getMetaDataForClass(joinedSym.getValueType(), clr);
                    Class joinedCls = joinedSym.getValueType();
                    while (joinedNode.getFirstChild() != null)
                    {
                        joinedNode = joinedNode.getFirstChild();
                        String joinedMember = (String)joinedNode.getNodeValue();
                        AbstractMemberMetaData mmd = joinedCmd.getMetaDataForMember(joinedMember);
View Full Code Here

            cls = parentCompiler.candidateClass;
        }
        else
        {
            // Try alias from parent query
            Symbol sym = parentCompiler.symtbl.getSymbolIgnoreCase(tokens[0]);
            if (sym != null)
            {
                cls = sym.getValueType();
            }
            else
            {
                // Must be a class name
                return resolveClass(classExpr);
View Full Code Here

            String varName = (String) node[i][1].getNodeValue();
            if (isKeyword(varName) || varName.equals(candidateAlias))
            {
                throw new NucleusUserException(LOCALISER.msg("021052", getLanguage(), varName));
            }
            Symbol varSym = symtbl.getSymbol(varName);
            Class nodeCls = resolveClass(node[i][0].getNodeChildId());
            if (varSym != null)
            {
                if (nodeCls != null)
                {
                    // Update the value type
                    varSym.setValueType(nodeCls);
                }
            }
            else
            {
                PropertySymbol sym = new PropertySymbol(varName, nodeCls);
View Full Code Here

            if (isKeyword(paramName) || paramName.equals(candidateAlias))
            {
                throw new NucleusUserException(LOCALISER.msg("021052", getLanguage(), paramName));
            }

            Symbol paramSym = symtbl.getSymbol(paramName);
            Class nodeCls = resolveClass(node[i][0].getNodeChildId());
            if (paramSym != null)
            {
                // TODO Update the type ?
            }
View Full Code Here

    }

    public Class getType(List tuples)
    {
        Class type = null;
        Symbol symbol = null;
        String firstTuple = (String)tuples.get(0);
        if (caseSensitiveSymbolNames())
        {
            symbol = symtbl.getSymbol(firstTuple);
        }
        else
        {
            symbol = symtbl.getSymbol(firstTuple);
            if (symbol == null)
            {
                symbol = symtbl.getSymbol(firstTuple.toUpperCase());
            }
            if (symbol == null)
            {
                symbol = symtbl.getSymbol(firstTuple.toLowerCase());
            }
        }
        if (symbol != null)
        {
            type = symbol.getValueType();
            if (type == null)
            {
                // Implicit variables don't have their type defined
                throw new NucleusUserException("Cannot find type of " + tuples.get(0) +
                    " since symbol has no type; implicit variable?");
            }

            for (int i=1; i<tuples.size(); i++)
            {
                type = getType(type, (String)tuples.get(i));
            }
        }
        else
        {
            symbol = symtbl.getSymbol(candidateAlias);
            type = symbol.getValueType();
            for (int i=0; i<tuples.size(); i++)
            {
                type = getType(type, (String)tuples.get(i));
            }
        }
View Full Code Here

            return;
        }

        // Apply to the main query
        boolean symbolFound = false;
        Symbol sym = compilation.getSymbolTable().getSymbol(name);
        if (sym != null)
        {
            symbolFound = true;
            if (sym.getValueType() == null && value != null)
            {
                // Update the compilation providing the type of this parameter
                sym.setValueType(value.getClass());
            }
            else if (sym.getValueType() != null && value != null)
            {
                if (!QueryUtils.queryParameterTypesAreCompatible(sym.getValueType(), value.getClass()))
                {
                    // Parameter value supplied is not consistent with what the query compilation expects
                    throw new QueryInvalidParametersException("Parameter " + name +
                        " needs to be assignable from " + sym.getValueType().getName() +
                        " yet the value is of type " + value.getClass().getName());
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.datanucleus.query.symbol.Symbol

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.