From: Lars H. <lh...@us...> - 2005-07-08 16:03:59
|
Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30131/src/org/tmapiutils/query/tolog Modified Files: PreparedQuery.java QueryEvaluator.java QueryEvaluatorFactory.java TologFragmentBuilder.java TologFragmentBuilderException.java TologFragmentBuilderImpl.java TologParserException.java TologProcessingException.java TologResultsSet.java Log Message: Tabs -> Whitespaces Index: QueryEvaluator.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/QueryEvaluator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** QueryEvaluator.java 8 Mar 2005 12:33:39 -0000 1.2 --- QueryEvaluator.java 8 Jul 2005 16:03:19 -0000 1.3 *************** *** 1,109 **** ! /* ! * 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; ! ! import java.io.IOException; ! import java.io.InputStream; ! import java.util.Map; ! ! import org.tmapiutils.query.tolog.TologResultsSet; ! ! /** ! * This is the high-level interface to the tolog 1.0 ! * query engine. Using this interface you can initialise ! * the evaluator by loading one or more rules module files or ! * by adding rules as strings. ! * This class also supports the registration of extension ! * predicates. ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public interface QueryEvaluator ! { ! ! /** ! * Loads a rules module from the specified stream. ! * @param src the input stream to be parsed ! * @throws IOException if the module file could not be read. ! * @throws TologParserException if the module file could be ! * read but contained syntax errors. ! */ ! public void addRulesModule(InputStream src, String prefix) ! throws IOException, TologParserException; ! ! /** ! * Adds a new rule to the QueryEvaluator. ! * @param rule the rule string in tolog syntax ! * @throws TologParserException if there is a syntax error in the rule string. ! */ ! public void addRule(String rule) throws TologParserException; ! ! /** ! * Parses (and possibly optimizes) the specified tolog query string. ! * The return value is the parsed query which can then be executed ! * simply by calling {PreparedQuery#execute()}. ! * @param queryString the tolog query string to be parsed. ! * @return the PreparedQuery that represents the parsed, optimized tolog query. ! * @throws TologParserException if a syntax error or parse-time error is found in <code>queryString</code> ! * @throws TologProcessingException if an error occurs during optimisation of the query. ! */ ! public PreparedQuery prepareQuery(String queryString) throws TologParserException, TologProcessingException; ! ! /** ! * A convenience method that parses and optimizes the specified ! * tolog query and then executes it immediately. ! * @param queryString the tolog query string to be evaluated ! * @return the results of the query evaluation. ! * @throws TologParserException if a syntax error or parse-time error is found in <code>queryString</code> ! * @throws TologProcessingException if an error occurrs during the optimisation or evaluation of the query. ! */ ! public TologResultsSet execute(String queryString) throws TologParserException, TologProcessingException; ! ! /** ! * A convenience method that parses and optimizes the specified ! * tolog query and then executes it immediately. ! * @param queryString the tolog query string to be evaluated ! * @param queryParams the replacement values for % references in the query string ! * @return the results of the query evaluation. ! * @throws TologParserException if a syntax error or parse-time error is found in <code>queryString</code> ! * @throws TologProcessingException if an error occurrs during the optimisation or evaluation of the query. ! */ ! public TologResultsSet execute(String queryString, Object[] queryParams) throws TologParserException, TologProcessingException; ! ! /** ! * Registers an extension predicate with the QueryEvaluator. ! * All implementation classes MUST implement the {@link Predicate} interface. ! * If <code>predicateName</code> is the name of an already registered predicate, ! * then the new registration overwrites the old one. ! * @param predicateName the name to be used to reference the predicate from a tolog query. ! * @param predicateClass the implementation class for the predicate. ! * @throws IllegalArgumentException if the specified implementation class does not implement the Predicate interface. ! */ ! public void registerPredicateClass(String predicateName, Class predicateClass) ! throws IllegalArgumentException; ! ! /** ! * Returns a Map of the predicates currently registered with the ! * QueryEvaluator. The Map key is the name of the predicate and ! * the value is the implementation Class of the predicate. ! */ ! public Map getRegisteredPredicates(); ! ! } ! --- 1,109 ---- ! /* ! * 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; ! ! import java.io.IOException; ! import java.io.InputStream; ! import java.util.Map; ! ! import org.tmapiutils.query.tolog.TologResultsSet; ! ! /** ! * This is the high-level interface to the tolog 1.0 ! * query engine. Using this interface you can initialise ! * the evaluator by loading one or more rules module files or ! * by adding rules as strings. ! * This class also supports the registration of extension ! * predicates. ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public interface QueryEvaluator ! { ! ! /** ! * Loads a rules module from the specified stream. ! * @param src the input stream to be parsed ! * @throws IOException if the module file could not be read. ! * @throws TologParserException if the module file could be ! * read but contained syntax errors. ! */ ! public void addRulesModule(InputStream src, String prefix) ! throws IOException, TologParserException; ! ! /** ! * Adds a new rule to the QueryEvaluator. ! * @param rule the rule string in tolog syntax ! * @throws TologParserException if there is a syntax error in the rule string. ! */ ! public void addRule(String rule) throws TologParserException; ! ! /** ! * Parses (and possibly optimizes) the specified tolog query string. ! * The return value is the parsed query which can then be executed ! * simply by calling {PreparedQuery#execute()}. ! * @param queryString the tolog query string to be parsed. ! * @return the PreparedQuery that represents the parsed, optimized tolog query. ! * @throws TologParserException if a syntax error or parse-time error is found in <code>queryString</code> ! * @throws TologProcessingException if an error occurs during optimisation of the query. ! */ ! public PreparedQuery prepareQuery(String queryString) throws TologParserException, TologProcessingException; ! ! /** ! * A convenience method that parses and optimizes the specified ! * tolog query and then executes it immediately. ! * @param queryString the tolog query string to be evaluated ! * @return the results of the query evaluation. ! * @throws TologParserException if a syntax error or parse-time error is found in <code>queryString</code> ! * @throws TologProcessingException if an error occurrs during the optimisation or evaluation of the query. ! */ ! public TologResultsSet execute(String queryString) throws TologParserException, TologProcessingException; ! ! /** ! * A convenience method that parses and optimizes the specified ! * tolog query and then executes it immediately. ! * @param queryString the tolog query string to be evaluated ! * @param queryParams the replacement values for % references in the query string ! * @return the results of the query evaluation. ! * @throws TologParserException if a syntax error or parse-time error is found in <code>queryString</code> ! * @throws TologProcessingException if an error occurrs during the optimisation or evaluation of the query. ! */ ! public TologResultsSet execute(String queryString, Object[] queryParams) throws TologParserException, TologProcessingException; ! ! /** ! * Registers an extension predicate with the QueryEvaluator. ! * All implementation classes MUST implement the {@link Predicate} interface. ! * If <code>predicateName</code> is the name of an already registered predicate, ! * then the new registration overwrites the old one. ! * @param predicateName the name to be used to reference the predicate from a tolog query. ! * @param predicateClass the implementation class for the predicate. ! * @throws IllegalArgumentException if the specified implementation class does not implement the Predicate interface. ! */ ! public void registerPredicateClass(String predicateName, Class predicateClass) ! throws IllegalArgumentException; ! ! /** ! * Returns a Map of the predicates currently registered with the ! * QueryEvaluator. The Map key is the name of the predicate and ! * the value is the implementation Class of the predicate. ! */ ! public Map getRegisteredPredicates(); ! ! } ! Index: QueryEvaluatorFactory.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/QueryEvaluatorFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** QueryEvaluatorFactory.java 8 Mar 2005 12:33:39 -0000 1.2 --- QueryEvaluatorFactory.java 8 Jul 2005 16:03:19 -0000 1.3 *************** *** 1,36 **** ! /* ! * 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; ! ! import org.tmapiutils.query.tolog.memory.QueryEvaluatorImpl; ! import org.tmapi.core.TopicMap; ! ! /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public class QueryEvaluatorFactory ! { ! ! public static QueryEvaluator newQueryEvaluator(TopicMap tm) { ! QueryEvaluator qe = new QueryEvaluatorImpl(tm); ! return qe; ! } ! } ! --- 1,36 ---- ! /* ! * 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; ! ! import org.tmapiutils.query.tolog.memory.QueryEvaluatorImpl; ! import org.tmapi.core.TopicMap; ! ! /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public class QueryEvaluatorFactory ! { ! ! public static QueryEvaluator newQueryEvaluator(TopicMap tm) { ! QueryEvaluator qe = new QueryEvaluatorImpl(tm); ! return qe; ! } ! } ! Index: TologParserException.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/TologParserException.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TologParserException.java 8 Mar 2005 12:33:39 -0000 1.2 --- TologParserException.java 8 Jul 2005 16:03:19 -0000 1.3 *************** *** 1,35 **** ! /* ! * 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; ! ! /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public class TologParserException extends Exception { ! ! public TologParserException(String msg) { ! super(msg); ! } ! ! public TologParserException(String msg, Throwable cause) { ! super(msg, cause); ! } ! } ! --- 1,35 ---- ! /* ! * 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; ! ! /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public class TologParserException extends Exception { ! ! public TologParserException(String msg) { ! super(msg); ! } ! ! public TologParserException(String msg, Throwable cause) { ! super(msg, cause); ! } ! } ! Index: TologProcessingException.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/TologProcessingException.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TologProcessingException.java 8 Mar 2005 12:33:39 -0000 1.2 --- TologProcessingException.java 8 Jul 2005 16:03:19 -0000 1.3 *************** *** 1,35 **** ! /* ! * 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; ! ! /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public class TologProcessingException extends Exception { ! ! public TologProcessingException(String msg) { ! super(msg); ! } ! ! public TologProcessingException(String msg, Throwable cause) { ! super(msg, cause); ! } ! } ! --- 1,35 ---- ! /* ! * 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; ! ! /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public class TologProcessingException extends Exception { ! ! public TologProcessingException(String msg) { ! super(msg); ! } ! ! public TologProcessingException(String msg, Throwable cause) { ! super(msg, cause); ! } ! } ! Index: TologFragmentBuilderException.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/TologFragmentBuilderException.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TologFragmentBuilderException.java 8 Mar 2005 12:33:39 -0000 1.2 --- TologFragmentBuilderException.java 8 Jul 2005 16:03:19 -0000 1.3 *************** *** 1,61 **** ! /* ! * 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; ! ! ! /** ! * Exception raised by the TologFragmentBuilder interface when exporting ! * a TologResultsSet object into a topic map fragment. ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public class TologFragmentBuilderException extends Exception { ! private Throwable m_cause; ! ! /** ! * Create a new TologFragmentBuilderException with the specified message. ! */ ! public TologFragmentBuilderException(String msg) { ! super(msg); ! } ! ! /** ! * Create a new TologFragmentBuilderException with the specified message and ! * nested cause. ! */ ! public TologFragmentBuilderException(String msg, Throwable cause) { ! super(msg + "Cause:\n" + cause.getMessage()); ! m_cause = cause; ! } ! ! public Throwable getCause() { ! return m_cause; ! } ! ! public String toString() { ! String ret = super.toString(); ! ! if (m_cause != null) { ! ret = ret + "\nCause:\n" + m_cause.toString(); ! } ! ! return ret; ! } ! } ! --- 1,61 ---- ! /* ! * 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; ! ! ! /** ! * Exception raised by the TologFragmentBuilder interface when exporting ! * a TologResultsSet object into a topic map fragment. ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public class TologFragmentBuilderException extends Exception { ! private Throwable m_cause; ! ! /** ! * Create a new TologFragmentBuilderException with the specified message. ! */ ! public TologFragmentBuilderException(String msg) { ! super(msg); ! } ! ! /** ! * Create a new TologFragmentBuilderException with the specified message and ! * nested cause. ! */ ! public TologFragmentBuilderException(String msg, Throwable cause) { ! super(msg + "Cause:\n" + cause.getMessage()); ! m_cause = cause; ! } ! ! public Throwable getCause() { ! return m_cause; ! } ! ! public String toString() { ! String ret = super.toString(); ! ! if (m_cause != null) { ! ret = ret + "\nCause:\n" + m_cause.toString(); ! } ! ! return ret; ! } ! } ! Index: TologFragmentBuilderImpl.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/TologFragmentBuilderImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TologFragmentBuilderImpl.java 8 Mar 2005 12:33:39 -0000 1.3 --- TologFragmentBuilderImpl.java 8 Jul 2005 16:03:19 -0000 1.4 *************** *** 1,232 **** ! /* ! * 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; ! ! import org.tmapi.core.Locator; ! import org.tmapi.core.LocatorFactory; ! import org.tmapi.core.LocatorFactoryException; ! // TMAPI ! import org.tmapi.core.Association; ! import org.tmapi.core.TopicName; ! import org.tmapi.core.AssociationRole; ! import org.tmapi.core.Topic; ! import org.tmapi.core.TopicMap; ! import org.tmapi.core.TopicMapFactory; ! import org.tmapi.core.TopicMapProcessingException; ! import org.tmapi.core.utils.IDGenerator; ! import org.tmapi.core.utils.IDGeneratorFactory; ! import org.tmapi.core.utils.TopicMapFragment; ! ! import java.beans.PropertyVetoException; ! ! import java.util.ArrayList; ! import java.util.List; ! ! ! /** ! * Default implementation of the TologFragmentBuilder interface. ! */ ! public class TologFragmentBuilderImpl implements TologFragmentBuilder { ! public static final String DEFAULT_VARTOPIC_SUBJECT_INDICATOR_PREFIX = "http://tm4j.org/tolog/variable/"; ! public static final String ROW_ASSOC_TYPE_SUBJECT_INDICATOR = "http://tm4j.org/tolog/result-set-row"; ! TopicMapFragment m_frag = null; ! boolean m_convertRowInfo = false; ! boolean m_genVarTopicSI = true; ! String m_varTopicSIPrefix = DEFAULT_VARTOPIC_SUBJECT_INDICATOR_PREFIX; ! boolean m_genVarTopicName = true; ! String m_varTopicNamePrefix = ""; ! String m_rowAssocTypeName = null; ! IDGenerator m_idgen = IDGeneratorFactory.newIDGenerator(); ! List m_rowVariableTopics; ! Topic m_rowAssocType; ! ! public TologFragmentBuilderImpl() { ! } ! ! public TologFragmentBuilderImpl(TopicMapFragment tmFrag) { ! m_frag = tmFrag; ! } ! ! public TologFragmentBuilderImpl(TopicMapFragment tmFrag, ! boolean convertRowInfo) { ! m_frag = tmFrag; ! m_convertRowInfo = convertRowInfo; ! } ! ! public void setFragment(TopicMapFragment tmFrag) { ! m_frag = tmFrag; ! } ! ! public void setConvertRowInformation(boolean convertRowInfo) { ! m_convertRowInfo = convertRowInfo; ! } ! ! public void setGenerateVarTopicSubjectIndicators(boolean genVarTopicSI) { ! m_genVarTopicSI = genVarTopicSI; ! } ! ! public void setVarTopicSubjectIndicatorPrefix(String vtPrefix) { ! m_varTopicSIPrefix = vtPrefix; ! } ! ! public void setGenerateVarTopicNames(boolean genVarTopicNames) { ! m_genVarTopicName = genVarTopicNames; ! } ! ! public void setVarTopicNamePrefix(String namePrefix) { ! m_varTopicNamePrefix = namePrefix; ! } ! ! public void setRowAssociationTypeName(String rowAssocTypeName) { ! m_rowAssocTypeName = rowAssocTypeName; ! } ! ! public void exportResultsSet(TologResultsSet rs) ! throws TologFragmentBuilderException { ! if (m_convertRowInfo) { ! createRowAssocType(); ! createRowVariableTopics(rs); ! } ! ! for (int i = 0; i < rs.getNumRows(); i++) { ! List copiedRow = copyRow(rs.getRow(i)); ! ! if (m_convertRowInfo) { ! createRowAssoc(copiedRow); ! } ! } ! } ! ! public void createRowAssocType() throws TologFragmentBuilderException { ! TopicMapFactory factory = m_frag.getTopicMap().getFactory(); ! LocatorFactory locFactory = m_frag.getTopicMap().getLocatorFactory(); ! ! try { ! Locator ratLoc = locFactory.createLocator("URI", ! ROW_ASSOC_TYPE_SUBJECT_INDICATOR); ! m_rowAssocType = m_frag.getTopicMap().createTopic(m_idgen.getObjectId()); ! m_rowAssocType.addSubjectIdentifier(ratLoc); ! ! if (m_rowAssocTypeName != null) { ! TopicName bn = m_rowAssocType.createName(null); ! bn.setValue(m_rowAssocTypeName); ! } ! } catch (LocatorFactoryException ex) { ! throw new TologFragmentBuilderException("Error in creating subject indicator for row association type.", ! ex); ! } catch (TopicMapProcessingException ex) { ! throw new TologFragmentBuilderException("Error creating row association type topic.", ! ex); ! } catch (PropertyVetoException ex) { ! throw new TologFragmentBuilderException("Unable to fully initialise row association type topic.", ! ex); ! } ! } ! ! public void createRowVariableTopics(TologResultsSet rs) ! throws TologFragmentBuilderException { ! TopicMap fragTM = m_frag.getTopicMap(); ! LocatorFactory locFactory = fragTM.getLocatorFactory(); ! ! try { ! m_rowVariableTopics = new ArrayList(); ! ! for (int i = 0; i < rs.getNumCols(); i++) { ! String colName = rs.getVar(i); ! Topic t = fragTM.createTopic(m_idgen.getObjectId()); ! ! if (m_genVarTopicSI) { ! Locator l = locFactory.createLocator("URI", ! m_varTopicSIPrefix + colName); ! t.addSubjectIdentifier(l); ! } ! ! if (m_genVarTopicName) { ! String name = m_varTopicNamePrefix + colName; ! TopicName bn = t.createName(null); ! bn.setValue(name); ! } ! ! m_rowVariableTopics.add(t); ! } ! } catch (TopicMapProcessingException ex) { ! throw new TologFragmentBuilderException("Could not construct row variable topic.", ! ex); ! } catch (LocatorFactoryException ex) { ! throw new TologFragmentBuilderException("Error creating subject indicator for row variable topic.", ! ex); ! } catch (PropertyVetoException ex) { ! throw new TologFragmentBuilderException("Creation of row variable topic was vetoed.", ! ex); ! } ! } ! ! public List copyRow(List row) throws TologFragmentBuilderException { ! List copiedRow = new ArrayList(); ! ! try { ! for (int i = 0; i < row.size(); i++) { ! if (row.get(i) instanceof Topic) { ! Topic src = (Topic) row.get(i); ! ! if (m_frag.getTopicMap().getObjectById(src.getObjectId()) == null) { ! Topic cp = m_frag.addTopic((Topic) row.get(i), 0); ! copiedRow.add(cp); ! } else { ! copiedRow.add((Topic) m_frag.getTopicMap() ! .getObjectById(src.getObjectId())); ! } ! } else { ! copiedRow.add(null); ! } ! } ! } catch (LocatorFactoryException ex) { ! throw new TologFragmentBuilderException("Error while copying result topic.", ! ex); ! } catch (TopicMapProcessingException ex) { ! throw new TologFragmentBuilderException("Error while copying result topic.", ! ex); ! } ! ! return copiedRow; ! } ! ! public void createRowAssoc(List row) throws TologFragmentBuilderException { ! TopicMap fragTM = m_frag.getTopicMap(); ! ! try { ! Association assoc = fragTM.createAssociation(null); ! ! for (int i = 0; i < row.size(); i++) { ! if (row.get(i) != null) { ! AssociationRole m = assoc.createAssociationRole(null); ! m.setType((Topic) m_rowVariableTopics.get(i)); ! m.addPlayer((Topic) row.get(i)); ! } ! } ! ! assoc.setType(m_rowAssocType); ! } catch (TopicMapProcessingException ex) { ! throw new TologFragmentBuilderException("Error while creating row association.", ! ex); ! } catch (PropertyVetoException ex) { ! throw new TologFragmentBuilderException("Creation of row association was vetoed.", ! ex); ! } ! } ! } --- 1,232 ---- ! /* ! * 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; ! ! import org.tmapi.core.Locator; ! import org.tmapi.core.LocatorFactory; ! import org.tmapi.core.LocatorFactoryException; ! // TMAPI ! import org.tmapi.core.Association; ! import org.tmapi.core.TopicName; ! import org.tmapi.core.AssociationRole; ! import org.tmapi.core.Topic; ! import org.tmapi.core.TopicMap; ! import org.tmapi.core.TopicMapFactory; ! import org.tmapi.core.TopicMapProcessingException; ! import org.tmapi.core.utils.IDGenerator; ! import org.tmapi.core.utils.IDGeneratorFactory; ! import org.tmapi.core.utils.TopicMapFragment; ! ! import java.beans.PropertyVetoException; ! ! import java.util.ArrayList; ! import java.util.List; ! ! ! /** ! * Default implementation of the TologFragmentBuilder interface. ! */ ! public class TologFragmentBuilderImpl implements TologFragmentBuilder { ! public static final String DEFAULT_VARTOPIC_SUBJECT_INDICATOR_PREFIX = "http://tm4j.org/tolog/variable/"; ! public static final String ROW_ASSOC_TYPE_SUBJECT_INDICATOR = "http://tm4j.org/tolog/result-set-row"; ! TopicMapFragment m_frag = null; ! boolean m_convertRowInfo = false; ! boolean m_genVarTopicSI = true; ! String m_varTopicSIPrefix = DEFAULT_VARTOPIC_SUBJECT_INDICATOR_PREFIX; ! boolean m_genVarTopicName = true; ! String m_varTopicNamePrefix = ""; ! String m_rowAssocTypeName = null; ! IDGenerator m_idgen = IDGeneratorFactory.newIDGenerator(); ! List m_rowVariableTopics; ! Topic m_rowAssocType; ! ! public TologFragmentBuilderImpl() { ! } ! ! public TologFragmentBuilderImpl(TopicMapFragment tmFrag) { ! m_frag = tmFrag; ! } ! ! public TologFragmentBuilderImpl(TopicMapFragment tmFrag, ! boolean convertRowInfo) { ! m_frag = tmFrag; ! m_convertRowInfo = convertRowInfo; ! } ! ! public void setFragment(TopicMapFragment tmFrag) { ! m_frag = tmFrag; ! } ! ! public void setConvertRowInformation(boolean convertRowInfo) { ! m_convertRowInfo = convertRowInfo; ! } ! ! public void setGenerateVarTopicSubjectIndicators(boolean genVarTopicSI) { ! m_genVarTopicSI = genVarTopicSI; ! } ! ! public void setVarTopicSubjectIndicatorPrefix(String vtPrefix) { ! m_varTopicSIPrefix = vtPrefix; ! } ! ! public void setGenerateVarTopicNames(boolean genVarTopicNames) { ! m_genVarTopicName = genVarTopicNames; ! } ! ! public void setVarTopicNamePrefix(String namePrefix) { ! m_varTopicNamePrefix = namePrefix; ! } ! ! public void setRowAssociationTypeName(String rowAssocTypeName) { ! m_rowAssocTypeName = rowAssocTypeName; ! } ! ! public void exportResultsSet(TologResultsSet rs) ! throws TologFragmentBuilderException { ! if (m_convertRowInfo) { ! createRowAssocType(); ! createRowVariableTopics(rs); ! } ! ! for (int i = 0; i < rs.getNumRows(); i++) { ! List copiedRow = copyRow(rs.getRow(i)); ! ! if (m_convertRowInfo) { ! createRowAssoc(copiedRow); ! } ! } ! } ! ! public void createRowAssocType() throws TologFragmentBuilderException { ! TopicMapFactory factory = m_frag.getTopicMap().getFactory(); ! LocatorFactory locFactory = m_frag.getTopicMap().getLocatorFactory(); ! ! try { ! Locator ratLoc = locFactory.createLocator("URI", ! ROW_ASSOC_TYPE_SUBJECT_INDICATOR); ! m_rowAssocType = m_frag.getTopicMap().createTopic(m_idgen.getObjectId()); ! m_rowAssocType.addSubjectIdentifier(ratLoc); ! ! if (m_rowAssocTypeName != null) { ! TopicName bn = m_rowAssocType.createName(null); ! bn.setValue(m_rowAssocTypeName); ! } ! } catch (LocatorFactoryException ex) { ! throw new TologFragmentBuilderException("Error in creating subject indicator for row association type.", ! ex); ! } catch (TopicMapProcessingException ex) { ! throw new TologFragmentBuilderException("Error creating row association type topic.", ! ex); ! } catch (PropertyVetoException ex) { ! throw new TologFragmentBuilderException("Unable to fully initialise row association type topic.", ! ex); ! } ! } ! ! public void createRowVariableTopics(TologResultsSet rs) ! throws TologFragmentBuilderException { ! TopicMap fragTM = m_frag.getTopicMap(); ! LocatorFactory locFactory = fragTM.getLocatorFactory(); ! ! try { ! m_rowVariableTopics = new ArrayList(); ! ! for (int i = 0; i < rs.getNumCols(); i++) { ! String colName = rs.getVar(i); ! Topic t = fragTM.createTopic(m_idgen.getObjectId()); ! ! if (m_genVarTopicSI) { ! Locator l = locFactory.createLocator("URI", ! m_varTopicSIPrefix + colName); ! t.addSubjectIdentifier(l); ! } ! ! if (m_genVarTopicName) { ! String name = m_varTopicNamePrefix + colName; ! TopicName bn = t.createName(null); ! bn.setValue(name); ! } ! ! m_rowVariableTopics.add(t); ! } ! } catch (TopicMapProcessingException ex) { ! throw new TologFragmentBuilderException("Could not construct row variable topic.", ! ex); ! } catch (LocatorFactoryException ex) { ! throw new TologFragmentBuilderException("Error creating subject indicator for row variable topic.", ! ex); ! } catch (PropertyVetoException ex) { ! throw new TologFragmentBuilderException("Creation of row variable topic was vetoed.", ! ex); ! } ! } ! ! public List copyRow(List row) throws TologFragmentBuilderException { ! List copiedRow = new ArrayList(); ! ! try { ! for (int i = 0; i < row.size(); i++) { ! if (row.get(i) instanceof Topic) { ! Topic src = (Topic) row.get(i); ! ! if (m_frag.getTopicMap().getObjectById(src.getObjectId()) == null) { ! Topic cp = m_frag.addTopic((Topic) row.get(i), 0); ! copiedRow.add(cp); ! } else { ! copiedRow.add((Topic) m_frag.getTopicMap() ! .getObjectById(src.getObjectId())); ! } ! } else { ! copiedRow.add(null); ! } ! } ! } catch (LocatorFactoryException ex) { ! throw new TologFragmentBuilderException("Error while copying result topic.", ! ex); ! } catch (TopicMapProcessingException ex) { ! throw new TologFragmentBuilderException("Error while copying result topic.", ! ex); ! } ! ! return copiedRow; ! } ! ! public void createRowAssoc(List row) throws TologFragmentBuilderException { ! TopicMap fragTM = m_frag.getTopicMap(); ! ! try { ! Association assoc = fragTM.createAssociation(null); ! ! for (int i = 0; i < row.size(); i++) { ! if (row.get(i) != null) { ! AssociationRole m = assoc.createAssociationRole(null); ! m.setType((Topic) m_rowVariableTopics.get(i)); ! m.addPlayer((Topic) row.get(i)); ! } ! } ! ! assoc.setType(m_rowAssocType); ! } catch (TopicMapProcessingException ex) { ! throw new TologFragmentBuilderException("Error while creating row association.", ! ex); ! } catch (PropertyVetoException ex) { ! throw new TologFragmentBuilderException("Creation of row association was vetoed.", ! ex); ! } ! } ! } Index: TologResultsSet.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/TologResultsSet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TologResultsSet.java 8 Mar 2005 12:33:39 -0000 1.2 --- TologResultsSet.java 8 Jul 2005 16:03:19 -0000 1.3 *************** *** 1,59 **** ! /* ! * 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; ! ! import java.util.List; ! ! ! /** ! * This interface represents a collection of results from a single Tolog ! * query. The collection is somewhat similar to a JDBC results set and can ! * be thought of as a table consisting of a number of named columns with ! * one row for each distinct match to the Tolog query. ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public interface TologResultsSet { ! /** ! * Returns the number of distinct matches in this results set. ! * (i.e. the number of "rows" in the set). ! */ ! public int getNumRows(); ! ! /** ! * Returns the number of variables listed in each match in this results set. ! * (i.e. the number of "columns" in the set). ! */ ! public int getNumCols(); ! ! /** ! * Returns the name of the variable in the <code>colNum</code>'th position ! * of the results set match. (equivalent to the column name in a JDBC query). ! * The index starts at 0. ! */ ! public String getVar(int colNum); ! ! /** ! * Returns a single match from the results set. The index starts at 0. ! * The row is returned at a list containing the results in colum order. ! * Each list entry is a ({@link org.tmapi.core.Topic} object. ! */ ! public List getRow(int rowNum); ! } ! --- 1,59 ---- ! /* ! * 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; ! ! import java.util.List; ! ! ! /** ! * This interface represents a collection of results from a single Tolog ! * query. The collection is somewhat similar to a JDBC results set and can ! * be thought of as a table consisting of a number of named columns with ! * one row for each distinct match to the Tolog query. ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public interface TologResultsSet { ! /** ! * Returns the number of distinct matches in this results set. ! * (i.e. the number of "rows" in the set). ! */ ! public int getNumRows(); ! ! /** ! * Returns the number of variables listed in each match in this results set. ! * (i.e. the number of "columns" in the set). ! */ ! public int getNumCols(); ! ! /** ! * Returns the name of the variable in the <code>colNum</code>'th position ! * of the results set match. (equivalent to the column name in a JDBC query). ! * The index starts at 0. ! */ ! public String getVar(int colNum); ! ! /** ! * Returns a single match from the results set. The index starts at 0. ! * The row is returned at a list containing the results in colum order. ! * Each list entry is a ({@link org.tmapi.core.Topic} object. ! */ ! public List getRow(int rowNum); ! } ! Index: PreparedQuery.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/PreparedQuery.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PreparedQuery.java 8 Mar 2005 12:33:39 -0000 1.2 --- PreparedQuery.java 8 Jul 2005 16:03:19 -0000 1.3 *************** *** 1,55 **** ! /* ! * 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; ! ! import org.tmapiutils.query.tolog.TologResultsSet; ! ! /** ! * Represents a parsed, optimized tolog query which can ! * be executed as often as required. ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public interface PreparedQuery ! { ! /** ! * Returns the prepared query string in tolog syntax. ! * This string may differ from the original string used to ! * prepare the query, as optimisations may have been performed ! * by the QueryEvaluator. ! * @return the prepared query string in tolog syntax. ! */ ! public String getQueryString(); ! ! /** ! * Executes the prepared query. ! * @return the results of the query evaluation. ! * @throws TologProcessingException if an error occurred during query evaluation. ! */ ! public TologResultsSet execute() throws TologProcessingException; ! ! /** ! * Executes a prepared query substituting <i>%n</i> references with the <i>n</i>th value from ! * the parameter array. ! * @param params the parameter array for this query evaluation ! * @return the results of the query evaluation. ! * @throws TologProcessingException if an error occurred during query evaluation. ! */ ! public TologResultsSet execute(Object[] params) throws TologProcessingException; ! } --- 1,55 ---- ! /* ! * 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; ! ! import org.tmapiutils.query.tolog.TologResultsSet; ! ! /** ! * Represents a parsed, optimized tolog query which can ! * be executed as often as required. ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public interface PreparedQuery ! { ! /** ! * Returns the prepared query string in tolog syntax. ! * This string may differ from the original string used to ! * prepare the query, as optimisations may have been performed ! * by the QueryEvaluator. ! * @return the prepared query string in tolog syntax. ! */ ! public String getQueryString(); ! ! /** ! * Executes the prepared query. ! * @return the results of the query evaluation. ! * @throws TologProcessingException if an error occurred during query evaluation. ! */ ! public TologResultsSet execute() throws TologProcessingException; ! ! /** ! * Executes a prepared query substituting <i>%n</i> references with the <i>n</i>th value from ! * the parameter array. ! * @param params the parameter array for this query evaluation ! * @return the results of the query evaluation. ! * @throws TologProcessingException if an error occurred during query evaluation. ! */ ! public TologResultsSet execute(Object[] params) throws TologProcessingException; ! } Index: TologFragmentBuilder.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/TologFragmentBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TologFragmentBuilder.java 8 Mar 2005 12:33:39 -0000 1.2 --- TologFragmentBuilder.java 8 Jul 2005 16:03:19 -0000 1.3 *************** *** 1,101 **** ! /* ! * 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; ! ! import org.tmapi.core.utils.TopicMapFragment; ! ! ! /** ! * The interface for implementations which export a TologResultsSet into ! * a TopicMapFragment. ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public interface TologFragmentBuilder { ! /** ! * Set the TopicMapFragment into which the results set should be exported. ! * @param fragment the topic map fragment to export to. ! */ ! public void setFragment(TopicMapFragment fragment); ! ! /** ! * Set the flag which indicates whether or not row information should be exported. ! * If <code>true</code> then the exported topic map fragment will contain ! * one association for each row in the TologResultsSet. Each association ! * will have one member for each column in the results set with a single ! * player for that member. ! */ ! public void setConvertRowInformation(boolean convertRowInfo); ! ! /** ! * Set the flag which indicates whether or not topics representing the ! * results set variables should be given subject indicators. ! * @param genVarTopicSI true if the topics representing results set variables ! * should be given subject indicators, false otherwise. ! */ ! public void setGenerateVarTopicSubjectIndicators(boolean genVarTopicSI); ! ! /** ! * Sets the prefix part of the subject indicator locator address to be ! * generated for results set variables. The final form of the locator ! * addresses generated will be {vtPrefix}{variablename}. It is the responsibility ! * of the caller to ensure that the prefix is such that these generated addresses ! * are valid URI strings. ! * @param vtPrefix the prefix string to be used for generating the subject ! * indicator locators for the topics representing results set ! * variables. ! */ ! public void setVarTopicSubjectIndicatorPrefix(String vtPrefix); ! ! /** ! * Set the flag which indicates whether or not topics representing the ! * results set variables should be given base names. ! * @param genVarTopicNames true if the topics representing results set variables ! * should be given base names, false otherwise. ! */ ! public void setGenerateVarTopicNames(boolean genVarTopicNames); ! ! /** ! * Sets the string to be prepended to the base name string generated for ! * topics which represent results set variables. The final form of the ! * generated names will be {namePrefix}{variable name}. ! * @param namePrefix the prefix string used in generating names for the ! * topics which represent results set variables. ! */ ! public void setVarTopicNamePrefix(String namePrefix); ! ! /** ! * Sets the base name string to be assigned to the topic which ! * types the row associations generated if the convertRowInformation option ! * is set to <code>true</code>. ! * @param rowAssocTypeName the name assigned to the topic which is used to ! * type associations generated for each row in the ! * results set. ! */ ! public void setRowAssociationTypeName(String rowAssocTypeName); ! ! /** ! * Perform the export with the currently specified export ! * parameters. This method will fail if setFragment() has not been ! * called before calling this method. ! * @param rs the tolog results set to be exported. ! */ ! public void exportResultsSet(TologResultsSet rs) ! throws TologFragmentBuilderException; ! } --- 1,101 ---- ! /* ! * 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; ! ! import org.tmapi.core.utils.TopicMapFragment; ! ! ! /** ! * The interface for implementations which export a TologResultsSet into ! * a TopicMapFragment. ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) ! */ ! public interface TologFragmentBuilder { ! /** ! * Set the TopicMapFragment into which the results set should be exported. ! * @param fragment the topic map fragment to export to. ! */ ! public void setFragment(TopicMapFragment fragment); ! ! /** ! * Set the flag which indicates whether or not row information should be exported. ! * If <code>true</code> then the exported topic map fragment will contain ! * one association for each row in the TologResultsSet. Each association ! * will have one member for each column in the results set with a single ! * player for that member. ! */ ! public void setConvertRowInformation(boolean convertRowInfo); ! ! /** ! * Set the flag which indicates whether or not topics representing the ! * results set variables should be given subject indicators. ! * @param genVarTopicSI true if the topics representing results set variables ! * should be given subject indicators, false otherwise. ! */ ! public void setGenerateVarTopicSubjectIndicators(boolean genVarTopicSI); ! ! /** ! * Sets the prefix part of the subject indicator locator address to be ! * generated for results set variables. The final form of the locator ! * addresses generated will be {vtPrefix}{variablename}. It is the responsibility ! * of the caller to ensure that the prefix is such that these generated addresses ! * are valid URI strings. ! * @param vtPrefix the prefix string to be used for generating the subject ! * indicator locators for the topics representing results set ! * variables. ! */ ! public void setVarTopicSubjectIndicatorPrefix(String vtPrefix); ! ! /** ! * Set the flag which indicates whether or not topics representing the ! * results set variables should be given base names. ! * @param genVarTopicNames true if the topics representing results set variables ! * should be given base names, false otherwise. ! */ ! public void setGenerateVarTopicNames(boolean genVarTopicNames); ! ! /** ! * Sets the string to be prepended to the base name string generated for ! * topics which represent results set variables. The final form of the ! * generated names will be {namePrefix}{variable name}. ! * @param namePrefix the prefix string used in generating names for the ! * topics which represent results set variables. ! */ ! public void setVarTopicNamePrefix(String namePrefix); ! ! /** ! * Sets the base name string to be assigned to the topic which ! * types the row associations generated if the convertRowInformation option ! * is set to <code>true</code>. ! * @param rowAssocTypeName the name assigned to the topic which is used to ! * type associations generated for each row in the ! * results set. ! */ ! public void setRowAssociationTypeName(String rowAssocTypeName); ! ! /** ! * Perform the export with the currently specified export ! * parameters. This method will fail if setFragment() has not been ! * called before calling this method. ! * @param rs the tolog results set to be exported. ! */ ! public void exportResultsSet(TologResultsSet rs) ! throws TologFragmentBuilderException; ! } |