KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > medor > query > lib > Union


1 /**
2  * MEDOR: Middleware Enabling Distributed Object Requests
3  *
4  * Copyright (C) 2001-2004 France Telecom R&D
5  * Contact: alexandre.lefebvre@rd.francetelecom.com
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * Initial developers: M. Alia, A. Lefebvre
22  */

23
24 /**
25  * Package definition.
26  */

27 package org.objectweb.medor.query.lib;
28
29 import org.objectweb.medor.api.MedorException;
30 import org.objectweb.medor.expression.api.Expression;
31 import org.objectweb.medor.query.api.OperationType;
32 import org.objectweb.medor.query.api.QueryTree;
33 import org.objectweb.medor.query.api.QueryTreeField;
34
35 public class Union extends BasicQueryNode {
36
37     public Union() {
38     }
39
40     public Union(QueryTree leftQT,
41                  QueryTree rightQT,
42                  String JavaDoc nodeName)
43             throws MedorException {
44         super(nodeName);
45
46         //test if the two QueryTree have the same TupleStructure
47
if (leftQT.getTupleStructure().getSize()
48                 != rightQT.getTupleStructure().getSize()) {
49             throw new MedorException(
50                     "Impossible to perform Union Operation");
51         }
52         for (int i = 1; i < leftQT.getTupleStructure().getSize(); i++) {
53             if (!leftQT.getTupleStructure().getField(i).getName()
54                     .equalsIgnoreCase(
55                             rightQT.getTupleStructure().getField(i).getName())) {
56                 throw new MedorException(
57                         "Impossible to perform Union Operation");
58             }
59         }
60         //add all Fields of the underlying QueryTrees
61
for (int i = 1; i < leftQT.getTupleStructure().getSize(); i++) {
62             QueryTreeField[] anc = new QueryTreeField[2];
63 //TODO construct the TupleStructure for the Union
64
}
65     }
66
67     public short getType() {
68         return OperationType.UNION;
69     }
70
71     public void setQueryFilter(Expression e) {
72         throw new UnsupportedOperationException JavaDoc("Unions cannot be assigned a filter.");
73     }
74
75 }
76
Popular Tags