Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/parameters/QueryField.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/parameters/QueryField.java	(revision 2131)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/parameters/QueryField.java	(revision 2132)
@@ -7,7 +7,7 @@
 import org.eclipse.swt.widgets.Label;
 import org.kohsuke.args4j.NamedOptionDef;
 import org.txm.rcp.swt.widget.QueryWidget;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.cqp.corpus.query.CQLQuery;
 
 public class QueryField extends ParameterField {
@@ -31,7 +31,7 @@
 		resetToDefault();
 	}
 
-	public Query getWidgetValue() {
+	public IQuery getWidgetValue() {
 		return w.getQuery();
 	}
 
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedChoiceQueryWidget.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedChoiceQueryWidget.java	(revision 2131)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedChoiceQueryWidget.java	(revision 2132)
@@ -52,7 +52,7 @@
 import org.txm.rcp.swt.dialog.QueryAssistDialog;
 import org.txm.rcp.swt.provider.ListContentProvider;
 import org.txm.rcp.swt.provider.SimpleLabelProvider;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.core.SearchEngine;
 import org.txm.searchengine.core.SearchEnginesManager;
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
@@ -242,7 +242,7 @@
 		querywidget.setText(query);
 	}
 
-	public Query getQuery() {
+	public IQuery getQuery() {
 		return this.querywidget.getQuery();
 	}
 }
\ No newline at end of file
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedQueryWidget.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedQueryWidget.java	(revision 2131)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedQueryWidget.java	(revision 2132)
@@ -41,7 +41,7 @@
 import org.txm.rcp.messages.TXMUIMessages;
 import org.txm.rcp.swt.GLComposite;
 import org.txm.rcp.swt.dialog.QueryAssistDialog;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.core.SearchEngine;
 import org.txm.searchengine.core.SearchEnginesManager;
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
@@ -179,7 +179,7 @@
 		querywidget.setText(query);
 	}
 
