/* // $Id: //guest/julian_hyde/saffron/src/main/openjava/ptree/JoinExpression.java#2 $ // Saffron preprocessor and data engine // Copyright (C) 2002 Julian Hyde <julian.hyde@mail.com> // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public // License along with this library; if not, write to the // Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. // // See the COPYING file located in the top-level-directory of // the archive of this library for complete text of license. */ package openjava.ptree; import openjava.mop.Environment; import openjava.mop.OJClass; import openjava.ptree.util.SyntheticClass; import openjava.tools.parser.ParserConstants; /** * JoinExpression is a pair of joined relational expressions appearing in the * from clause of a {@link QueryExpression}. */ public class JoinExpression extends SetExpression { /** * Constructs a <code>JoinExpression</code>. * * @param joinType type of join; allowable values are {@link * ParserConstants#LEFT}, {@link ParserConstants#RIGHT}, {@link * ParserConstants#FULL}, and {@link ParserConstants#INNER} * signifies an ordinary join. **/ public JoinExpression( Expression left, Expression right, int joinType, Expression condition) { set(left, right, new Integer(joinType), condition); } public Expression getLeft() { return (Expression) elementAt(0); } public Expression getRight() { return (Expression) elementAt(1); } public int getJoinType() { return ((Integer) elementAt(2)).intValue(); } public String getJoinTypeName() { switch (getJoinType()) { case ParserConstants.INNER: return "inner"; case ParserConstants.LEFT: return "left"; case ParserConstants.RIGHT: return "right"; case ParserConstants.FULL: return "full"; default: throw new UnsupportedOperationException(); } } /** * Returns {@link ParserConstants#INNER} if <code>s</code> is "inner", * and similarly for {@link ParserConstants#LEFT}, {@link * ParserConstants#RIGHT}, {@link ParserConstants#FULL}. **/ public static int getJoinTypeCode(String s) { if (s.equalsIgnoreCase("inner")) { return ParserConstants.INNER; } else if (s.equalsIgnoreCase("left")) { return ParserConstants.LEFT; } else if (s.equalsIgnoreCase("right")) { return ParserConstants.RIGHT; } else if (s.equalsIgnoreCase("full")) { return ParserConstants.FULL; } else if (s.equalsIgnoreCase("inner")) { return ParserConstants.INNER; } else { throw new UnsupportedOperationException(); } } public Expression getCondition() { return (Expression) elementAt(3); } public void accept(openjava.ptree.util.ParseTreeVisitor v) throws ParseTreeException { v.visit(this); } // implement SetExpression public OJClass deriveRowType(Environment env) throws Exception { Expression[] expressions = flatten(this); OJClass[] classes = new OJClass[expressions.length]; for (int i = 0; i < expressions.length; i++) { classes[i] = expressions[i].getRowType(env); } String className = env.currentClassName(); OJClass clazz = OJClass.forName(className); return SyntheticClass.createJoin(clazz, classes); } }; // End JoinExpression.java
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 1474 | Julian Hyde |
saffron: Aggregations are working. Renamed 'aggregator' to 'aggregation'. |
||
#1 | 1467 | Julian Hyde |
saffron: First saffron check-in; incorporate my changes to openjava. |