OSDN Git Service

imported from subversion repository
[xerial/xerial-core.git] / src / main / java / org / xerial / lens / relation / query / QuerySet.java
1 /*--------------------------------------------------------------------------\r
2  *  Copyright 2009 Taro L. Saito\r
3  *\r
4  *  Licensed under the Apache License, Version 2.0 (the "License");\r
5  *  you may not use this file except in compliance with the License.\r
6  *  You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  *  Unless required by applicable law or agreed to in writing, software\r
11  *  distributed under the License is distributed on an "AS IS" BASIS,\r
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  *  See the License for the specific language governing permissions and\r
14  *  limitations under the License.\r
15  *--------------------------------------------------------------------------*/\r
16 //--------------------------------------\r
17 // Xerial Raquel Project\r
18 //\r
19 // QuerySet.java\r
20 // Since: 2009/03/15 14:13:50\r
21 //\r
22 // $URL: http://www.xerial.org/svn/project/XerialJ/trunk/xerial-core/src/main/java/org/xerial/lens/relation/query/QuerySet.java $\r
23 // $Author: leo $\r
24 //--------------------------------------\r
25 package org.xerial.lens.relation.query;\r
26 \r
27 import java.util.ArrayList;\r
28 import java.util.Collection;\r
29 import java.util.HashSet;\r
30 import java.util.List;\r
31 import java.util.Set;\r
32 \r
33 import org.xerial.lens.relation.schema.Schema;\r
34 import org.xerial.util.IndexedSet;\r
35 \r
36 /**\r
37  * Set of target queries for the stream amoeba join.\r
38  * \r
39  * @author leo\r
40  * \r
41  */\r
42 public class QuerySet {\r
43     private IndexedSet<Schema> queryTarget = new IndexedSet<Schema>();\r
44     private Set<String> treeNodeSet = new HashSet<String>();\r
45 \r
46     public QuerySet() {}\r
47 \r
48     private QuerySet(Collection<Schema> schemaSet) {\r
49         for (Schema eachSchema : schemaSet) {\r
50             queryTarget.add(eachSchema);\r
51         }\r
52     }\r
53 \r
54     public Set<Schema> getTargetQuerySet() {\r
55         return queryTarget;\r
56     }\r
57 \r
58     public boolean isTreeNode(String nodeName) {\r
59         return treeNodeSet.contains(nodeName);\r
60     }\r
61 \r
62     @Override\r
63     public String toString() {\r
64         return queryTarget.toString();\r
65     }\r
66 \r
67     public static class QuerySetBuilder {\r
68         List<Schema> schemaList = new ArrayList<Schema>();\r
69         Set<String> treeNodeSet = new HashSet<String>();\r
70 \r
71         public void addTreeNode(String treeNode) {\r
72             treeNodeSet.add(treeNode);\r
73         }\r
74 \r
75         public void addQueryTarget(Schema schema) {\r
76             schemaList.add(schema);\r
77         }\r
78 \r
79         public QuerySet build() {\r
80             return new QuerySet(schemaList);\r
81         }\r
82 \r
83     }\r
84 \r
85 }\r