+++ /dev/null
-/*--------------------------------------------------------------------------\r
- * Copyright 2009 Taro L. Saito\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *--------------------------------------------------------------------------*/\r
-//--------------------------------------\r
-// XerialJ\r
-//\r
-// RelationLens.java\r
-// Since: Aug 6, 2009 4:02:39 PM\r
-//\r
-// $URL$\r
-// $Author$\r
-//--------------------------------------\r
-package org.xerial.lens;\r
-\r
-import org.xerial.core.XerialException;\r
-import org.xerial.lens.relation.Node;\r
-import org.xerial.lens.relation.Tuple;\r
-import org.xerial.lens.relation.lang.RelationExpr;\r
-import org.xerial.lens.relation.query.QuerySet;\r
-import org.xerial.lens.relation.query.RelationExtractor;\r
-import org.xerial.lens.relation.query.RelationHandler;\r
-import org.xerial.lens.relation.schema.Schema;\r
-import org.xerial.util.log.Logger;\r
-import org.xerial.util.tree.TreeParser;\r
-\r
-/**\r
- * For extracting relation from tree-structured data\r
- * \r
- * @author leo\r
- * \r
- */\r
-public class RelationLens {\r
-\r
- private static Logger _logger = Logger.getLogger(RelationLens.class);\r
-\r
- private final QuerySet qs;\r
-\r
- public RelationLens(String lensQuery) throws XerialException {\r
- RelationExpr re = RelationExpr.parse(lensQuery);\r
- qs = re.buildQuerySet();\r
- }\r
-\r
- public void map(TreeParser input) throws XerialException {\r
-\r
- RelationHandler rh = new MyRelationHandler();\r
- RelationExtractor.run(qs, input, rh);\r
- }\r
-\r
- public class MyRelationHandler implements RelationHandler {\r
-\r
- public void relation(Schema s, Tuple<Node> relation) {\r
- _logger.info(String.format("%s: %s", s, relation));\r
- }\r
-\r
- }\r
-\r
-}\r