Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17903/src/org/tmapiutils/query/tolog/parser Modified Files: Clause.java ClauseList.java NEClause.java NotClause.java OrClause.java Placeholder.java PlayerRolePair.java PlayerRoleVarPair.java Predicate.java Projection.java ProjectionImpl.java Sorting.java TologQuery.java TologResultsSetImpl.java TologRule.java TologRuleImpl.java TologRuleInstance.java TologRuleInstanceImpl.java Variable.java tolog.g Log Message: Shift to Apache License 2.0 More TMAPI compatible, some classes already compile. ;) Deleted CVS log from files Index: PlayerRolePair.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/PlayerRolePair.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PlayerRolePair.java 6 Mar 2005 17:29:06 -0000 1.1 --- PlayerRolePair.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.parser; *************** *** 15,25 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class PlayerRolePair { protected Topic m_pTopic; protected Topic m_rTopic; ! protected PlayerRolePair() { } --- 22,33 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class PlayerRolePair { protected Topic m_pTopic; protected Topic m_rTopic; ! protected PlayerRolePair() { } *************** *** 28,35 **** m_rTopic = roleTopic; } ! public Topic getPlayerTopic() { return m_pTopic; } public Topic getRoleTopic() { return m_rTopic; } ! public String toString() { return ReferenceUtils.getTologReference(m_pTopic) + ":" + ReferenceUtils.getTologReference(m_rTopic); --- 36,43 ---- m_rTopic = roleTopic; } ! public Topic getPlayerTopic() { return m_pTopic; } public Topic getRoleTopic() { return m_rTopic; } ! public String toString() { return ReferenceUtils.getTologReference(m_pTopic) + ":" + ReferenceUtils.getTologReference(m_rTopic); *************** *** 37,57 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:29:06 lheuer - * Initial tolog import - * - * Revision 1.3 2004/06/07 20:31:15 kal_ahmed - * Completed work on projection and sorting. Performed a bit more code reorganisation. Added DirectInstanceOfPredicate. - * - * Revision 1.2 2004/06/03 19:55:16 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/06/03 19:47:22 kal_ahmed - * Separated parser and parsed query representation classes into a sub-package. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 45,46 ---- Index: tolog.g =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/tolog.g,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tolog.g 6 Mar 2005 17:29:07 -0000 1.1 --- tolog.g 8 Mar 2005 12:33:55 -0000 1.2 *************** *** 1,21 **** ! header { package org.tm4j.tologx.parser; } { /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ - import org.tm4j.net.Locator; - import org.tm4j.net.LocatorFactoryException; - import org.tm4j.net.LocatorResolutionException; - import org.tm4j.topicmap.Topic; - import org.tm4j.topicmap.TopicMap; - import org.tm4j.topicmap.TopicMapObject; import java.io.File; import java.io.FileInputStream; --- 1,22 ---- ! header { package org.tmapiutils.query.tolog.parser; } { /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ import java.io.File; import java.io.FileInputStream; *************** *** 32,43 **** import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; ! import org.tm4j.tologx.TologParserException; ! import org.tm4j.tologx.predicates.DynamicAssociationPredicate; } /** * INTERNAL: Parser for the tolog syntax. */ - class TologParser extends Parser; --- 33,56 ---- import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; ! org.tmapiutils.query.tolog.TologParserException; ! org.tmapiutils.query.tolog.predicates.DynamicAssociationPredicate; ! ! import org.tmapiutils.utils.IndexUtils; ! // TMAPI ! import org.tmapi.core.TopicMapObject; ! import org.tmapi.core.Locator; ! import org.tmapi.core.Topic; ! import org.tmapi.core.TopicMap; ! import org.tmapi.core.TMAPIException; ! import org.tmapi.index.core.TopicMapObjectsIndex; ! import org.tmapi.index.core.TopicsIndex; } /** * INTERNAL: Parser for the tolog syntax. + * + * @author Kal Ahmed (kal[at]techquila.com) + * @author Lars Heuer (heuer[at]semagia.com) */ class TologParser extends Parser; *************** *** 48,51 **** --- 61,66 ---- { + private TopicMapObjectsIndex _tmoIdx; + private TopicsIndex _topicIdx; private static final Log m_log = LogFactory.getLog(TologParser.class); private Stack m_clauseStack = new Stack(); *************** *** 75,83 **** private String m_identifier = null; private Class m_dynAssocPredicate = DynamicAssociationPredicate.class; ! public void setTopicMap(TopicMap topicmap) { m_tm = topicmap; } ! private Object getObjectByIdent(String ident) throws TologParserException { try { --- 90,98 ---- private String m_identifier = null; private Class m_dynAssocPredicate = DynamicAssociationPredicate.class; ! public void setTopicMap(TopicMap topicmap) { m_tm = topicmap; } ! private Object getObjectByIdent(String ident) throws TologParserException { try { *************** *** 85,90 **** if (ident.startsWith("i\"")) { String si = ident.substring(2, ident.length() - 1); ! Locator l = m_tm.getBaseLocator().resolveRelative(si); ! tmo = m_tm.getTopicBySubjectIndicator(l); if (tmo == null) { throw new TologParserException("No topic found in topic map with subject indicator: " + si); --- 100,110 ---- if (ident.startsWith("i\"")) { String si = ident.substring(2, ident.length() - 1); ! Locator loc = m_tm.getBaseLocator().resolveRelative(si); ! _topicIdx.open(); ! if (!_topicIdx.getFlags().isAutoUpdated()) { ! _topicIdx.reindex(); ! } ! tmo = _topicIdx.getTopicBySubjectIdentifier(loc); ! // tmo = m_tm.getTopicBySubjectIndicator(l); if (tmo == null) { throw new TologParserException("No topic found in topic map with subject indicator: " + si); *************** *** 92,110 **** } else if (ident.startsWith("a\"")) { String sa = ident.substring(2, ident.length() - 1); ! Locator l = m_tm.getBaseLocator().resolveRelative(sa); ! tmo = m_tm.getTopicBySubject(l); if (tmo == null) { throw new TologParserException("No topic found in topic map with subject address: " + sa); ! } } else if (ident.startsWith("s\"")) { String src = ident.substring(2, ident.length() - 1); ! Locator l = m_tm.getBaseLocator().resolveRelative(src); ! tmo = m_tm.getObjectBySourceLocator(l); if (tmo == null) { throw new TologParserException("No topic found in topic map with source locator address: " + src); ! } } else if (ident.startsWith("@")) { String id = ident.substring(1); ! tmo = m_tm.getObjectByID(id); if (tmo == null) { throw new TologParserException("No object found in topic map with id: " + id); --- 112,140 ---- } else if (ident.startsWith("a\"")) { String sa = ident.substring(2, ident.length() - 1); ! Locator loc = m_tm.getBaseLocator().resolveRelative(sa); ! _topicIdx.open(); ! if (!_topicIdx.getFlags().isAutoUpdated()) { ! _topicIdx.reindex(); ! } ! tmo = _topicIdx.getTopicBySubjectLocator(loc); ! // tmo = m_tm.getTopicBySubject(l); if (tmo == null) { throw new TologParserException("No topic found in topic map with subject address: " + sa); ! } } else if (ident.startsWith("s\"")) { String src = ident.substring(2, ident.length() - 1); ! Locator loc = m_tm.getBaseLocator().resolveRelative(src); ! _tmoIdx.open(); ! if (!_tmoIdx.getFlags().isAutoUpdated()) { ! _tmoIdx.reindex(); ! } ! tmo = _tmoIdx.getTopicMapObjectBySourceLocator(loc); ! // tmo = m_tm.getObjectBySourceLocator(l); if (tmo == null) { throw new TologParserException("No topic found in topic map with source locator address: " + src); ! } } else if (ident.startsWith("@")) { String id = ident.substring(1); ! tmo = m_tm.getObjectById(id); if (tmo == null) { throw new TologParserException("No object found in topic map with id: " + id); *************** *** 114,121 **** tmo = new Placeholder(ref); } else { ! Locator l = m_tm.getBaseLocator().resolveRelative("#" + ident); ! tmo = m_tm.getObjectBySourceLocator(l); if (tmo == null) { ! throw new TologParserException("No object in topic map with source locator " + l.getAddress()); } } --- 144,156 ---- tmo = new Placeholder(ref); } else { ! Locator loc = m_tm.getBaseLocator().resolveRelative("#" + ident); ! _tmoIdx.open(); ! if (!_tmoIdx.getFlags().isAutoUpdated()) { ! _tmoIdx.reindex(); ! } ! tmo = _tmoIdx.getTopicMapObjectBySourceLocator(loc); ! //tmo = m_tm.getObjectBySourceLocator(l); if (tmo == null) { ! throw new TologParserException("No object in topic map with source locator " + loc.getReference()); } } *************** *** 123,146 **** } catch (LocatorResolutionException ex) { throw new TologParserException("Invalid topic identifier " + ident + ". The identifier cannot be resolved to a URI fragment identifier."); } } ! public void setBaseLocator(Locator baseLoc) { m_baseLoc = baseLoc; } ! public void setPrefix(String prefix) { m_prefix = prefix; } ! public Map getRules() { return m_rulesByName; } ! public void setRules(Map m) { m_rulesByName.clear(); m_rulesByName.putAll(m); } ! public void setPrefixRules(Map m) { Iterator keys = m.keySet().iterator(); --- 158,183 ---- } catch (LocatorResolutionException ex) { throw new TologParserException("Invalid topic identifier " + ident + ". The identifier cannot be resolved to a URI fragment identifier."); + } catch (TMAPIException ex) { + throw new TologParserException("Initializing of index failed", ex); } } ! public void setBaseLocator(Locator baseLoc) { m_baseLoc = baseLoc; } ! public void setPrefix(String prefix) { m_prefix = prefix; } ! public Map getRules() { return m_rulesByName; } ! public void setRules(Map m) { m_rulesByName.clear(); m_rulesByName.putAll(m); } ! public void setPrefixRules(Map m) { Iterator keys = m.keySet().iterator(); *************** *** 156,169 **** } } ! public void setPredicates(Map m) { m_predicatesByID.clear(); m_predicatesByID.putAll(m); } ! public void setDynamicAssociationPredicateClass(Class c) { ! m_dynAssocPredicate = c; } ! private void importModule(String modSrc, String modPrefix) throws TologParserException { // Hack to remove enclosing quotes from URL production. --- 193,206 ---- } } ! public void setPredicates(Map m) { m_predicatesByID.clear(); m_predicatesByID.putAll(m); } ! public void setDynamicAssociationPredicateClass(Class c) { ! m_dynAssocPredicate = c; } ! private void importModule(String modSrc, String modPrefix) throws TologParserException { // Hack to remove enclosing quotes from URL production. *************** *** 177,203 **** if (m_baseLoc == null) { if (m_tm.getBaseLocator() != null) { ! m_log.debug("Resolving name against topic map base locator: " + m_tm.getBaseLocator().getAddress()); moduleLoc = m_tm.getBaseLocator().resolveRelative(modSrc); } else { ! moduleLoc = m_tm.getLocatorFactory().createLocator("URI", modSrc); } } else { ! m_log.debug("Resolving name against module base locator: " + m_baseLoc.getAddress()); moduleLoc = m_baseLoc.resolveRelative(modSrc); } ! m_log.debug("Resolved module locator: "+ moduleLoc.getAddress()); InputStream is = null; try { m_log.debug("Trying address as URL..."); ! URL u = new URL(moduleLoc.getAddress()); is = u.openStream(); } catch (MalformedURLException ex) { m_log.debug("Trying address as file name..."); ! File f = new File(moduleLoc.getAddress()); m_log.debug("Got new file: "+ f.getAbsolutePath()); if (f.exists()) { is = new FileInputStream(f); } else { ! throw new TologParserException("Unable to process module reference " + moduleLoc.getAddress() + " as either a URL or a file name."); } } --- 214,240 ---- if (m_baseLoc == null) { if (m_tm.getBaseLocator() != null) { ! m_log.debug("Resolving name against topic map base locator: " + m_tm.getBaseLocator().getReference()); moduleLoc = m_tm.getBaseLocator().resolveRelative(modSrc); } else { ! moduleLoc = m_tm.createLocator(modSrc); } } else { ! m_log.debug("Resolving name against module base locator: " + m_baseLoc.getReference()); moduleLoc = m_baseLoc.resolveRelative(modSrc); } ! m_log.debug("Resolved module locator: "+ moduleLoc.getReference()); InputStream is = null; try { m_log.debug("Trying address as URL..."); ! URL u = new URL(moduleLoc.getReference()); is = u.openStream(); } catch (MalformedURLException ex) { m_log.debug("Trying address as file name..."); ! File f = new File(moduleLoc.getReference()); m_log.debug("Got new file: "+ f.getAbsolutePath()); if (f.exists()) { is = new FileInputStream(f); } else { ! throw new TologParserException("Unable to process module reference " + moduleLoc.getReference() + " as either a URL or a file name."); } } *************** *** 208,212 **** p.module(); Map moduleRules = p.getRules(); ! if (m_log.isDebugEnabled()) m_log.debug("Parse of module " + moduleLoc.getAddress() + " completed. Parser reports " + moduleRules.size() + " rules."); Iterator it = moduleRules.keySet().iterator(); while (it.hasNext()) { --- 245,249 ---- p.module(); Map moduleRules = p.getRules(); ! if (m_log.isDebugEnabled()) m_log.debug("Parse of module " + moduleLoc.getReference() + " completed. Parser reports " + moduleRules.size() + " rules."); Iterator it = moduleRules.keySet().iterator(); while (it.hasNext()) { *************** *** 229,233 **** } } ! private void addRule(String name, TologRule rule) { m_predicatesByID.put(name, TologRule.class); --- 266,270 ---- } } ! private void addRule(String name, TologRule rule) { m_predicatesByID.put(name, TologRule.class); *************** *** 240,250 **** (r:rule)* ; ! directive throws TologParserException : import_module ! | prefixmap ; ! import_module throws TologParserException : "import" mod_src:URL "as" mod_prefix:NAME --- 277,287 ---- (r:rule)* ; ! directive throws TologParserException : import_module ! | prefixmap ; ! import_module throws TologParserException : "import" mod_src:URL "as" mod_prefix:NAME *************** *** 253,272 **** prefixmap throws TologParserException : ! "using" prefix:NAME "for" ! (INDURL { m_prefixMap.put(prefix, LT(0).getText()); }| ADDURL { m_prefixMap.put(prefix, LT(0).getText()); }| SRCURL { m_prefixMap.put(prefix, LT(0).getText()); }| OBJID { m_prefixMap.put(prefix, LT(0).getText()); }) ; ! rule returns [TologRule r] throws TologParserException {r = null;}: {m_rule = new TologRuleImpl(); } ! (rulehead) ! IMPLIES clauselist {m_rule.setRuleBody(m_currClauseList); } FULLSTOP ! { ! if (m_rules == null) m_rules = new ArrayList(); ! m_rules.add(m_rule); r = m_rule; } --- 290,309 ---- prefixmap throws TologParserException : ! "using" prefix:NAME "for" ! (INDURL { m_prefixMap.put(prefix, LT(0).getText()); }| ADDURL { m_prefixMap.put(prefix, LT(0).getText()); }| SRCURL { m_prefixMap.put(prefix, LT(0).getText()); }| OBJID { m_prefixMap.put(prefix, LT(0).getText()); }) ; ! rule returns [TologRule r] throws TologParserException {r = null;}: {m_rule = new TologRuleImpl(); } ! (rulehead) ! IMPLIES clauselist {m_rule.setRuleBody(m_currClauseList); } FULLSTOP ! { ! if (m_rules == null) m_rules = new ArrayList(); ! m_rules.add(m_rule); r = m_rule; } *************** *** 275,284 **** rulehead : name:NAME { ! m_rule.setName(name.getText()); addRule(name.getText(), m_rule); } ! LPAREN variable { m_rule.addHeadParameter(new Variable(m_varName)); } ! (COMMA variable { m_rule.addHeadParameter(new Variable(m_varName)); })* RPAREN ; --- 312,321 ---- rulehead : name:NAME { ! m_rule.setName(name.getText()); addRule(name.getText(), m_rule); } ! LPAREN variable { m_rule.addHeadParameter(new Variable(m_varName)); } ! (COMMA variable { m_rule.addHeadParameter(new Variable(m_varName)); })* RPAREN ; *************** *** 295,299 **** QM { ! q = new TologQuery(m_currClauseList); if (m_proj != null) q.setProjection(m_proj); if (m_sorting != null) q.setSorting(m_sorting); --- 332,336 ---- QM { ! q = new TologQuery(m_currClauseList); if (m_proj != null) q.setProjection(m_proj); if (m_sorting != null) q.setSorting(m_sorting); *************** *** 302,306 **** } ; ! selectpart : "select" --- 339,343 ---- } ; ! selectpart : "select" *************** *** 316,321 **** orderpart { m_sorting = new Sorting(); }: ! "order" "by" ! (variable { m_sorting.addSort(new Variable(m_varName));})+ ( ("asc" { m_sorting.setSortAscending(true);} ) | --- 353,358 ---- orderpart { m_sorting = new Sorting(); }: ! "order" "by" ! (variable { m_sorting.addSort(new Variable(m_varName));})+ ( ("asc" { m_sorting.setSortAscending(true);} ) | *************** *** 329,333 **** ; ! count : "count" LPAREN variable RPAREN ; --- 366,370 ---- ; ! count : "count" LPAREN variable RPAREN ; *************** *** 357,361 **** throw new TologParserException("Unable to create a new dynamic association predicate from class " + m_dynAssocPredicate.getName() + ".", ex); } ! } | prefixedident { --- 394,398 ---- throw new TologParserException("Unable to create a new dynamic association predicate from class " + m_dynAssocPredicate.getName() + ".", ex); } ! } | prefixedident { *************** *** 388,403 **** } ) ! LPAREN (pair { m_predicateParams.add(m_param); } | URL { m_predicateParams.add(LT(0).getText()); }) (COMMA (pair { m_predicateParams.add(m_param); }) | URL { m_predicateParams.add(LT(0).getText());})* RPAREN ! { ! m_predicate.setParameters(m_predicateParams); ! m_currClauseList.addPredicate(m_predicate); } ; pair throws TologParserException: ! { if (m_dynAssocPredicate.isInstance(m_predicate)) { m_param = m_prp = new PlayerRoleVarPair(); --- 425,440 ---- } ) ! LPAREN (pair { m_predicateParams.add(m_param); } | URL { m_predicateParams.add(LT(0).getText()); }) (COMMA (pair { m_predicateParams.add(m_param); }) | URL { m_predicateParams.add(LT(0).getText());})* RPAREN ! { ! m_predicate.setParameters(m_predicateParams); ! m_currClauseList.addPredicate(m_predicate); } ; pair throws TologParserException: ! { if (m_dynAssocPredicate.isInstance(m_predicate)) { m_param = m_prp = new PlayerRoleVarPair(); *************** *** 407,412 **** m_log.debug("START: pair"); } ! ! expr { if (m_refObject != null) { --- 444,449 ---- m_log.debug("START: pair"); } ! ! expr { if (m_refObject != null) { *************** *** 430,439 **** } } ! (COLON expr ! { if (m_prp != null) { if (m_refObject != null) { if (m_refObject instanceof Topic) { ! m_prp.setRoleTopic((Topic)m_refObject); } else if (m_refObject instanceof Placeholder) { m_prp.setRolePlaceholder((Placeholder)m_refObject); --- 467,476 ---- } } ! (COLON expr ! { if (m_prp != null) { if (m_refObject != null) { if (m_refObject instanceof Topic) { ! m_prp.setRoleTopic((Topic)m_refObject); } else if (m_refObject instanceof Placeholder) { m_prp.setRolePlaceholder((Placeholder)m_refObject); *************** *** 451,455 **** {m_log.debug("END: pair");} ; ! orclause throws TologParserException: { m_clauseStack.push(m_currClauseList); m_oc = new OrClause(); } --- 488,492 ---- {m_log.debug("END: pair");} ; ! orclause throws TologParserException: { m_clauseStack.push(m_currClauseList); m_oc = new OrClause(); } *************** *** 459,486 **** RCURLY { ! m_currClauseList = (ClauseList) m_clauseStack.pop(); m_currClauseList.addClause(m_oc); } ; ! notclause throws TologParserException: ! "not" LPAREN { m_clauseStack.push(m_currClauseList); m_nc = new NotClause(); } clauselist RPAREN { ! m_nc.setTest(m_currClauseList); ! m_currClauseList = (ClauseList)m_clauseStack.pop(); m_currClauseList.addClause(m_nc); } ; ! opclause throws TologParserException : { m_nec = new NEClause(); } (expr { m_nec.setLeft(m_refObject); m_nec.setLeftVar(m_varName); } ! "/=" expr { m_nec.setRight(m_refObject); m_nec.setRightVar(m_varName); }) { m_currClauseList.addClause(m_nec); } ; ! expr throws TologParserException : { m_varName = null; m_refObject = null; } --- 496,523 ---- RCURLY { ! m_currClauseList = (ClauseList) m_clauseStack.pop(); m_currClauseList.addClause(m_oc); } ; ! notclause throws TologParserException: ! "not" LPAREN { m_clauseStack.push(m_currClauseList); m_nc = new NotClause(); } clauselist RPAREN { ! m_nc.setTest(m_currClauseList); ! m_currClauseList = (ClauseList)m_clauseStack.pop(); m_currClauseList.addClause(m_nc); } ; ! opclause throws TologParserException : { m_nec = new NEClause(); } (expr { m_nec.setLeft(m_refObject); m_nec.setLeftVar(m_varName); } ! "/=" expr { m_nec.setRight(m_refObject); m_nec.setRightVar(m_varName); }) { m_currClauseList.addClause(m_nec); } ; ! expr throws TologParserException : { m_varName = null; m_refObject = null; } *************** *** 488,505 **** { m_log.debug("After expr: " + String.valueOf(m_varName) + "/" + String.valueOf(m_refObject)); } ; ! ! variable : {m_varName = null; } (DOLLAR NAME { m_varName = LT(0).getText(); }) ; ! ref throws TologParserException: { m_refObject = null; } prefixedident { m_refObject = getObjectByIdent(m_identifier); } ; ! prefixedident : ! (NAME DBLCOLON) => prefix:NAME DBLCOLON ref:NAME ! { m_log.debug("Got identifier '" + ref.getText() + "' with prefix '" + prefix.getText() + "'."); String exp = (String) m_prefixMap.get(prefix.getText()); --- 525,542 ---- { m_log.debug("After expr: " + String.valueOf(m_varName) + "/" + String.valueOf(m_refObject)); } ; ! ! variable : {m_varName = null; } (DOLLAR NAME { m_varName = LT(0).getText(); }) ; ! ref throws TologParserException: { m_refObject = null; } prefixedident { m_refObject = getObjectByIdent(m_identifier); } ; ! prefixedident : ! (NAME DBLCOLON) => prefix:NAME DBLCOLON ref:NAME ! { m_log.debug("Got identifier '" + ref.getText() + "' with prefix '" + prefix.getText() + "'."); String exp = (String) m_prefixMap.get(prefix.getText()); *************** *** 542,547 **** name:NAME { m_identifier = name.getText(); } ; ! ! /* predname throws TologParserException : ident { --- 579,584 ---- name:NAME { m_identifier = name.getText(); } ; ! ! /* predname throws TologParserException : ident { *************** *** 571,583 **** INDURL ; ! address: ADDURL ; ! srcloc: SRCURL ; ! /** * INTERNAL: Lexer for tolog syntax. --- 608,620 ---- INDURL ; ! address: ADDURL ; ! srcloc: SRCURL ; ! /** * INTERNAL: Lexer for tolog syntax. *************** *** 586,591 **** class TologLexer extends Lexer; ! options { ! charVocabulary = '\1'..'\uFFFF'; k = 2; } --- 623,628 ---- class TologLexer extends Lexer; ! options { ! charVocabulary = '\1'..'\uFFFF'; k = 2; } *************** *** 596,601 **** ; ! NAME : ! ('A'..'Z' | 'a'..'z' | '_') ('A'..'Z' | 'a'..'z' | '0'..'9' | '_' | '.' | '-')* ; --- 633,638 ---- ; ! NAME : ! ('A'..'Z' | 'a'..'z' | '_') ('A'..'Z' | 'a'..'z' | '0'..'9' | '_' | '.' | '-')* ; *************** *** 604,616 **** '"' (~('"' | '\n') | '\n' { newline(); } )* '"' ; ! INDURL : 'i' URL ; ! ADDURL : 'a' URL ; ! SRCURL : 's' URL --- 641,653 ---- '"' (~('"' | '\n') | '\n' { newline(); } )* '"' ; ! INDURL : 'i' URL ; ! ADDURL : 'a' URL ; ! SRCURL : 's' URL *************** *** 624,628 **** '%' INT ; ! NE : "/="; --- 661,665 ---- '%' INT ; ! NE : "/="; Index: TologQuery.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/TologQuery.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TologQuery.java 6 Mar 2005 17:29:06 -0000 1.1 --- TologQuery.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.parser; *************** *** 21,29 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class TologQuery { ! private ClauseList m_rootClauseList; private Projection m_projection; --- 28,37 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class TologQuery { ! private ClauseList m_rootClauseList; private Projection m_projection; *************** *** 32,44 **** private int m_pageLength; private static final Log m_log = LogFactory.getLog(TologQuery.class); ! public TologQuery(ClauseList rootClauseList) { m_rootClauseList = rootClauseList; } ! public ClauseList getRootClauseList() { return m_rootClauseList; } ! /** * @return --- 40,52 ---- private int m_pageLength; private static final Log m_log = LogFactory.getLog(TologQuery.class); ! public TologQuery(ClauseList rootClauseList) { m_rootClauseList = rootClauseList; } ! public ClauseList getRootClauseList() { return m_rootClauseList; } ! /** * @return *************** *** 116,120 **** return new TologResultsSetImpl(m_projection.getColumns(), sortedRows.subList(m_pageStart, pageLength)); } ! public String toString() { StringBuffer sb = new StringBuffer(); --- 124,128 ---- return new TologResultsSetImpl(m_projection.getColumns(), sortedRows.subList(m_pageStart, pageLength)); } ! public String toString() { StringBuffer sb = new StringBuffer(); *************** *** 167,205 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:29:06 lheuer - * Initial tolog import - * - * Revision 1.9 2004/07/19 15:59:51 kal_ahmed - * Query processing now initialises the input variable set correctly. - * - * Revision 1.8 2004/07/19 14:52:40 kal_ahmed - * More fixes to processing of recursive rules. ClauseList now aborts when the input parameter list becomes empty. - * - * Revision 1.7 2004/06/20 14:12:30 kal_ahmed - * Copied TologRsultsSet interface and TologFragmentBuilder implementation from org.tm4j.tolog to this package. - * - * Revision 1.6 2004/06/16 21:21:43 kal_ahmed - * Tolog queries may now contain replaceable references specified in an Object array parameter to the QueryEvaluator at evaluation time. - * - * Revision 1.5 2004/06/13 19:44:30 kal_ahmed - * Added a fix and test for handling recursive rules definitions. - * - * Revision 1.4 2004/06/09 20:20:30 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.3 2004/06/07 20:31:33 kal_ahmed - * Completed work on projection and sorting. Performed a bit more code reorganisation. Added DirectInstanceOfPredicate. - * - * Revision 1.2 2004/06/03 19:55:16 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/06/03 19:47:22 kal_ahmed - * Separated parser and parsed query representation classes into a sub-package. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 175,176 ---- Index: Variable.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/Variable.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Variable.java 6 Mar 2005 17:29:07 -0000 1.1 --- Variable.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,17 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.parser; /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class Variable { --- 1,25 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.parser; /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class Variable { *************** *** 22,30 **** } public String getName() { return m_name; } ! public String toString() { return "$" + m_name; } ! public boolean equals(Object o) { if (o instanceof Variable) { --- 30,38 ---- } public String getName() { return m_name; } ! public String toString() { return "$" + m_name; } ! public boolean equals(Object o) { if (o instanceof Variable) { *************** *** 33,37 **** return false; } ! public int hashCode() { return m_name.hashCode(); --- 41,45 ---- return false; } ! public int hashCode() { return m_name.hashCode(); *************** *** 39,56 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:29:07 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/03 19:55:16 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/06/03 19:47:22 kal_ahmed - * Separated parser and parsed query representation classes into a sub-package. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 47,48 ---- Index: Projection.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/Projection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Projection.java 6 Mar 2005 17:29:06 -0000 1.1 --- Projection.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.parser; *************** *** 15,21 **** /** ! * @author Kal ! * ! * Describe Projection here. */ public interface Projection { --- 23,29 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public interface Projection { *************** *** 25,29 **** /** * Returns the columns in the projection as a list of either Variable or Count ! * instances. * @return a list of column descriptors */ --- 33,37 ---- /** * Returns the columns in the projection as a list of either Variable or Count ! * instances. * @return a list of column descriptors */ *************** *** 36,46 **** } - /* - * $Log$ - * Revision 1.1 2005/03/06 17:29:06 lheuer - * Initial tolog import - * - * Revision 1.6 2004/06/09 21:12:19 kal_ahmed - * Added standard source file header and footer. - * - */ \ No newline at end of file --- 44,45 ---- Index: Sorting.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/Sorting.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Sorting.java 6 Mar 2005 17:29:06 -0000 1.1 --- Sorting.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.parser; *************** *** 26,30 **** * of the sort columns and the sort direction and provides a method for * sorting a projection. ! * @author Kal Ahmed (ka...@te...) */ public class Sorting { --- 33,39 ---- * of the sort columns and the sort direction and provides a method for * sorting a projection. ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class Sorting { *************** *** 34,49 **** private RowComparator m_rowComparator = null; private Comparator m_invRowComparator; ! public void addSort(Variable sortVar) { m_sortCols.add(sortVar); } ! public void setSortAscending(boolean sortAscending) { m_sortAscending = sortAscending; } ! /** * Sorts a list of results rows by this class's sorting criteria. The sort ! * is executed as an in-place sort of <code>rows</code>, so the * List returned by this method is in fact the same List object passed * in in the <code>rows</code> parameter. --- 43,58 ---- private RowComparator m_rowComparator = null; private Comparator m_invRowComparator; ! public void addSort(Variable sortVar) { m_sortCols.add(sortVar); } ! public void setSortAscending(boolean sortAscending) { m_sortAscending = sortAscending; } ! /** * Sorts a list of results rows by this class's sorting criteria. The sort ! * is executed as an in-place sort of <code>rows</code>, so the * List returned by this method is in fact the same List object passed * in in the <code>rows</code> parameter. *************** *** 73,77 **** return rows; } ! public String toString() { if (m_sortCols.isEmpty()) { --- 82,86 ---- return rows; } ! public String toString() { if (m_sortCols.isEmpty()) { *************** *** 84,88 **** sb.append(it.next().toString()); if (it.hasNext()) { ! sb.append(","); } sb.append(" "); --- 93,97 ---- sb.append(it.next().toString()); if (it.hasNext()) { ! sb.append(","); } sb.append(" "); *************** *** 97,120 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:29:06 lheuer - * Initial tolog import - * - * Revision 1.4 2004/06/07 20:31:33 kal_ahmed - * Completed work on projection and sorting. Performed a bit more code reorganisation. Added DirectInstanceOfPredicate. - * - * Revision 1.3 2004/06/03 20:04:56 kal_ahmed - * Completed initial package restructuring. - * - * Revision 1.2 2004/06/03 19:55:16 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/06/03 19:47:22 kal_ahmed - * Separated parser and parsed query representation classes into a sub-package. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 106,107 ---- Index: TologRuleImpl.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/TologRuleImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TologRuleImpl.java 6 Mar 2005 17:29:07 -0000 1.1 --- TologRuleImpl.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.parser; *************** *** 15,21 **** /** ! * @author Kal ! * ! * Describe DefaultRuleImpl here. */ public class TologRuleImpl implements TologRule { --- 23,29 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class TologRuleImpl implements TologRule { *************** *** 26,34 **** private String m_name; ! public TologRuleImpl() { m_headParams = new ArrayList(); } ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.Rule#getName() --- 34,42 ---- private String m_name; ! public TologRuleImpl() { m_headParams = new ArrayList(); } ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.Rule#getName() *************** *** 55,63 **** m_body = body; } ! public ClauseList getRuleBody() { return m_body; } ! public List getHeadParameters() { return m_headParams; --- 63,71 ---- m_body = body; } ! public ClauseList getRuleBody() { return m_body; } ! public List getHeadParameters() { return m_headParams; *************** *** 70,74 **** return new TologRuleInstanceImpl(this); } ! public String toString() { StringBuffer ret = new StringBuffer(); --- 78,82 ---- return new TologRuleInstanceImpl(this); } ! public String toString() { StringBuffer ret = new StringBuffer(); *************** *** 88,98 **** } } ! /* ! * $Log$ ! * Revision 1.1 2005/03/06 17:29:07 lheuer ! * Initial tolog import ! * ! * Revision 1.3 2004/06/09 21:12:19 kal_ahmed ! * Added standard source file header and footer. ! * ! */ \ No newline at end of file --- 96,98 ---- } } ! Index: TologRuleInstance.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/TologRuleInstance.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TologRuleInstance.java 6 Mar 2005 17:29:07 -0000 1.1 --- TologRuleInstance.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,18 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.parser; /** ! * @author Kal ! * ! * Describe RuleInstance here. */ public interface TologRuleInstance extends Predicate { --- 1,26 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.parser; /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public interface TologRuleInstance extends Predicate { *************** *** 20,30 **** } ! /* ! * $Log$ ! * Revision 1.1 2005/03/06 17:29:07 lheuer ! * Initial tolog import ! * ! * Revision 1.3 2004/06/09 21:12:19 kal_ahmed ! * Added standard source file header and footer. ! * ! */ \ No newline at end of file --- 28,30 ---- } ! Index: ProjectionImpl.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/ProjectionImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ProjectionImpl.java 6 Mar 2005 21:11:32 -0000 1.2 --- ProjectionImpl.java 8 Mar 2005 12:33:40 -0000 1.3 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.parser; *************** *** 21,26 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class ProjectionImpl implements Projection { --- 28,34 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class ProjectionImpl implements Projection { *************** *** 29,46 **** private static final Log m_log = LogFactory.getLog(ProjectionImpl.class); ! public ProjectionImpl () { m_columns = new ArrayList(); m_rows = new ArrayList(); } ! public void addVariable(Variable var) { m_columns.add(var); } ! public void addCount(Variable var) { m_columns.add(new Count(var)); } ! public void addVariableSet(VariableSet varSet) { if (m_columns.isEmpty()) { --- 37,54 ---- private static final Log m_log = LogFactory.getLog(ProjectionImpl.class); ! public ProjectionImpl () { m_columns = new ArrayList(); m_rows = new ArrayList(); } ! public void addVariable(Variable var) { m_columns.add(var); } ! public void addCount(Variable var) { m_columns.add(new Count(var)); } ! public void addVariableSet(VariableSet varSet) { if (m_columns.isEmpty()) { *************** *** 75,79 **** } } ! if (m_log.isDebugEnabled()) debugRow("Adding new row: ", newRow); boolean hasMatch = false; --- 83,87 ---- } } ! if (m_log.isDebugEnabled()) debugRow("Adding new row: ", newRow); boolean hasMatch = false; *************** *** 93,105 **** } } ! } } if (!hasMatch) { m_log.debug("Adding new row to projection."); m_rows.add(newRow); ! } } } ! private boolean compareRows(List r1, List r2) { for (int col = 0; col < r1.size(); col++) { --- 101,113 ---- } } ! } } if (!hasMatch) { m_log.debug("Adding new row to projection."); m_rows.add(newRow); ! } } } ! private boolean compareRows(List r1, List r2) { for (int col = 0; col < r1.size(); col++) { *************** *** 117,124 **** return true; } ! /** * Returns the columns in the projection as a list of either Variable or Count ! * instances. * @return a list of column descriptors */ --- 125,132 ---- return true; } ! /** * Returns the columns in the projection as a list of either Variable or Count ! * instances. * @return a list of column descriptors */ *************** *** 126,130 **** return m_columns; } ! /** * Returns the data rows in the projection. --- 134,138 ---- return m_columns; } ! /** * Returns the data rows in the projection. *************** *** 134,138 **** return m_rows; } ! public class Count { private Variable m_var; --- 142,146 ---- return m_rows; } ! public class Count { private Variable m_var; *************** *** 144,148 **** } } ! private void debugRow(String msg, List row) { StringBuffer m = new StringBuffer(); --- 152,156 ---- } } ! private void debugRow(String msg, List row) { StringBuffer m = new StringBuffer(); *************** *** 162,166 **** m_log.debug(m.toString()); } ! public String toString() { if (m_columns.isEmpty()) { --- 170,174 ---- m_log.debug(m.toString()); } ! public String toString() { if (m_columns.isEmpty()) { *************** *** 180,212 **** } - - /* - * $Log$ - * Revision 1.2 2005/03/06 21:11:32 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:29:06 lheuer - * Initial tolog import - * - * Revision 1.3 2004/06/09 21:05:01 kal_ahmed - * Added support for 'select * from' projection. - * - * Revision 1.2 2004/06/09 20:20:30 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.1 2004/06/07 20:31:33 kal_ahmed - * Completed work on projection and sorting. Performed a bit more code reorganisation. Added DirectInstanceOfPredicate. - * - * Revision 1.3 2004/06/03 20:04:56 kal_ahmed - * Completed initial package restructuring. - * - * Revision 1.2 2004/06/03 19:55:16 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/06/03 19:47:22 kal_ahmed - * Separated parser and parsed query representation classes into a sub-package. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 188,189 ---- Index: Clause.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/Clause.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Clause.java 6 Mar 2005 17:29:06 -0000 1.1 --- Clause.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.parser; *************** *** 18,26 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public interface Clause { ! public void doReplacement(Object[] params) throws TologProcessingException; --- 25,34 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public interface Clause { ! public void doReplacement(Object[] params) throws TologProcessingException; *************** *** 30,59 **** } - - /* - * $Log$ - * Revision 1.1 2005/03/06 17:29:06 lheuer - * Initial tolog import - * - * Revision 1.6 2004/06/16 21:21:43 kal_ahmed - * Tolog queries may now contain replaceable references specified in an Object array parameter to the QueryEvaluator at evaluation time. - * - * Revision 1.5 2004/06/13 19:44:30 kal_ahmed - * Added a fix and test for handling recursive rules definitions. - * - * Revision 1.4 2004/06/09 20:20:30 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.3 2004/06/03 20:04:56 kal_ahmed - * Completed initial package restructuring. - * - * Revision 1.2 2004/06/03 19:55:16 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/06/03 19:47:22 kal_ahmed - * Separated parser and parsed query representation classes into a sub-package. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 38,39 ---- Index: OrClause.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/parser/OrClause.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OrClause.java 6 Mar 2005 17:29:06 -0000 1.1 --- OrClause.java 8 Mar 2005 12:33:40 -0000 1.2 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.parser; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.parser; *************** *** 22,27 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class OrClause implements Clause { --- 29,35 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class OrClause implements Clause { *************** *** 30,34 **** private List m_vars; private static final Log m_log = LogFactory.getLog(OrClause.class); ! public OrClause() { m_children = new ArrayList(); --- 38,42 ---- private List m_vars; private static final Log m_log = LogFactory.getLog(OrClause.class); ! public OrClause() { m_children = new ArrayList(); *************** *** 46,50 **** } } ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.Clause#execute(org.tmapiutils.query.to... [truncated message content] |