Package org.jpox.store.mapped.expression

Examples of org.jpox.store.mapped.expression.ClassExpression


            candidateAlias = exprs[0].getAlias().toUpperCase(); // Identifiers are case insensitive

            candidateExpressions = new ClassExpression[exprs.length];
            for (int i=0; i<candidateExpressions.length; i++)
            {
                ClassExpression classExpr = (ClassExpression)exprs[i];
                if (classExpr.getCls() == null)
                {
                    // Candidate expression is for the candidate but candidate wasnt known at the time of compilation
                    candidateExpressions[i] = new ClassExpression(qs, candidateClass);
                    candidateExpressions[i].as(candidateAlias);
                    JoinExpression[] joins = classExpr.getJoins();
                    if (joins != null)
                    {
                        for (int j=0;j<joins.length;j++)
                        {
                            candidateExpressions[i].join(joins[j]);
View Full Code Here


     * @param fromStr The from expression string
     * @return Class Expression for this part of the FROM
     */
    protected ClassExpression compileFromExpression(String fromStr)
    {
        ClassExpression expr = null;

        p = new JPQLParser(fromStr, imports);
        if (p.parseStringIgnoreCase("IN"))
        {
            // "IN(...) [AS] alias"
            if (!p.parseChar('('))
            {
                throw new QueryCompilerSyntaxException("Expected: '(' but got " + p.remaining(),
                    p.getIndex(), p.getInput());
            }

            // Find what we are joining to
            String name = p.parseIdentifier();
            if (p.nextIsDot())
            {
                p.parseChar('.');
                name += ".";
                name += p.parseName();
            }

            if (!p.parseChar(')'))
            {
                throw new QueryCompilerSyntaxException("Expected: ')' but got " + p.remaining(),
                    p.getIndex(), p.getInput());
            }

            p.parseStringIgnoreCase("AS"); // Optional
            String alias = p.parseName();

            // Return as part of ClassExpression joining candidate class to this collection field
            expr = new ClassExpression(qs, candidateClass);
            expr.as(candidateAlias);
            JoinExpression joinExpr = new JoinExpression(qs, name, false, false);
            joinExpr.as(alias);
            expr.join(joinExpr);

            // Update with any subsequent JOIN expressions
            compileFromJoinExpressions(expr);
        }
        else
        {
            // "<candidate_expression> [AS] alias"
            String id = p.parseIdentifier();

            String name = id;
            if (p.nextIsDot())
            {
                p.parseChar('.');
                name += ".";
                name += p.parseName();
            }

            if (parentExpr != null)
            {
                // Subquery, so calculate any candidate expression
                Class cls = null;
                cls = getClassForSubqueryCandidateExpression(name);
                expr = new ClassExpression(qs, cls);
                id = p.parseIdentifier();
                if (id != null)
                {
                    // Add alias to class/class.field
                    if (id.equalsIgnoreCase("AS"))
                    {
                        id = p.parseIdentifier();
                    }
                    if (id != null)
                    {
                        expr.as(id);
                    }
                }
            }
            else
            {
                Class cls = query.resolveClassDeclaration(name);
                expr = new ClassExpression(qs, cls);
                id = p.parseIdentifier();
                if (id != null)
                {
                    // Add alias to class/class.field
                    if (id.equalsIgnoreCase("AS"))
                    {
                        id = p.parseIdentifier();
                    }
                    if (id != null)
                    {
                        expr.as(id);
                    }
                }
            }

            // Update with any subsequent JOIN expressions
View Full Code Here

                Class cls = null;
                try
                {
                    cls = query.resolveClassDeclaration(name);
                    expr = new ClassExpression(qs, cls);
                }
                catch (JPOXUserException jdoe)
                {
                    if (aliasInfo == null && name.indexOf('.') > 0)
                    {
                        // Try without the last part of the name (in case its a class name plus field or method)
                        String partialName = name.substring(0, name.lastIndexOf('.'));
                        String finalNamePart = name.substring(name.lastIndexOf('.')+1);
                        try
                        {
                            //try method invocation
                            expr = callUserDefinedScalarExpression(name);
                            if (expr == null)
                            {
                                cls = query.resolveClassDeclaration(partialName);
                                //try field access
                                expr = new ClassExpression(qs, cls);
                                expr = expr.accessField(finalNamePart, true);
                            }
                        }
                        catch (JPOXUserException jdoe2)
                        {
                            throw new JPOXUserException(LOCALISER.msg("021066", partialName),jdoe2);
                        }
                    }
                    else
                    {
                        try
                        {
                            // try with candidate class using field access
                            expr = new ClassExpression(qs, candidateClass);
                            expr = expr.accessField(name, true);
                        }
                        catch (JPOXUserException jdoe2)
                        {
                            // Implicit variable
View Full Code Here

                Class cls = null;
                try
                {
                    cls = query.resolveClassDeclaration(name);
                    expr = new ClassExpression(qs, cls);
                }
                catch (JPOXUserException jpue)
                {
                    if (name.indexOf('.') > 0)
                    {
                        // Try without the last part of the name (in case its a class name plus field or method)
                        String partialName = name.substring(0, name.lastIndexOf('.'));
                        String finalNamePart = name.substring(name.lastIndexOf('.') + 1);
                        try
                        {
                            // try method invocation
                            expr = callUserDefinedScalarExpression(name);
                            if (expr == null)
                            {
                                // try with this class using field access
                                cls = query.resolveClassDeclaration(partialName);
                                expr = new ClassExpression(qs, cls);
                                expr = expr.accessField(finalNamePart, true);
                            }
                        }
                        catch (JPOXUserException jpue2)
                        {
                            throw new JPOXUserException(LOCALISER.msg("021066", partialName), jpue2);
                        }
                    }
                    else
                    {
                        try
                        {
                            // try with candidate class using field access
                            expr = new ClassExpression(qs, candidateClass);
                            expr = expr.accessField(name, true);
                        }
                        catch (JPOXUserException jpue2)
                        {
                            // Implicit variable
View Full Code Here

TOP

Related Classes of org.jpox.store.mapped.expression.ClassExpression

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.