-	public Query getQuery() {
+	public IQuery getQuery() {
 		return this.querywidget.getQuery();
 	}
 
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/QueryWidget.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/QueryWidget.java	(revision 2131)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/QueryWidget.java	(revision 2132)
@@ -32,7 +32,7 @@
 
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.core.SearchEngine;
 import org.txm.searchengine.core.SearchEnginesManager;
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
@@ -130,7 +130,7 @@
 	 *
 	 * @return the query
 	 */
-	public Query getQuery() {
+	public IQuery getQuery() {
 		if (!this.getQueryString().isEmpty())	{
 			return se.newQuery().setQuery(this.getQueryString());	
 		} else {
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java	(revision 2131)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java	(revision 2132)
@@ -82,7 +82,7 @@
 import org.txm.rcp.utils.SWTEditorsUtils;
 import org.txm.rcp.views.corpora.CorporaView;
 import org.txm.rcp.views.debug.TXMResultDebugView;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.cqp.ReferencePattern;
 import org.txm.searchengine.cqp.corpus.Property;
 import org.txm.searchengine.cqp.corpus.query.CQLQuery;
@@ -1234,9 +1234,9 @@
 					((NewNavigationWidget)object).setCurrentPosition((Integer) value); 
 				}
 				else if(object instanceof AssistedChoiceQueryWidget)	{
-					if(!((Query)value).getQueryString().isEmpty())	{
-						((AssistedChoiceQueryWidget)object).setText(((Query)value).getQueryString());
-						((AssistedChoiceQueryWidget)object).setSearchEngine(((Query)value).getSearchEngine());
+					if(!((IQuery)value).getQueryString().isEmpty())	{
+						((AssistedChoiceQueryWidget)object).setText(((IQuery)value).getQueryString());
+						((AssistedChoiceQueryWidget)object).setSearchEngine(((IQuery)value).getSearchEngine());
 					}
 				}
 				else if(object instanceof AssistedQueryWidget)	{
Index: tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERQuery.java
===================================================================
--- tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERQuery.java	(revision 2131)
+++ tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERQuery.java	(revision 2132)
@@ -1,10 +1,10 @@
 package org.txm.searchengine.ts;
 
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.core.SearchEngine;
 import org.txm.searchengine.core.SearchEnginesManager;
 
-public class TIGERQuery implements Query {
+public class TIGERQuery implements IQuery {
 
 	String query;
 	
@@ -24,18 +24,18 @@
 	}
 
 	@Override
-	public Query setQuery(String rawQuery) {
+	public IQuery setQuery(String rawQuery) {
 		query = rawQuery;
 		return this;
 	}
 
 	@Override
-	public Query fixQuery() {
+	public IQuery fixQuery() {
 		return this;
 	}
 
 	@Override
-	public boolean equals(Query q) {
+	public boolean equals(IQuery q) {
 		return this.getClass().equals(q.getClass()) && this.getQueryString().equals(q.getQueryString());
 	}
 	
Index: tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSelection.java
===================================================================
--- tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSelection.java	(revision 2131)
+++ tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSelection.java	(revision 2132)
@@ -4,15 +4,15 @@
 import java.util.List;
 
 import org.txm.objects.Match;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.core.Selection;
 
 public class TIGERSelection extends Selection {
 
 	List<? extends Match> matches;
-	Query query;
+	IQuery query;
 	
-	public TIGERSelection(Query query, List<? extends Match> result2) {
+	public TIGERSelection(IQuery query, List<? extends Match> result2) {
 		this.query = query;
 		matches = result2;
 	}
@@ -34,7 +34,7 @@
 	}
 
 	@Override
-	public Query getQuery() {
+	public IQuery getQuery() {
 		return query;
 	}
 
Index: tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSearchEngine.java
===================================================================
--- tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSearchEngine.java	(revision 2131)
+++ tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSearchEngine.java	(revision 2132)
@@ -11,7 +11,7 @@
 import org.txm.objects.Match;
 import org.txm.objects.Project;
 import org.txm.searchengine.core.EmptySelection;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.core.SearchEngine;
 import org.txm.searchengine.core.SearchEngineProperty;
 import org.txm.searchengine.core.Selection;
@@ -56,7 +56,7 @@
 	}
 
 	@Override
-	public Selection query(CorpusBuild corpus, Query query, String name, boolean saveQuery) throws Exception {
+	public Selection query(CorpusBuild corpus, IQuery query, String name, boolean saveQuery) throws Exception {
 		
 		File tigerDirectory = new File(corpus.getProjectDirectory(), "tiger");
 		File configfile = new File(tigerDirectory, "tigersearch.logprop");
@@ -149,7 +149,7 @@
 	}
 
 	@Override
-	public Query newQuery() {
+	public IQuery newQuery() {
 		return new TIGERQuery();
 	}
 
Index: tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/PartitionIndexEditor.java
===================================================================
--- tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/PartitionIndexEditor.java	(revision 2131)
+++ tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/PartitionIndexEditor.java	(revision 2132)
@@ -65,7 +65,7 @@
 import org.txm.rcp.swt.widget.PropertiesSelector;
 import org.txm.rcp.swt.widget.ThresholdsGroup;
 import org.txm.rcp.views.QueriesView;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
 import org.txm.searchengine.cqp.corpus.Part;
@@ -655,7 +655,7 @@
 		this.queryWidget.setText(query);
 	}
 
-	public Query getQuery() {
+	public IQuery getQuery() {
 		return queryWidget.getQuery();
 	}
 }
\ No newline at end of file
Index: tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/IndexEditor.java
===================================================================
--- tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/IndexEditor.java	(revision 2131)
+++ tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/IndexEditor.java	(revision 2132)
@@ -64,7 +64,7 @@
 import org.txm.rcp.swt.widget.PropertiesSelector;
 import org.txm.rcp.swt.widget.ThresholdsGroup;
 import org.txm.rcp.views.QueriesView;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
 import org.txm.searchengine.cqp.corpus.Property;
@@ -540,7 +540,7 @@
 	 * Gets the query of the query widget.
 	 * @return
 	 */
-	public Query getQuery() {
+	public IQuery getQuery() {
 		return queryWidget.getQuery();
 	}
 }
\ No newline at end of file
Index: tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/editors/ProgressionEditor.java
===================================================================
--- tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/editors/ProgressionEditor.java	(revision 2131)
+++ tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/editors/ProgressionEditor.java	(revision 2132)
@@ -44,7 +44,7 @@
 import org.txm.rcp.swt.widget.structures.StructuralUnitPropertiesComboViewer;
 import org.txm.rcp.swt.widget.structures.StructuralUnitsComboViewer;
 import org.txm.rcp.swt.widget.structures.StructuralUnitsCombosGroup;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.cqp.corpus.query.CQLQuery;
 import org.txm.utils.io.IOUtils;
 import org.txm.utils.logger.Log;
@@ -533,7 +533,7 @@
 			assistedQueryWidget.setText(query);
 		}
 
-		public Query getQuery() {
+		public IQuery getQuery() {
 			return assistedQueryWidget.getQuery();
 		}
 
@@ -633,7 +633,7 @@
 		
 		 // initialize query fields
 		if (queryWidgets.size() == 0 && queryList != null) {
-			for (Query q : queryList) {
+			for (IQuery q : queryList) {
 				addFocusQueryField(q.getQueryString()); 
 			}
 		}
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/CQLQuery.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/CQLQuery.java	(revision 2131)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/CQLQuery.java	(revision 2132)
@@ -33,7 +33,7 @@
 import java.util.regex.Pattern;
 
 import org.txm.core.preferences.TXMPreferences;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.core.SearchEngine;
 import org.txm.searchengine.core.SearchEnginesManager;
 import org.txm.searchengine.cqp.CQPSearchEngine;
@@ -47,7 +47,7 @@
  * @author sjacquot
  */
 
-public class CQLQuery implements Query {
+public class CQLQuery implements IQuery {
 
 	/** The Constant NoStrategy. */
 	private static final Integer NoStrategy = 0;
@@ -396,19 +396,19 @@
 	}
 
 	@Override
-	public Query setQuery(String rawQuery) {
+	public IQuery setQuery(String rawQuery) {
 		this.queryString = rawQuery;
 		return this;
 	}
 
 	@Override
-	public Query fixQuery() {
+	public IQuery fixQuery() {
 		this.queryString = fixQuery(this.queryString);
 		return this;
 	}
 
 	@Override
-	public boolean equals(Query q) {
+	public boolean equals(IQuery q) {
 		return this.getClass().equals(q.getClass()) && this.getQueryString().equals(q.getQueryString());
 	}
 }
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CQPSearchEngine.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CQPSearchEngine.java	(revision 2131)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CQPSearchEngine.java	(revision 2132)
@@ -14,7 +14,7 @@
 import org.txm.objects.CorpusBuild;
 import org.txm.objects.Match;
 import org.txm.searchengine.core.EmptySelection;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.core.SearchEngine;
 import org.txm.searchengine.core.SearchEngineProperty;
 import org.txm.searchengine.core.Selection;
@@ -410,7 +410,7 @@
 	}
 
 	@Override
-	public Selection query(CorpusBuild corpus, Query query, String name, boolean saveQuery) throws CqiClientException {
+	public Selection query(CorpusBuild corpus, IQuery query, String name, boolean saveQuery) throws CqiClientException {
 		if (query instanceof CQLQuery && corpus instanceof CQPCorpus) {
 			return ((CQPCorpus)corpus).query((CQLQuery)query, name, saveQuery);
 		} else {
@@ -419,7 +419,7 @@
 	}
 
 	@Override
-	public Query newQuery() {
+	public IQuery newQuery() {
 		return new CQLQuery(""); //$NON-NLS-1$
 	}
 
Index: tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java
===================================================================
--- tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java	(revision 2131)
+++ tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java	(revision 2132)
@@ -51,7 +51,7 @@
 import org.txm.core.results.TXMParameters;
 import org.txm.core.results.TXMResult;
 import org.txm.objects.Match;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.core.Selection;
 import org.txm.searchengine.cqp.AbstractCqiClient;
 import org.txm.searchengine.cqp.CQPSearchEngine;
@@ -114,7 +114,7 @@
 	
 	/** The query. */
 	@Parameter(key=ConcordancePreferences.QUERY)
-	protected Query pQuery;
+	protected IQuery pQuery;
 	
 	
 	/** The keyword analysis properties */
@@ -291,8 +291,8 @@
 		
 		if (!this.getCorpus().equals(other.getCorpus())) return false;
 		
-		Query q1 = other.getQuery();
-		Query q2 = this.getQuery();
+		IQuery q1 = other.getQuery();
+		IQuery q2 = this.getQuery();
 		if (q1 != null && q2 != null) return q1.equals(q2);
 		
 		return true;
@@ -859,7 +859,7 @@
 	 * 
 	 * @return the query
 	 */
-	public Query getQuery() {
+	public IQuery getQuery() {
 		return pQuery;
 	}
 
Index: tmp/org.txm.index.core/src/org/txm/index/core/functions/PartitionIndex.java
===================================================================
--- tmp/org.txm.index.core/src/org/txm/index/core/functions/PartitionIndex.java	(revision 2131)
+++ tmp/org.txm.index.core/src/org/txm/index/core/functions/PartitionIndex.java	(revision 2132)
@@ -50,7 +50,7 @@
 import org.txm.index.core.messages.IndexCoreMessages;
 import org.txm.index.core.preferences.IndexPreferences;
 import org.txm.objects.Match;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.core.Selection;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
@@ -140,7 +140,7 @@
 	 * The CQP query.
 	 */
 	@Parameter(key=TXMPreferences.QUERY)
-	protected Query pQuery;
+	protected IQuery pQuery;
 
 	/**
 	 * The line index of the current index page.
@@ -728,7 +728,7 @@
 	 *
 	 * @return the query used
 	 */
-	public Query getQuery() {
+	public IQuery getQuery() {
 		return pQuery;
 	}
 
Index: tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java
===================================================================
--- tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java	(revision 2131)
+++ tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java	(revision 2132)
@@ -51,7 +51,7 @@
 import org.txm.index.core.messages.IndexCoreMessages;
 import org.txm.index.core.preferences.IndexPreferences;
 import org.txm.objects.Match;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.core.Selection;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
@@ -127,7 +127,7 @@
 	 * The CQP query.
 	 */
 	@Parameter(key=TXMPreferences.QUERY)
-	protected Query pQuery;
+	protected IQuery pQuery;
 
 	/**
 	 * The line index of the current index page.
@@ -675,7 +675,7 @@
 	 *
 	 * @return the query used
 	 */
-	public Query getQuery() {
+	public IQuery getQuery() {
 		return pQuery;
 	}
 
Index: tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/IQuery.java
===================================================================
--- tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/IQuery.java	(revision 0)
+++ tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/IQuery.java	(revision 2132)
@@ -0,0 +1,36 @@
+package org.txm.searchengine.core;
+
+/**
+ * Represent a search engine query
+ * 
+ * @author mdecorde
+ *
+ */
+public interface IQuery {
+	
+	public String getQueryString();
+	
+	public boolean isEmpty();
+
+	/**
+	 * 
+	 * @return the Query SearchEngine that can resolve the query
+	 */
+	public SearchEngine getSearchEngine();
+
+	/**
+	 * update the query
+	 * 
+	 * @param rawQuery
+	 * @return this
+	 */
+	public IQuery setQuery(String rawQuery);
+	
+	/**
+	 * fix the query using sugar syntax rules
+	 * @return this
+	 */
+	public IQuery fixQuery();
+	
+	public boolean equals(IQuery q);
+}

Property changes on: tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/IQuery.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/EmptySelection.java
===================================================================
--- tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/EmptySelection.java	(revision 2131)
+++ tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/EmptySelection.java	(revision 2132)
@@ -8,9 +8,9 @@
 public class EmptySelection extends Selection {
 	
 	private static final List<? extends Match> EMPTY = new ArrayList<Match>();
-	protected Query query;
+	protected IQuery query;
 	
-	public EmptySelection(Query query) {
+	public EmptySelection(IQuery query) {
 		this.query = query;
 	}
 
@@ -26,7 +26,7 @@
 		return 0;
 	}
 	
-	public Query getQuery() {
+	public IQuery getQuery() {
 		return query;
 	}
 
Index: tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/ISearchEngine.java
===================================================================
--- tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/ISearchEngine.java	(revision 2131)
+++ tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/ISearchEngine.java	(revision 2132)
@@ -5,13 +5,13 @@
 
 public interface ISearchEngine extends Engine {
 	
-	public Selection query(CorpusBuild corpus, Query query, String name, boolean saveQuery) throws Exception;
+	public Selection query(CorpusBuild corpus, IQuery query, String name, boolean saveQuery) throws Exception;
 	
 	/**
 	 * 
 	 * @return an empty Query for the engine implementation
 	 */
-	public Query newQuery();
+	public IQuery newQuery();
 
 	/**
 	 * 
Index: tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/Query.java
===================================================================
--- tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/Query.java	(revision 2131)
+++ tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/Query.java	(revision 2132)
@@ -1,36 +1,186 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate: 2015-05-13 09:46:56 +0200 (Wed, 13 May 2015) $
+// $LastChangedRevision: 2967 $
+// $LastChangedBy: mdecorde $ 
+//
 package org.txm.searchengine.core;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import org.txm.core.preferences.TXMPreferences;
+
 /**
- * Represent a search engine query
+ * Implements a SearchEngine generic query with a query and a search engine.
  * 
- * @author mdecorde
- *
+ * TODO stop using CQLQuery and TIGERQuery with this class
  */
-public interface Query {
-	
-	public String getQueryString();
-	
-	public boolean isEmpty();
 
+public class Query implements IQuery {
+
 	/**
+	 * Converts the specified list of Query to a string.
+	 * Queries strings are separated by a tabulation.
+	 * @param queries
+	 * @return
+	 */
+	public static String queriesToString(List<Query> queries) {
+		String str = "";
+		for (int i = 0; i < queries.size(); i++) {
+			if(i > 0)	{
+				str += TXMPreferences.LIST_SEPARATOR;
+			}
+			str += queries.get(i).getQueryString();	
+			str += TXMPreferences.LIST_SEPARATOR+queries.get(i).getSearchEngine().getName();
+		}
+		return str;
+	}
+
+	/**
+	 * Converts the specified string to a list of Query.
+	 * Input string must contains queries separated by a tabulation.
+	 * @param str
+	 * @return
+	 */
+	public static List<Query> stringToQueries(String str) {
+		ArrayList<Query> queries = new ArrayList<Query>();
+		if (str == null || str.length() == 0) {
+			return queries;
+		}
+		String[] split = str.split(TXMPreferences.LIST_SEPARATOR);
+		for (int i = 0 ; i +1 < split.length ; i = i+2) {
+			String s = split[i];
+			String eName = split[i];
+			SearchEngine e = SearchEnginesManager.getSearchEngine(eName);
+			queries.add(new Query(s, e));
+		}
+		return queries;
+	}
+
+	/**
+	 * Converts the specified string to a Query.
+	 * Input string must contains queries separated by a tabulation.
+	 * @param str
+	 * @return
+	 */
+	public static Query stringToQuery(String str) {
+
+		String[] split = str.split(TXMPreferences.LIST_SEPARATOR, 2);
+		String eName = split[1];
+		SearchEngine e = SearchEnginesManager.getSearchEngine(eName);
+		return new Query(split[0], e);
+
+	}
+
+	/**
+	 * The query string.
+	 */
+	protected SearchEngine engine = null;
+
+	/**
+	 * The query string.
+	 */
+	protected String queryString = "";
+
+
+	/**
+	 * Instantiates a new query.
 	 * 
-	 * @return the Query SearchEngine that can resolve the query
+	 * @param queryString
+	 *            the query string
+	 * 
+	 *            public Query(String queryString){
+	 *            this.queryString=queryString.trim(); }
 	 */
-	public SearchEngine getSearchEngine();
+	public Query(String queryString, SearchEngine engine) {
+		if (queryString != null) {
+			this.queryString = queryString.trim();
+		}
+		else {
+			this.queryString = "";
+		}
 
+		this.engine = engine;
+	}
+
+	@Override
+	public boolean equals(IQuery q) {
+		return this.engine.equals(q.getSearchEngine()) && this.getQueryString().equals(q.getQueryString());
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (obj == null) return false;
+		if (!(obj instanceof Query)) {
+			return false;
+		}
+		if (this.queryString == null) return false;
+		if (this.engine == null) return false;
+
+		return this.queryString.equals(((Query) obj).queryString) && this.engine.equals(((Query) obj).engine);
+	}
+
+	@Override
+	public IQuery fixQuery() {
+		return new Query(queryString, this.engine);
+	}
+
+
 	/**
-	 * update the query
+	 * Gets the query string.
 	 * 
-	 * @param rawQuery
-	 * @return this
+	 * @return the query string
 	 */
-	public Query setQuery(String rawQuery);
-	
+	public final String getQueryString() {
+		return queryString;
+	}
+
+	@Override
+	public SearchEngine getSearchEngine() {
+		return engine;
+	}
+
 	/**
-	 * fix the query using sugar syntax rules
-	 * @return this
+	 * Checks whatever the query is empty (null, empty or contains only double quotes) or not.
+	 * @return true if empty otherwise false
 	 */
-	public Query fixQuery();
-	
-	public boolean equals(Query q);
+	public boolean isEmpty() {
+		return queryString == null || queryString.length() == 0 || "\"\"".equals(queryString);
+	}
+
+	@Override
+	public IQuery setQuery(String rawQuery) {
+		queryString = rawQuery;
+		return this;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		return queryString;
+	}
 }
Index: tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/Selection.java
===================================================================
--- tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/Selection.java	(revision 2131)
+++ tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/Selection.java	(revision 2132)
@@ -13,7 +13,7 @@
 	
 	public abstract int getNMatch() throws Exception;
 	
-	public abstract Query getQuery();
+	public abstract IQuery getQuery();
 
 	public abstract boolean isTargetUsed() throws Exception;
 
Index: tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/SearchEnginesManager.java
===================================================================
--- tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/SearchEnginesManager.java	(revision 2131)
+++ tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/SearchEnginesManager.java	(revision 2132)
@@ -31,6 +31,14 @@
 	public static SearchEngine getTIGERSearchEngine() {
 		return (SearchEngine) Toolbox.getEngineManager(EngineType.SEARCH).getEngine("TIGER");
 	}
+	
+	/**
+	 * 
+	 * @return
+	 */
+	public static SearchEngine getSearchEngine(String name) {
+		return (SearchEngine) Toolbox.getEngineManager(EngineType.SEARCH).getEngine(name);
+	}
 
 	@Override
 	public boolean fetchEngines() {
Index: tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/SearchEngine.java
===================================================================
--- tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/SearchEngine.java	(revision 2131)
+++ tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/SearchEngine.java	(revision 2132)
@@ -19,9 +19,9 @@
 		return start(new LogMonitor("Starting "+getName()));
 	}
 	
-	public abstract Selection query(CorpusBuild corpus, Query query, String name, boolean saveQuery) throws Exception;
+	public abstract Selection query(CorpusBuild corpus, IQuery query, String name, boolean saveQuery) throws Exception;
 	
-	public abstract Query newQuery();
+	public abstract IQuery newQuery();
 
 	/**
 	 * 
@@ -34,6 +34,14 @@
 		return this.getClass()+ " "+this.toString();
 	}
 	
+	public boolean equals(SearchEngine e) {
+		
+		if (e == null) return false;
+		if (this.getName() == null) return false;
+		
+		return this.getName().equals(e.getName());
+	}
+	
 	/**
 	 * 
 	 * @param match
Index: tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSSearchEngine.java
===================================================================
--- tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSSearchEngine.java	(revision 2131)
+++ tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSSearchEngine.java	(revision 2132)
@@ -11,7 +11,7 @@
 import org.txm.core.results.TXMResult;
 import org.txm.objects.CorpusBuild;
 import org.txm.objects.Match;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.core.SearchEngine;
 import org.txm.searchengine.core.SearchEngineProperty;
 import org.txm.searchengine.core.Selection;
@@ -59,7 +59,7 @@
 	}
 
 	@Override
-	public Selection query(CorpusBuild corpus, Query query, String name, boolean saveQuery) throws Exception {
+	public Selection query(CorpusBuild corpus, IQuery query, String name, boolean saveQuery) throws Exception {
 		
 		ArrayList<Element> elements = findAllInCorpus(0, URSCorpora.getCorpus(corpus), corpus, Unite.class, query.getQueryString());
 		ArrayList<URSMatch> matches = new ArrayList<URSMatch>();
@@ -251,7 +251,7 @@
 	}
 	
 	@Override
-	public Query newQuery() {
+	public IQuery newQuery() {
 		return new URSQuery();
 	}
 
Index: tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSQuery.java
===================================================================
--- tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSQuery.java	(revision 2131)
+++ tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSQuery.java	(revision 2132)
@@ -2,7 +2,7 @@
 
 import org.txm.Toolbox;
 import org.txm.core.engines.EngineType;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.core.SearchEngine;
 
 /**
@@ -12,7 +12,7 @@
  * @author mdecorde
  *
  */
-public class URSQuery implements Query {
+public class URSQuery implements IQuery {
 
 	String query = ""; //$NON-NLS-1$
 	
@@ -32,13 +32,13 @@
 	}
 
 	@Override
-	public Query setQuery(String rawQuery) {
+	public IQuery setQuery(String rawQuery) {
 		query = rawQuery;
 		return this;
 	}
 
 	@Override
-	public Query fixQuery() {
+	public IQuery fixQuery() {
 		return this;
 	}
 	
@@ -48,7 +48,7 @@
 	}
 	
 	@Override
-	public boolean equals(Query q) {
+	public boolean equals(IQuery q) {
 		return this.getClass().equals(q.getClass()) && this.getQueryString().equals(q.getQueryString());
 	}
 }
Index: tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSSelection.java
===================================================================
--- tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSSelection.java	(revision 2131)
+++ tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/search/URSSelection.java	(revision 2132)
@@ -4,15 +4,15 @@
 import java.util.List;
 
 import org.txm.objects.Match;
-import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.IQuery;
 import org.txm.searchengine.core.Selection;
 
 public class URSSelection extends Selection {
 
 	ArrayList<URSMatch> matches;
-	Query query;
+	IQuery query;
 	
-	public URSSelection(Query query, ArrayList<URSMatch> matches2) {
+	public URSSelection(IQuery query, ArrayList<URSMatch> matches2) {
 		this.query = query;
 		matches = matches2;
 	}
@@ -34,7 +34,7 @@
 	}
 
 	@Override
-	public Query getQuery() {
+	public IQuery getQuery() {
 		return query;
 	}
 
