Index: tmp/org.txm.searchengine.cqp.core/build.properties
===================================================================
--- tmp/org.txm.searchengine.cqp.core/build.properties	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/build.properties	(revision 449)
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+               META-INF/,\
+               .,\
+               icons/,\
+               res/

Property changes on: tmp/org.txm.searchengine.cqp.core/build.properties
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.core/plugin.xml
===================================================================
--- tmp/org.txm.searchengine.cqp.core/plugin.xml	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/plugin.xml	(revision 449)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension
+         point="org.txm.searchengine.core.SearchEngine">
+      <SearchEngine
+            class="org.txm.searchengine.cqp.CQPEngine">
+      </SearchEngine>
+   </extension>
+
+
+</plugin>

Property changes on: tmp/org.txm.searchengine.cqp.core/plugin.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.core/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- tmp/org.txm.searchengine.cqp.core/.settings/org.eclipse.jdt.core.prefs	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/.settings/org.eclipse.jdt.core.prefs	(revision 449)
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7

Property changes on: tmp/org.txm.searchengine.cqp.core/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.core/.classpath
===================================================================
--- tmp/org.txm.searchengine.cqp.core/.classpath	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/.classpath	(revision 449)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
+		<accessrules>
+			<accessrule kind="accessible" pattern="**"/>
+		</accessrules>
+	</classpathentry>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

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

Index: tmp/org.txm.searchengine.cqp.core/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.searchengine.cqp.core/META-INF/MANIFEST.MF	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/META-INF/MANIFEST.MF	(revision 449)
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: CQP
+Bundle-SymbolicName: org.txm.searchengine.cqp.core;singleton:=true
+Bundle-Version: 1.1.0.qualifier
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.txm.core;bundle-version="0.7.0",
+ org.txm.searchengine.core;bundle-version="1.0.0",
+ org.txm.libs.cqp;bundle-version="1.0.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ClassPath: res/,
+ .
+Bundle-Vendor: Textometrie.org
+Export-Package: org.txm.functions.diagnostic,
+ org.txm.functions.internal,
+ org.txm.functions.preview,
+ org.txm.functions.selection,
+ org.txm.functions.summary,
+ org.txm.importer.cwb,
+ org.txm.searchengine.cqp,
+ org.txm.searchengine.cqp.clientExceptions,
+ org.txm.searchengine.cqp.corpus,
+ org.txm.searchengine.cqp.corpus.query,
+ org.txm.searchengine.cqp.serverException,
+ org.txm.test

Property changes on: tmp/org.txm.searchengine.cqp.core/META-INF/MANIFEST.MF
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.core/.project
===================================================================
--- tmp/org.txm.searchengine.cqp.core/.project	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/.project	(revision 449)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.txm.searchengine.cqp.core</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

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

Index: tmp/org.txm.searchengine.cqp.core/src/cwbinstaller/Activator.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/cwbinstaller/Activator.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/cwbinstaller/Activator.java	(revision 449)
@@ -0,0 +1,61 @@
+package cwbinstaller;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "CQP"; //$NON-NLS-1$
+
+	// The shared instance
+	private static Activator plugin;
+	
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+		super.stop(context);
+	}
+
+	/**
+	 * Returns the shared instance
+	 *
+	 * @return the shared instance
+	 */
+	public static Activator getDefault() {
+		return plugin;
+	}
+
+	/**
+	 * Returns an image descriptor for the image file at the given
+	 * plug-in relative path
+	 *
+	 * @param path the path
+	 * @return the image descriptor
+	 */
+	public static ImageDescriptor getImageDescriptor(String path) {
+		return imageDescriptorFromPlugin(PLUGIN_ID, path);
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/cwbinstaller/commands/DoInstallStep.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/cwbinstaller/commands/DoInstallStep.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/cwbinstaller/commands/DoInstallStep.java	(revision 449)
@@ -0,0 +1,90 @@
+package cwbinstaller.commands;
+
+import java.io.File;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.util.Util;
+import org.osgi.framework.Version;
+import org.txm.core.preferences.TBXPreferences;
+import org.txm.core.preferences.TXMPreferences;
+import org.txm.utils.BundleUtils;
+import org.txm.utils.logger.Log;
+
+import cwbinstaller.CQPPreferences;
+
+public class DoInstallStep extends org.txm.rcp.commands.TxmCommand {
+	protected String name = "cwbbinaries.commands.DoInstallStep"; //$NON-NLS-1$
+	
+	@Override
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public void install() {	
+		
+	}
+	
+	@Override
+	public void preInstall() {	
+		String CQPFRAGMENT = "CQP."+System.getProperty("osgi.os");
+		
+		Log.info("CQP.DoInstallStep.install()");
+		String saved = TXMPreferences.getString(CQPPreferences.VERSION, CQPPreferences.PREFERENCES_NODE);
+		Version currentVersion = BundleUtils.getBundleVersion(CQPFRAGMENT); // the CQPFRAGMENT plugin contains the right version
+		
+		if (saved != null && saved.length() > 0) {
+			Version savedVersion = new Version(saved);
+			if (currentVersion.compareTo(savedVersion) <= 0) {
+				Log.info("No post-installation of CQP to do");
+				return; // nothing to do
+			}
+		}
+		System.out.println("Updating CWB preferences for CQP version="+currentVersion);
+		
+		String os = "win";
+		String ext = "";
+		if (Util.isWindows()) { //$NON-NLS-1$
+			if (System.getProperty("os.arch").contains("64")) { os = "win64"; } 
+			else { os = "win32"; }
+			ext = ".exe";
+		} else if (Util.isMac()) { //$NON-NLS-1$
+			os = "macosx";
+		} else {
+			os = "linux32";
+			if (System.getProperty("os.arch").contains("64")) 
+				os = "linux64";
+		}
+
+		File bundleDir = BundleUtils.getBundleFile(CQPFRAGMENT);
+		if (bundleDir == null) {
+			System.out.println("Error while retrieving TreeTaggerInstaller bundle directory.");
+			return;
+		}
+		File cwbDir = new File(bundleDir, "res");
+		File initFile = new File(cwbDir, "cqpserver.init");
+		File OSDir = new File(cwbDir, os);
+		File execFile = new File(OSDir, "cqpserver"+ext);
+
+		TXMPreferences.putString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PATH_TO_CQPLIB, OSDir.getAbsolutePath());
+		TXMPreferences.putString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PATH_TO_INIT_FILE, initFile.getAbsolutePath());
+		TXMPreferences.putString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PATH_TO_EXECUTABLE, execFile.getAbsolutePath());
+		if (!Util.isWindows()) { 
+			try {
+				Log.info("Setting execution file rights to: "+OSDir.getAbsolutePath());
+				Runtime.getRuntime().exec("chmod -R +x "+OSDir.getAbsolutePath()).waitFor();
+			} catch (Exception e) {
+				System.out.println("Error while setting execution file rights to: "+OSDir.getAbsolutePath());
+				e.printStackTrace();
+			}
+		}
+	
+		if (!execFile.canExecute()) {
+			System.out.println("File right setting error, cannot execute: "+execFile);
+		}
+		Log.warning("SearchEngine preferences set with: "+OSDir.getAbsolutePath()+ ", "+initFile.getAbsolutePath()+ " and "+execFile.getAbsolutePath());
+		TXMPreferences.putString(CQPPreferences.PREFERENCES_NODE, CQPPreferences.VERSION, currentVersion.toString());
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/cwbinstaller/CQPPreferences.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/cwbinstaller/CQPPreferences.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/cwbinstaller/CQPPreferences.java	(revision 449)
@@ -0,0 +1,18 @@
+package cwbinstaller;
+
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.osgi.service.prefs.Preferences;
+import org.txm.core.preferences.TXMPreferences;
+
+public class CQPPreferences extends TXMPreferences {
+
+	public static final String PREFERENCES_NODE = "cwbinstaller";
+	
+	public static final String VERSION = "cwbinstaller.commands.version";
+
+	@Override
+	public void initializeDefaultPreferences() {
+		Preferences preferences = DefaultScope.INSTANCE.getNode(PREFERENCES_NODE);
+		preferences.put(VERSION, "0.0");
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/test/package.html
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/test/package.html	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/test/package.html	(revision 449)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>First draft of tests for TXM</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.searchengine.cqp.core/src/org/txm/test/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/test/TestSubcorpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/test/TestSubcorpus.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/test/TestSubcorpus.java	(revision 449)
@@ -0,0 +1,71 @@
+package org.txm.test;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Arrays;
+
+import org.txm.searchengine.cqp.NetCqiClient;
+import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
+import org.txm.searchengine.cqp.corpus.Corpus;
+import org.txm.searchengine.cqp.corpus.CorpusManager;
+import org.txm.searchengine.cqp.corpus.Subcorpus;
+import org.txm.searchengine.cqp.corpus.query.Query;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
+
+public class TestSubcorpus {
+
+	public static String CORPUS = "DISCOURS"; //$NON-NLS-1$
+
+	public static boolean allTests(File outdir) {
+		TestSubcorpus tester = new TestSubcorpus();
+		return tester.test1(outdir) && tester.test2(outdir) && tester.test3(outdir);
+	}
+
+	public boolean test1(File outdir) {
+		try {
+			Corpus corpus = CorpusManager.getCorpusManager().getCorpus(CORPUS);
+			Subcorpus sub = corpus.createSubcorpus(new Query("\"je\" expand to p"), "JEP"); //$NON-NLS-1$ //$NON-NLS-2$
+
+			writePositions(sub, new File(outdir, TestSubcorpus.class.getName()+"_test1.csv")); //$NON-NLS-1$
+		} catch (Exception e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return false;
+		}
+		return true;
+	}
+
+	public boolean test2(File outdir) {
+		try {
+			Corpus corpus = CorpusManager.getCorpusManager().getCorpus(CORPUS);
+			Subcorpus sub = corpus.createSubcorpus(corpus.getStructuralUnit("text"), corpus.getStructuralUnit("text").getProperty("loc"), "De_Gaulle", "DG"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+
+			writePositions(sub, new File(outdir, TestSubcorpus.class.getName()+"_test2.csv")); //$NON-NLS-1$
+		} catch (Exception e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return false;
+		}
+		return true;
+	}
+
+	public boolean test3(File outdir) {
+		try {
+			Corpus corpus = CorpusManager.getCorpusManager().getCorpus(CORPUS);
+			Subcorpus sub = corpus.createSubcorpus(corpus.getStructuralUnit("text"), corpus.getStructuralUnit("text").getProperty("type"), Arrays.asList("Allocution radiotélévisée", "Conférence de presse"), "alloc+presse"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+
+			writePositions(sub, new File(outdir, TestSubcorpus.class.getName()+"_test3.csv")); //$NON-NLS-1$
+		} catch (Exception e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return false;
+		}
+		return true;
+	}
+
+	private void writePositions(Subcorpus sub, File outfile) throws UnexpectedAnswerException, IOException, CqiServerError {
+		int[] positions = CorpusManager.getCorpusManager().getCqiClient().dumpSubCorpus(sub.getQualifiedCqpId(), NetCqiClient.CQI_CONST_FIELD_MATCH, 0, sub.getNMatch());
+		PrintWriter writer = new PrintWriter(new FileWriter(outfile));
+		for(int i : positions) writer.println(i);
+		writer.close();
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/BuildCwbEncodeArgsFromWTC.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/BuildCwbEncodeArgsFromWTC.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/BuildCwbEncodeArgsFromWTC.java	(revision 449)
@@ -0,0 +1,216 @@
+// 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: 2013-08-29 14:23:55 +0200 (Thu, 29 Aug 2013) $
+// $LastChangedRevision: 2519 $
+// $LastChangedBy: nilskredens $ 
+//
+package org.txm.importer.cwb;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+
+import org.txm.core.messages.TXMCoreMessages;
+
+// TODO: Auto-generated Javadoc
+/**
+ * build the sAttributes and pAttributs List from an xmlfile pAttributes
+ * (attributes of tei:w tags) and the sAttributes (attributes + max inclusion of
+ * tags).
+ *
+ * @author mdecorde
+ */
+public class BuildCwbEncodeArgsFromWTC {
+
+	/** The stack. */
+	LinkedList<String> stack = new LinkedList<String>();
+
+	/** The tagcount. */
+	HashMap<String, Integer> tagcount = new HashMap<String, Integer>();
+
+	/** The tagmax. */
+	HashMap<String, Integer> tagmax = new HashMap<String, Integer>();
+
+	/** The tagattrs. */
+	HashMap<String, HashSet<String>> tagattrs = new HashMap<String, HashSet<String>>();
+	int nWordProps = 0;
+	/**
+	 * process !!!.
+	 *
+	 * @param wtcfile the xmlfile
+	 * @param wordstag the wordstag
+	 * @return true, if successful
+	 * @throws XMLStreamException the xML stream exception
+	 * @throws FactoryConfigurationError the factory configuration error
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public boolean process(File wtcfile)
+			throws XMLStreamException, FactoryConfigurationError, IOException {
+		if (wtcfile == null || !wtcfile.exists()) {
+			System.out.println(TXMCoreMessages.bind(TXMCoreMessages.BuildCwbEncodeArgs_0, wtcfile));
+			return false;
+		}
+
+		BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(wtcfile), "UTF-8"));
+
+		String line = reader.readLine();
+		String localname;
+		
+		
+		Pattern p = Pattern.compile("(([^= ]+)=\"([^\"]+)\")");
+		//for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {
+		for(; line != null ; line = reader.readLine()) {
+
+			if (line.startsWith("</") && line.endsWith(">")) { // END_ELEMENT
+				int idx = line.indexOf(" ");
+				if (idx == -1) idx = line.indexOf(">");
+				localname = line.substring(2, idx);
+
+				if (stack.size() > 0) {
+					stack.pop();
+					int count = tagcount.get(localname);
+					count--;
+					tagcount.put(localname, count);// decrement the
+					// recursion counter of the tag
+				}
+
+			} else if (line.startsWith("<") && line.endsWith("/>")) { // EMPTY_ELEMENT
+				// ignore milestones
+			} else if (line.startsWith("<") && line.endsWith(">")) { // START_ELEMENT
+				int idx = line.indexOf(" ");
+				if (idx == -1) idx = line.indexOf(">"); // no attributes
+				localname = line.substring(1, idx);
+
+				stack.push(localname);
+
+				if (!tagattrs.containsKey(localname))// initialize
+					// HashMaps
+				{
+					tagattrs.put(localname, new HashSet<String>());
+					tagcount.put(localname, 0);
+					tagmax.put(localname, 0);
+				}
+
+				Matcher m = p.matcher(line);
+				while (m.find()) {
+					if (m.groupCount() == 3) {
+						tagattrs.get(localname).add(m.group(2));
+					}
+				}
+
+				int count = tagcount.get(localname);
+				count++;
+				tagcount.put(localname, count);// increment the
+				// recursion counter of the tag
+				int max = tagmax.get(localname);
+				if (max < count)
+					tagmax.put(localname, count);// update max
+				// recursion of the tag
+
+			} else { // WORD LINE
+				if (nWordProps == 0) {
+					//System.out.println("Line: "+line);
+					String[] split = line.split("\t");
+					nWordProps = split.length;
+					//System.out.println("nprops: "+nWordProps);
+				}
+				
+			}
+		} // end while
+		reader.close();
+		return true;
+	}
+
+	/**
+	 * Gets the p attributes.
+	 *
+	 * @return the p attributes
+	 */
+	public Collection<String> getPAttributes() {
+		ArrayList<String> props = new ArrayList<String>();
+		for( int i = 1 ; i < nWordProps ; i++) { // don't count the "word" property
+			props.add("p"+i);
+		}
+		return props;
+	}
+
+	/**
+	 * Gets the s attributes.
+	 *
+	 * @return the s attributes
+	 */
+	public Collection<String> getSAttributes() {
+		ArrayList<String> rez = new ArrayList<String>();
+
+		for (String tag : tagattrs.keySet()) {
+			String s = tag.toLowerCase();
+			s += ":"; //$NON-NLS-1$
+
+			if (tagmax.get(tag) >= 0)
+				s += "" + (tagmax.get(tag) - 1); //$NON-NLS-1$
+
+			for (String attr : tagattrs.get(tag))
+				s += "+" + attr.toLowerCase(); //$NON-NLS-1$
+			rez.add(s);
+		}
+		return rez;
+	}
+
+	/**
+	 * The main method.
+	 *
+	 * @param args the arguments
+	 */
+	public static void main(String[] args) {
+		try {
+			BuildCwbEncodeArgsFromWTC argsgetter = new BuildCwbEncodeArgsFromWTC();
+			argsgetter.process(new File(
+					"/home/mdecorde/xml/wtc/discours.wtc")); //$NON-NLS-1$
+
+			System.out.println("pAttributes : " + argsgetter.getPAttributes()); //$NON-NLS-1$
+			System.out.println("sAttributes : " + argsgetter.getSAttributes()); //$NON-NLS-1$
+		} catch (XMLStreamException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} catch (FactoryConfigurationError e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbEncode.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbEncode.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbEncode.java	(revision 449)
@@ -0,0 +1,332 @@
+// 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: 2016-05-30 16:02:59 +0200 (Mon, 30 May 2016) $
+// $LastChangedRevision: 3220 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.importer.cwb;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.osgi.util.NLS;
+import org.txm.Toolbox;
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.core.preferences.TBXPreferences;
+import org.txm.searchengine.cqp.clientExceptions.ServerNotFoundException;
+import org.txm.stat.utils.ConsoleProgressBar;
+import org.txm.utils.OSDetector;
+import org.txm.utils.io.IOUtils;
+
+// TODO: Auto-generated Javadoc
+/**
+ * This class aims at handling a CQi server process. It is not a CQi server per
+ * se.
+ * 
+ * @author Adrien Yepdieu, mdecorde
+ */
+
+public class CwbEncode extends CwbProcess {
+	/**
+	 * Instantiates a new CQi server.
+	 */
+	public CwbEncode() {
+		super("cwb-encode"); //$NON-NLS-1$
+	}
+
+	/**
+	 * Instantiates a new cwb encode.
+	 *
+	 * @param name the name
+	 */
+	public CwbEncode(String name) {
+		super(name);
+	}
+
+	/**
+	 * * Instantiates a new CQi server.
+	 *
+	 * @param pathToExecutable the path to the executable
+	 * @param pathToData the path to data
+	 * @param inputFile the input file
+	 * @param pathToRegistry the path to the registry
+	 * @param pAttributes the positional attribute
+	 * @param sAttributes the structural atribute
+	 * @return true, if successful
+	 * @throws ServerNotFoundException the server not found exception
+	 * @throws IOException 
+	 * @throws InterruptedException 
+	 */
+	public boolean run(String pathToExecutable, String pathToData,
+			List<File> inputFiles, String pathToRegistry, String[] pAttributes,
+			String[] sAttributes) throws ServerNotFoundException, InterruptedException, IOException {
+		boolean ret = run(pathToExecutable, pathToData, inputFiles,
+				pathToRegistry, pAttributes, sAttributes, false);
+
+		return ret;
+	}
+
+	/**
+	 * * Instantiates a new CQi server.
+	 *
+	 * @param pathToExecutable the path to the executable
+	 * @param pathToData the path to data
+	 * @param inputFile the input file
+	 * @param pathToRegistry the path to the registry
+	 * @param pAttributes the positional attribute
+	 * @param sAttributes the structural atribute
+	 * @return true, if successful
+	 * @throws ServerNotFoundException the server not found exception
+	 * @throws IOException 
+	 * @throws InterruptedException 
+	 */
+	public boolean run(String pathToExecutable, String pathToData,
+			String inputFile, String pathToRegistry, String[] pAttributes,
+			String[] sAttributes) throws ServerNotFoundException, InterruptedException, IOException {
+		boolean ret = run(pathToExecutable, pathToData, inputFile,
+				pathToRegistry, pAttributes, sAttributes, false);
+
+		return ret;
+	}
+
+	/*
+	 * delete all files and directory of the given path
+	 */
+	/**
+	 * Delete dir.
+	 *
+	 * @param dir the dir
+	 * @return true, if successful
+	 */
+	public static boolean deleteDir(File dir) {
+		if (dir.isDirectory()) {
+			String[] children = dir.list();
+			for (int i = 0; i < children.length; i++) {
+				boolean success = deleteDir(new File(dir, children[i]));
+				if (!success) {
+					return false;
+				}
+			}
+		}
+		// The directory is now empty so delete it
+		return dir.delete();
+	}
+
+	public boolean run(String pathToExecutable, String pathToData,
+			String inputFile, String pathToRegistry, String[] pAttributes,
+			String[] sAttributes, boolean monitorOutput)
+					throws ServerNotFoundException, InterruptedException, IOException {
+
+		List<File> inputFiles = Arrays.asList(new File(inputFile));
+
+		return run(pathToExecutable, pathToData, inputFiles, pathToRegistry, pAttributes, sAttributes, monitorOutput);
+	}
+	/**
+	 * execute cwb-encode.
+	 *
+	 * @param pathToExecutable the path to the executable of cwb-encode
+	 * @param pathToData the path to cwb indexes
+	 * @param inputFile the input file
+	 * @param pathToRegistry the path to registry
+	 * @param pAttributes the attributes
+	 * @param sAttributes the s attributes
+	 * @param monitorOutput the monitor output
+	 * @return true, if successful
+	 * @throws ServerNotFoundException the server not found exception
+	 * @throws IOException 
+	 * @throws InterruptedException 
+	 */
+	public boolean run(String pathToExecutable, String pathToData,
+			List<File> inputFiles, String pathToRegistry, String[] pAttributes,
+			String[] sAttributes, boolean monitorOutput)
+					throws ServerNotFoundException, InterruptedException, IOException {
+		File data = new File(pathToData);
+		deleteDir(data);
+		data.mkdirs();
+
+		/*
+		 * if (System.getProperty("os.name").contains("Win")) { pathToExecutable
+		 * = "\""+pathToExecutable+"\""; pathToData = "\""+pathToData+"\"";
+		 * inputFile = "\""+inputFile+"\""; pathToRegistry =
+		 * "\""+pathToRegistry+"\""; }
+		 */
+
+		// Warning !! for WINDOWS ONLY the "" value does not work with the ProcessBuilder we must set the value to "\"\""
+		String empty_value_code = Toolbox.getParam(TBXPreferences.CQP_EMPTY_VALUE_CODE);
+		if (OSDetector.isFamilyWindows()) {
+			if (empty_value_code == null) empty_value_code = "\"\"";
+			empty_value_code = empty_value_code.trim();
+			if (empty_value_code.length() == 0) empty_value_code = "\"\"";
+		}
+
+		ArrayList<String> cmd = new ArrayList<String>();
+		if (inputFiles != null) { //read input from file
+			cmd.add(pathToExecutable);
+			cmd.add("-d");
+			cmd.add(new File(pathToData).getAbsolutePath()); //$NON-NLS-1$
+			cmd.add("-R"); //$NON-NLS-1$
+			cmd.add(new File(pathToRegistry).getAbsolutePath()); 
+			cmd.add("-U");
+			cmd.add(empty_value_code); //$NON-NLS-1$ //$NON-NLS-2$
+			cmd.add("-c"); //$NON-NLS-1$
+			cmd.add("utf8"); //$NON-NLS-1$ //$NON-NLS-2$
+
+			if (debug) {
+				cmd.add("-D"); //$NON-NLS-1$ 
+			}
+
+			for (File inputFile : inputFiles) { // append "-f path" parameters
+				cmd.add("-f"); //$NON-NLS-1$
+				cmd.add(inputFile.getAbsolutePath());
+			}
+		} else { //read input from stdin
+			String[] c = { pathToExecutable,
+					"-d", new File(pathToData).getAbsolutePath() //$NON-NLS-1$
+					, "-R", new File(pathToRegistry).getAbsolutePath() //$NON-NLS-1$
+					, "-U", empty_value_code //$NON-NLS-1$ //$NON-NLS-2$
+					, "-c", "utf8" //$NON-NLS-1$ //$NON-NLS-2$
+					//, "-x" //$NON-NLS-1$ 
+			}; 
+			cmd.addAll(Arrays.asList(c));
+		}
+
+		cmd.add("-xsB"); //$NON-NLS-1$ //$NON-NLS-2$
+		for (int i = 0; i < pAttributes.length; i++) {
+			cmd.add("-P"); //$NON-NLS-1$
+			// lower case pattributes
+			cmd.addAll(Arrays.asList(pAttributes[i].toLowerCase().split(" "))); //$NON-NLS-1$
+
+		}
+		for (int i = 0; i < sAttributes.length; i++) {
+			cmd.add("-S"); //$NON-NLS-1$
+			// lower case sattributes
+			cmd.addAll(Arrays.asList(sAttributes[i].toLowerCase().split(" "))); //$NON-NLS-1$
+		}
+		// String[] tmp = new String[cmd.length];
+		boolean waitForCWBEncodeToEnd = inputFiles != null;
+		return run(cmd, monitorOutput, waitForCWBEncodeToEnd) && new File(pathToRegistry).exists();
+	}
+
+	/**
+	 * Patch dir.
+	 *
+	 * @param directory the directory
+	 */
+	public static void patchDir(File directory) {
+		File bin = new File(directory, "bin"); //$NON-NLS-1$
+		File registry = new File(directory, "registry"); //$NON-NLS-1$
+		File corpora = new File(directory, "corpora"); //$NON-NLS-1$
+		if (!directory.exists()) {
+			System.err.println(TXMCoreMessages.CwbEncode_0 + directory);
+			return;
+		}
+		if (!bin.exists()) {
+			System.err.println(TXMCoreMessages.CwbEncode_21 + bin);
+			return;
+		}
+		if (!registry.exists()) {
+			System.err.println(TXMCoreMessages.CwbEncode_23 + registry);
+			return;
+		}
+		if (!corpora.exists()) {
+			System.err.println(TXMCoreMessages.CwbEncode_25 + corpora);
+			return;
+		}
+
+		for (File corpus : corpora.listFiles()) {
+			System.out.println(TXMCoreMessages.CwbEncode_27 + corpus.getName());
+			File data = new File(corpus, "data"); //$NON-NLS-1$
+
+			if (!data.exists()) {
+				System.err.println(TXMCoreMessages.CwbEncode_29 + data);
+				return;
+			}
+
+			String datapath = data.getAbsolutePath();
+			String regpath = registry.getAbsolutePath() + "/" + corpus.getName(); //$NON-NLS-1$
+			System.out.println(NLS.bind(TXMCoreMessages.CwbEncode_32, regpath, datapath));
+			try {
+				PatchCwbRegistry.patch(new File(regpath), new File(datapath));
+			} catch (IOException e) {
+				org.txm.utils.logger.Log.printStackTrace(e);
+			}
+		}
+	}
+
+	/**
+	 * concatenates WTC files into one master WTC file and wraps with the 'txmcorpus' structure. 
+	 * 
+	 * @param wtcFiles
+	 * @param allwtcFile
+	 * @return
+	 * @throws IOException
+	 */
+	public static boolean concat(ArrayList<File> wtcFiles, File allwtcFile) throws IOException {
+		PrintWriter output = IOUtils.getWriter(allwtcFile);
+		ConsoleProgressBar cpb = new ConsoleProgressBar(wtcFiles.size());
+
+		output.write("<txmcorpus lang=\"fr\">\n");
+		for (File wtcFile : wtcFiles) {
+			cpb.tick();
+			output.write(IOUtils.getText(wtcFile, "UTF-8"));
+			output.write("\n");
+			output.flush();
+		}
+		output.write("</txmcorpus>\n");
+		output.close();
+		return true;
+	}
+
+	/**
+	 * The main method.
+	 *
+	 * @param args the arguments
+	 */
+	public static void main(String[] args) {
+		// CwbEncode cwbEn = new CwbEncode();
+		// String[] pAttributes = {"pos", "col", "line", "id", "facs", "dipl"};
+		// String[] sAttributes = {"p:0+n", "q:1", "s:0+n+id"};
+		/*
+		 * String[] pAttributes = {"pos", "id", "col"}; String[] sAttributes =
+		 * {"p:0+n", "s:0+n"}; try {//cwbEn.run(
+		 * "/home/ayepdieu/textometrie/trunk/toolbox/src/main/C/cwb-3.0/utils/cwb-encode"
+		 * , "/home/txm/form/data/qgraalcm", "/home/txm/form/wtc/qgraalcm.wtc",
+		 * "/home/txm/form/registry/qgraalcm",pAttributes, sAttributes);
+		 * cwbEn.run(
+		 * "/home/ayepdieu/textometrie/trunk/toolbox/src/main/C/cwb-3.0/utils/cwb-encode"
+		 * , "/home/txm/form/data/qgraalfrmod",
+		 * "/home/txm/form/wtc/qgraalfrmod.wtc",
+		 * "/home/txm/form/registry/qgraalfrmod", pAttributes, sAttributes);
+		 * System.out.println(cwbEn.getErrorStream().toString()); } catch
+		 * (Exception ex) { System.out.println(ex);
+		 * System.out.println(cwbEn.getErrorStream()); }
+		 */
+		CwbEncode.patchDir(new File(
+				"C:/Documents and Settings/H/Mes documents/TXM/cwb")); //$NON-NLS-1$
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbProcess.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbProcess.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbProcess.java	(revision 449)
@@ -0,0 +1,254 @@
+// 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: 2016-05-30 16:02:59 +0200 (Mon, 30 May 2016) $
+// $LastChangedRevision: 3220 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.importer.cwb;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.core.preferences.TBXPreferences;
+import org.txm.searchengine.cqp.clientExceptions.ServerNotFoundException;
+import org.txm.utils.logger.Log;
+
+// TODO: Auto-generated Javadoc
+/**
+ * This class aims at handling a Cwb process. it uses a java ProcessBuilder
+ * 
+ * @author Adrien Yepdieu
+ */
+
+abstract class CwbProcess {
+
+	/** The debug. */
+	protected boolean debug = false;
+	/** The process. */
+	private Process process;
+
+	/** The name. */
+	private String name;
+
+	/**
+	 * * Instantiates a new Cwb process.
+	 *
+	 */
+	protected CwbProcess() {
+		name = "Cwb_Process"; //$NON-NLS-1$
+	}
+
+	/**
+	 * Instantiates a new cwb process.
+	 *
+	 * @param name the name
+	 */
+	protected CwbProcess(String name) {
+		this.name = name;
+	}
+
+	/**
+	 * Sets the debug.
+	 *
+	 * @param b the new debug
+	 */
+	public void setDebug(boolean b) {
+		this.debug = b;
+	}
+
+	/**
+	 * * run the command in cmd.
+	 *
+	 * @param cmd the cmd to be execute by the process
+	 * @param monitorOutput the monitor output
+	 * @return true, if successful
+	 * @throws ServerNotFoundException the server not found exception
+	 * @throws InterruptedException 
+	 * @throws IOException 
+	 */
+	protected boolean run(List<String> cmd, boolean monitorOutput, boolean waitFor)
+			throws ServerNotFoundException, InterruptedException, IOException {
+		Log.info(TXMCoreMessages.CwbProcess_1 + StringUtils.join(cmd, " ")); //$NON-NLS-1$ 
+		//System.out.println(StringUtils.join(cmd, " "));
+		for (String s : cmd) {
+			//System.out.println("s="+s);
+			if (s == null) {
+				System.out.println("ERROR null arg parameter: "+cmd);
+				return false;
+			}
+		}
+		ProcessBuilder processBuilder = new ProcessBuilder(cmd);
+		processBuilder.redirectErrorStream(true);
+		this.process = processBuilder.start();
+
+		final InputStream is = process.getInputStream();
+		new Thread() {
+			@Override
+			public void run() {
+				if (debug) System.out.println("Start logging "+name+" process...");
+				try {
+					InputStreamReader isr = new InputStreamReader(is);
+					BufferedReader br = new BufferedReader(isr);
+					String line;
+					while ((line = br.readLine()) != null) {
+						if (debug)
+							System.out.println(line);
+					}
+					isr.close();
+					if (debug) System.out.println("End of "+name+" process logs.");
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+		}.start();
+
+		if (waitFor) {
+			Log.warning("Waiting for end of process: "+name);
+			endProcess();
+		}
+		
+		return true;
+	}
+	
+	public void endProcess() throws InterruptedException {
+		this.process.waitFor();
+
+		int scount = 0;
+		do {
+			Thread.sleep(10);
+			scount++;
+		} while (isRunning() && scount <= 5);
+		this.process.destroy();
+	}
+
+	public OutputStream getOutPutStream() {
+		if (process == null)  return null;
+		return process.getOutputStream();
+	}
+
+	/**
+	 * Stop the cwb process.
+	 */
+	public void stop() {
+		Log.finest(TXMCoreMessages.CwbProcess_3 + name.toUpperCase());
+		this.process.destroy();
+		Log.finest(TXMCoreMessages.CwbProcess_4+name.toUpperCase());
+	}
+
+	/**
+	 * Checks if the process is running.
+	 * 
+	 * @return true, if is running
+	 */
+	public boolean isRunning() {
+		try {
+			if (this.process.exitValue() == 0)
+				return true;
+			// this throws an IllegalThreadStateException if the process is
+			// running
+			// The IllegalThreadStateException has not been thrown, the process
+			// is not running.
+			// false;
+			return false;
+		} catch (IllegalThreadStateException e) {
+			// The IllegalThreadStateException has been thrown, all good.
+			return true;
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#finalize()
+	 */
+	@Override
+	protected void finalize() throws Throwable {
+		try {
+			this.stop();
+		} finally {
+			super.finalize();
+		}
+	}
+
+	/**
+	 * Wait for.
+	 *
+	 * @return the int
+	 * @throws InterruptedException the interrupted exception
+	 */
+	public int waitFor() throws InterruptedException {
+		return this.process.waitFor();
+	}
+
+	/**
+	 * Gets the error stream.
+	 *
+	 * @return the error stream
+	 */
+	public InputStream getErrorStream() {
+		return process.getErrorStream();
+	}
+
+	/**
+	 * Gets the input stream.
+	 *
+	 * @return the input stream
+	 */
+	public InputStream getInputStream() {
+		return process.getInputStream();
+	}
+
+	/**
+	 * Gets the output stream.
+	 *
+	 * @return the output stream
+	 */
+	public OutputStream getOutputStream() {
+		return process.getOutputStream();
+	}
+
+	/**
+	 * Gets the CWB binaries location.
+	 *
+	 * @return the cWB location
+	 */
+	public static String getCWBLocation()
+	{
+		String cwbLoc = org.txm.Toolbox.getParam(TBXPreferences.CQI_SERVER_PATH_TO_CQPLIB)+File.separator;
+
+		if (!new File(cwbLoc).exists()) {
+			System.out.println(TXMCoreMessages.CwbProcess_5+cwbLoc);
+			return null;
+		}
+
+		return cwbLoc;
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/package.html
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/package.html	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/package.html	(revision 449)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>CWB utils. Wraps cwb-encode and cwb-makeall</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbDecode.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbDecode.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbDecode.java	(revision 449)
@@ -0,0 +1,598 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.importer.cwb;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.text.DateFormat;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+
+// Decode CWB indexes
+/**
+ * The Class CwbDecode.
+ */
+public class CwbDecode {
+
+	/** The binpath. */
+	String binpath = "";
+
+	/**
+	 * Instantiates a new cwb decode.
+	 *
+	 * @param binpath the binpath
+	 */
+	public CwbDecode(String binpath) {
+		this.binpath = binpath;
+	}
+
+	/** The version. */
+	String version = "0.0.0";
+
+	/** The desc. */
+	String desc = "Decode CWB indexes";
+
+	/** The debug. */
+	boolean debug = false;
+
+	/**
+	 * Debug.
+	 *
+	 * @param b the b
+	 */
+	public void debug(boolean b) {
+		debug = b;
+	};
+
+	// Lisp output mode
+
+	/** The is l. */
+	private Boolean isL = false;
+
+	/**
+	 * Sets the l.
+	 */
+	public void setL() {
+		this.isL = true;
+	}
+
+	/**
+	 * Unset l.
+	 */
+	public void unsetL() {
+		this.isL = false;
+	}
+
+	// concordance line ('horizonta'l) output mode
+
+	/** The is h. */
+	private Boolean isH = false;
+
+	/**
+	 * Sets the h.
+	 */
+	public void setH() {
+		this.isH = true;
+	}
+
+	/**
+	 * Unset h.
+	 */
+	public void unsetH() {
+		this.isH = false;
+	}
+
+	// compact output mode (suitable for encode)
+
+	/** The is c. */
+	private Boolean isC = false;
+
+	/**
+	 * Sets the c.
+	 */
+	public void setC() {
+		this.isC = true;
+	}
+
+	/**
+	 * Unset c.
+	 */
+	public void unsetC() {
+		this.isC = false;
+	}
+
+	// XML-compatible compact output (for {encode -x ...}))
+
+	/** The is cx. */
+	private Boolean isCx = false;
+
+	/**
+	 * Sets the cx.
+	 */
+	public void setCx() {
+		this.isCx = true;
+	}
+
+	/**
+	 * Unset cx.
+	 */
+	public void unsetCx() {
+		this.isCx = false;
+	}
+
+	// XML output mode
+
+	/** The is x. */
+	private Boolean isX = false;
+
+	/**
+	 * Sets the x.
+	 */
+	public void setX() {
+		this.isX = true;
+	}
+
+	/**
+	 * Unset x.
+	 */
+	public void unsetX() {
+		this.isX = false;
+	}
+
+	// show corpus position ('numbers')
+
+	/** The isn. */
+	private Boolean isn = false;
+
+	/**
+	 * Setn.
+	 */
+	public void setn() {
+		this.isn = true;
+	}
+
+	/**
+	 * Unsetn.
+	 */
+	public void unsetn() {
+		this.isn = false;
+	}
+
+	// first token to print (at corpus position {n})
+
+	/** The iss. */
+	private Boolean iss = false;
+
+	/** The s. */
+	private int s;
+
+	/**
+	 * Sets the s.
+	 *
+	 * @param arg the new s
+	 */
+	public void sets(int arg) {
+		this.iss = true;
+		this.s = arg;
+	}
+
+	/**
+	 * Unsets.
+	 */
+	public void unsets() {
+		this.iss = false;
+	}
+
+	// last token to print (at corpus position {n})
+
+	/** The ise. */
+	private Boolean ise = false;
+
+	/** The e. */
+	private int e;
+
+	/**
+	 * Sets the e.
+	 *
+	 * @param arg the new e
+	 */
+	public void sete(int arg) {
+		this.ise = true;
+		this.e = arg;
+	}
+
+	/**
+	 * Unsete.
+	 */
+	public void unsete() {
+		this.ise = false;
+	}
+
+	// set registry directory
+
+	/** The isr. */
+	private Boolean isr = false;
+
+	/** The r. */
+	private String r;
+
+	/**
+	 * Sets the r.
+	 *
+	 * @param arg the new r
+	 */
+	public void setr(String arg) {
+		this.isr = true;
+		this.r = arg;
+	}
+
+	/**
+	 * Unsetr.
+	 */
+	public void unsetr() {
+		this.isr = false;
+	}
+
+	// matchlist mode (input from stdin)
+
+	/** The isp. */
+	private Boolean isp = false;
+
+	/**
+	 * Setp.
+	 */
+	public void setp() {
+		this.isp = true;
+	}
+
+	/**
+	 * Unsetp.
+	 */
+	public void unsetp() {
+		this.isp = false;
+	}
+
+	// matchlist mode (input from {file})
+
+	/** The isf. */
+	private Boolean isf = false;
+
+	/** The f. */
+	private String f;
+
+	/**
+	 * Sets the f.
+	 *
+	 * @param arg the new f
+	 */
+	public void setf(String arg) {
+		this.isf = true;
+		this.f = arg;
+	}
+
+	/**
+	 * Unsetf.
+	 */
+	public void unsetf() {
+		this.isf = false;
+	}
+
+	// this help page
+
+	/** The ish. */
+	private Boolean ish = false;
+
+	/**
+	 * Seth.
+	 */
+	public void seth() {
+		this.ish = true;
+	}
+
+	/**
+	 * Unseth.
+	 */
+	public void unseth() {
+		this.ish = false;
+	}
+
+	// print p-attribute {att}
+
+	/** The is p. */
+	private Boolean isP = false;
+
+	/** The P. */
+	private List<String> P;
+
+	/**
+	 * Sets the p.
+	 *
+	 * @param arg the new p
+	 */
+	public void setP(List<String> arg) {
+		this.isP = true;
+		this.P = arg;
+	}
+
+	/**
+	 * Unset p.
+	 */
+	public void unsetP() {
+		this.isP = false;
+	}
+
+	// print s-attribute {att} (possibly including annotations)
+
+	/** The is s. */
+	private Boolean isS = false;
+
+	/** The S. */
+	private List<String> S;
+
+	/**
+	 * Sets the s.
+	 *
+	 * @param arg the new s
+	 */
+	public void setS(List<String> arg) {
+		this.isS = true;
+		this.S = arg;
+	}
+
+	/**
+	 * Unset s.
+	 */
+	public void unsetS() {
+		this.isS = false;
+	}
+
+	// show s-attribute annotation for each range in matchlist mode
+
+	/** The is v. */
+	private Boolean isV = false;
+
+	/** The V. */
+	private List<String> V;
+
+	/**
+	 * Sets the v.
+	 *
+	 * @param arg the new v
+	 */
+	public void setV(List<String> arg) {
+		this.isV = true;
+		this.V = arg;
+	}
+
+	/**
+	 * Unset v.
+	 */
+	public void unsetV() {
+		this.isV = false;
+	}
+
+	// print alignment attribute {att}
+
+	/** The is a. */
+	private Boolean isA = false;
+
+	/** The A. */
+	private List<String> A;
+
+	/**
+	 * Sets the a.
+	 *
+	 * @param arg the new a
+	 */
+	public void setA(List<String> arg) {
+		this.isA = true;
+		this.A = arg;
+	}
+
+	/**
+	 * Unset a.
+	 */
+	public void unsetA() {
+		this.isA = false;
+	}
+
+	// print all p-attributes and s-attributes
+
+	/** The is all. */
+	private Boolean isALL = false;
+
+	/**
+	 * Sets the all.
+	 */
+	public void setALL() {
+		this.isALL = true;
+	}
+
+	/**
+	 * Unset all.
+	 */
+	public void unsetALL() {
+		this.isALL = false;
+	}
+
+	// expand ranges to full {att} region (matchlist mode)
+
+	/** The isc. */
+	private Boolean isc = false;
+
+	/** The c. */
+	private String c;
+
+	/**
+	 * Sets the c.
+	 *
+	 * @param arg the new c
+	 */
+	public void setc(String arg) {
+		this.isc = true;
+		this.c = arg;
+	}
+
+	/**
+	 * Unsetc.
+	 */
+	public void unsetc() {
+		this.isc = false;
+	}
+
+	String[] options;
+	public void setAdditionalOptions(String[] options) {
+		this.options = options;
+	}
+
+	/**
+	 * Cwbdecode.
+	 *
+	 * @param corpus the corpus
+	 */
+	public void cwbdecode(String corpus) throws IOException
+	// arg : corpus name
+	{
+		ArrayList<String> args = new ArrayList<String>();
+		if(System.getProperty("os.name").contains("Windows")) {
+			args.add(binpath + "cwb-decode.exe");	
+		} else {
+			args.add(binpath + "cwb-decode");
+		}
+		if (isL)
+			args.add("-L");
+		if (isH)
+			args.add("-H");
+		if (isC)
+			args.add("-C");
+		if (isCx)
+			args.add("-Cx");
+		if (isX)
+			args.add("-X");
+		if (isn)
+			args.add("-n");
+		if (iss) {
+			args.add("-s");
+			args.add("" + s);
+		}
+		if (ise) {
+			args.add("-e");
+			args.add("" + e);
+		}
+		if (isr) {
+			args.add("-r");
+			args.add("" + r);
+		}
+		if (isp)
+			args.add("-p");
+		if (isf) {
+			args.add("-f");
+			args.add("" + f);
+		}
+		args.add("" + corpus);
+		if (ish)
+			args.add("-h");
+		if (isP)
+			for (int c = 0; c < P.size(); c++) {
+				args.add("-P");
+				args.add("" + P.get(c));
+			}
+		if (isS)
+			for (int c = 0; c < S.size(); c++) {
+				args.add("-S");
+				args.add("" + S.get(c));
+			}
+		if (isV)
+			for (int c = 0; c < V.size(); c++) {
+				args.add("-V");
+				args.add("" + V.get(c));
+			}
+		if (isA)
+			for (int c = 0; c < A.size(); c++) {
+				args.add("-A");
+				args.add("" + A.get(c));
+			}
+		if (isALL)
+			args.add("-ALL");
+		if (isc) {
+			args.add("-c");
+			args.add("" + c);
+		}
+
+		if (options != null) {
+			for (String opt : options) {
+				args.add(opt);
+			}
+		}
+
+		ProcessBuilder pb = new ProcessBuilder(args);
+		pb.redirectErrorStream(false);
+		Process process = null;
+		try {
+			process = pb.start();
+		} catch (IOException e) {
+			System.err.println(e);
+		}
+		InputStream is = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(is);
+		BufferedReader br = new BufferedReader(isr);
+		String line;
+		while ((line = br.readLine()) != null) {
+			System.out.println(line);
+		}
+		int e = 0;
+		try {
+			e = process.waitFor();
+		} catch (Exception err) {
+		}
+		if (e != 0) {
+			System.err.println("Process exited abnormally with code "
+					+ e
+					+ " at "
+					+ DateFormat.getDateInstance(DateFormat.FULL, Locale.UK)
+					.format(new Date()));
+
+			for (int c = 0; c < args.size(); c++)
+				System.out.print("" + args.get(c) + " ");
+			System.out.println();
+		}
+	}
+
+	/**
+	 * The main method.
+	 *
+	 * @param args the arguments
+	 */
+	public static void main(String[] args) {
+		CwbDecode tt = new CwbDecode("");
+	}
+}
\ No newline at end of file

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/FixMilestoneDeclarations.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/FixMilestoneDeclarations.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/FixMilestoneDeclarations.java	(revision 449)
@@ -0,0 +1,122 @@
+package org.txm.importer.cwb;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+/**
+ * Remove milestone declarations and index files. Milestones are empty structures that cannot be used with CQL
+ * 
+ * @author mdecorde
+ *
+ */
+public class FixMilestoneDeclarations {
+	File registryFile;
+	File dataDirectory;
+	boolean debug = false;
+	
+	public static final String[] exts = { ".avs", ".avx", ".rng"};
+
+	public FixMilestoneDeclarations(File registryFile, File dataDirectory) {
+		this.registryFile = registryFile;
+		this.dataDirectory = dataDirectory;
+	}
+
+	
+	public boolean process() throws IOException {
+		if (!dataDirectory.exists()) return false;
+		if (!registryFile.exists()) return false;
+
+		// get structural units and their properties
+		ArrayList<String> structures = new ArrayList<String>();
+		HashMap<String, ArrayList<String>> structureAttributes = new HashMap<String, ArrayList<String>>();
+		BufferedReader reader = new BufferedReader(new FileReader(registryFile));
+		String line = reader.readLine();
+		String structure = "";
+		while (line != null) {
+
+			if (line.startsWith("STRUCTURE ")) {
+				if ( !line.contains("_")) {
+					structure = line.substring(10);
+					structures.add(structure);
+					structureAttributes.put(structure, new ArrayList<String>());
+				} else {
+					line = line.replaceAll("[ ]+# \\[annotations\\]", "");
+					structureAttributes.get(structure).add(line.substring(10));
+				}
+
+			}
+			line = reader.readLine();
+		}
+		reader.close();
+		if (debug) System.out.println("Structures: "+structures);
+
+		File[] files = dataDirectory.listFiles();
+		if (files == null) return false;
+
+		//removing empty data files
+		ArrayList<String> linesToRemove = new ArrayList<String>();
+		for (String s : structures) {
+			File f = new File(dataDirectory, s+".rng");
+
+			if (f.exists() && f.length() == 0) {
+				if (debug) System.out.println("Milestone detected : "+s);
+				f.delete();
+				linesToRemove.add(s);
+
+				if (debug) System.out.println("Removing files: "+structureAttributes.get(s));
+				for (String attribute : structureAttributes.get(s)) {
+					linesToRemove.add(attribute);
+					for (String ext : exts) {
+						new File(dataDirectory, attribute+ext).delete();
+					}
+				}
+				continue;
+			}
+
+			if (!f.exists()) {
+				if (debug) System.out.println("Structure "+s+" RNG file is missing: "+f);
+				linesToRemove.add(s);
+			}
+		}
+
+		// remove structure declarations
+		if (debug) System.out.println("Attributes to remove from registry files: "+linesToRemove);
+		reader = new BufferedReader(new FileReader(registryFile));
+		File registryFile_tmp = new File(registryFile.getAbsolutePath()+".tmp");
+		BufferedWriter writer = new BufferedWriter(new FileWriter(registryFile_tmp));
+		line = reader.readLine();
+		while (line != null) {
+			
+			if (line.startsWith("STRUCTURE ")) {
+				
+				structure = line.substring(10).replaceAll("[ ]+# \\[annotations\\]", "");
+				if (linesToRemove.contains(structure)) {
+					if (debug) System.out.println("Remove line: "+line);
+					// don't write attribute line
+				} else {
+					writer.write(line+"\n");
+				}
+			} else {
+				writer.write(line+"\n");
+			}
+			line = reader.readLine();
+		}
+		reader.close();
+		writer.close();
+
+		return (registryFile.delete() && registryFile_tmp.renameTo(registryFile));
+	}
+
+	public static void main(String args[]) throws IOException {
+		File registryFile = new File("/home/mdecorde/TXM/corpora/BAIP/registry/baip");
+		File dataDirectory = new File("/home/mdecorde/TXM/corpora/BAIP/data/BAIP");
+		FixMilestoneDeclarations fm = new FixMilestoneDeclarations(registryFile, dataDirectory);
+		System.out.println("Result: "+fm.process());
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/BuildAlignOut.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/BuildAlignOut.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/BuildAlignOut.java	(revision 449)
@@ -0,0 +1,95 @@
+package org.txm.importer.cwb;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+
+import org.txm.utils.io.IOUtils;
+/**
+ * Create the CWB "align.out" file usually created with cwb-align using 2 WTC files. The alignement structure and property is not checked. Only structure order is used.
+ * 
+ * @author mdecorde
+ *
+ */
+public class BuildAlignOut {
+	
+	File wtcFile1;
+	File wtcFile2;
+	
+	public BuildAlignOut(File wtcFile1, File wtcFile2) {
+		this.wtcFile1 = wtcFile1;
+		this.wtcFile2 = wtcFile2;
+	}
+	
+	public boolean process(File alignOutFile, String su, String sup) throws IOException {
+		
+		ArrayList<Integer> positions1 = getWordPositions(wtcFile1, su, sup);
+		ArrayList<Integer> positions2 = getWordPositions(wtcFile2, su, sup);
+		
+		if (positions1.size() != positions2.size()) {
+			System.out.println("Error: the number of segment differs. "+positions1.size()+" in "+wtcFile1+" and "+positions2.size()+" in "+wtcFile2);
+			return false;
+		}
+		
+		System.out.println("Writing "+alignOutFile.getName()+" with "+positions1.size()+" positions.");
+		String encoding = "UTF-8";
+		PrintWriter writer = IOUtils.getWriter(alignOutFile, encoding);
+		
+		String c1 = wtcFile1.getName().toLowerCase();
+		c1 = c1.substring(0, c1.length()-4);
+		String c2 = wtcFile2.getName().toLowerCase();
+		c2 = c2.substring(0, c2.length()-4);
+		
+		writer.println(c1+"\t"+su+"\t"+c2+"\t"+su);
+		for (int i = 0 ; i < positions1.size() ; i = i+2) {
+			writer.println(""+positions1.get(i)+"\t"+positions1.get(i+1)+"\t"+positions2.get(i)+"\t"+positions2.get(i+1)+"\t1:1\t42");
+		}
+		writer.close();
+		
+		return true;
+	}
+
+	private static ArrayList<Integer> getWordPositions(File wtcFile, String su,
+			String sup) throws IOException {
+		
+		BufferedReader reader = IOUtils.getReader(wtcFile);
+		int position_counter = 0;
+		ArrayList<Integer> positions1 = new ArrayList<Integer>();
+		
+		String pattern = " "+sup+"=\"";
+		String line = reader.readLine();
+		while (line != null) {
+			if (line.startsWith("<"+su) && line.contains(pattern)) {
+				// align structure !
+				positions1.add(position_counter);
+			} else if (line.startsWith("</"+su+">")) {
+				// align structure !
+				positions1.add(position_counter-1);
+			}  else if (line.startsWith("<")) {
+				// structure !
+			} else if (line.length() == 0) {
+				// empty line
+			} else { // word line
+				//System.out.println("WORD: "+line);
+				position_counter++;
+			}
+			line = reader.readLine();
+		}
+		return positions1;
+	}
+	
+	public static void main(String args[]) throws IOException {
+		
+//		PatchCwbRegistry.patchAlignment(new File("/home/mdecorde/TEMP/align/registry", "c1"), "c2");
+//		PatchCwbRegistry.patchAlignment(new File("/home/mdecorde/TEMP/align/registry", "c2"), "c1");
+		
+		File wtcFile1 = new File("/home/mdecorde/TXM/corpora/SAMPLE/wtc/SAMPLE_en0.wtc");
+		File wtcFile2 = new File("/home/mdecorde/TXM/corpora/SAMPLE/wtc/SAMPLE_fr3.wtc");
+		File alignOutFile = new File("/home/mdecorde/TXM/corpora/SAMPLE/align.out");
+		
+		BuildAlignOut bao = new BuildAlignOut(wtcFile1, wtcFile2);
+		System.out.println("Result: "+bao.process(alignOutFile, "seg", "id"));
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbMakeAll.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbMakeAll.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbMakeAll.java	(revision 449)
@@ -0,0 +1,122 @@
+// 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: 2016-05-26 17:42:36 +0200 (Thu, 26 May 2016) $
+// $LastChangedRevision: 3219 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.importer.cwb;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.txm.searchengine.cqp.clientExceptions.ServerNotFoundException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * This class aims at handling a Cwb Make All.
+ * 
+ * @author Adrien Yepdieu
+ */
+public class CwbMakeAll extends CwbProcess {
+
+	/**
+	 * Instantiates a new cwb make all.
+	 */
+	public CwbMakeAll() {
+		super("cwb-makeall"); //$NON-NLS-1$
+	}
+
+	/**
+	 * Instantiates a new cwb make all.
+	 *
+	 * @param name the name
+	 */
+	public CwbMakeAll(String name) {
+		super(name);
+	}
+
+	/**
+	 * * Instantiates a new Cwb Make All.
+	 *
+	 * @param pathToExecutable the path to the executable
+	 * @param corpusName the corpus name
+	 * @param pathToRegistry the path to the registry
+	 * @return true, if successful
+	 * @throws ServerNotFoundException the server not found exception
+	 * @throws IOException 
+	 * @throws InterruptedException 
+	 */
+	public boolean run(String pathToExecutable, String corpusName,
+			String pathToRegistry) throws ServerNotFoundException, InterruptedException, IOException {
+		return run(pathToExecutable, corpusName, pathToRegistry, false);
+	}
+
+	/**
+	 * execute cwb-makeall.
+	 *
+	 * @param pathToExecutable path to cwb-makeall executable
+	 * @param corpusName the corpus name you want to build
+	 * @param pathToRegistry path to the directory which contains the corpus registry file
+	 * @param monitorOutput show output messages or not
+	 * @return true, if successful
+	 * @throws ServerNotFoundException the server not found exception
+	 * @throws IOException 
+	 * @throws InterruptedException 
+	 */
+	public boolean run(String pathToExecutable, String corpusName,
+			String pathToRegistry, boolean monitorOutput)
+			throws ServerNotFoundException, InterruptedException, IOException {
+		if (System.getProperty("os.name").contains("Win")) //$NON-NLS-1$ //$NON-NLS-2$
+		{
+			pathToExecutable = "\"" + pathToExecutable + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+			pathToRegistry = "\"" + pathToRegistry + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+		}
+		ArrayList<String> cmd = new ArrayList<String>();
+		cmd.addAll(Arrays.asList(pathToExecutable,
+				"-r", pathToRegistry, "-V", corpusName.toUpperCase())); //$NON-NLS-1$ //$NON-NLS-2$
+		if (debug) {
+			cmd.add(1, "-D"); //$NON-NLS-1$ //$NON-NLS-2$
+		}
+		return run(cmd, monitorOutput, true); // always wait for cwb-makeall to end
+	}
+
+	/**
+	 * The main method.
+	 *
+	 * @param args the arguments
+	 */
+	public static void main(String[] args) {
+		CwbMakeAll cwbMa = new CwbMakeAll();
+		try {
+			// cwbMa.run("/home/ayepdieu/textometrie/trunk/toolbox/src/main/C/cwb-3.0/utils/cwb-makeall",
+			// "QGRAALCM", "/home/txm/form/registry");
+			cwbMa.run("/home/ayepdieu/textometrie/trunk/toolbox/src/main/C/cwb-3.0/utils/cwb-makeall", "QGRAALFRMOD", "/home/txm/form/registry"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			// System.out.println(cwbMa.getErrorStream().toString());
+		} catch (Exception ex) {
+			System.out.println(ex);
+			// System.out.println(cwbMa.getErrorStream());
+		}
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/PatchCwbRegistry.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/PatchCwbRegistry.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/PatchCwbRegistry.java	(revision 449)
@@ -0,0 +1,343 @@
+// 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: 2016-05-24 10:43:03 +0200 (Tue, 24 May 2016) $
+// $LastChangedRevision: 3216 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.importer.cwb;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.utils.logger.Log;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class PatchCwbRegistry.
+ */
+public class PatchCwbRegistry {
+	
+	/**
+	 * Patch.
+	 *
+	 * @param registryfile the file to patch
+	 * @param datadir the directory containing the cwb index
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static void patch(File registryfile, File datadir)
+			throws IOException {
+		//String corpus = registryfile.getName();
+		
+		// HOME INFO
+		File temp = File.createTempFile("temp", ".registry", registryfile.getParentFile()); //$NON-NLS-1$ //$NON-NLS-2$
+		
+		String encoding = "UTF-8"; //$NON-NLS-1$
+		//if (OSDetector.isFamilyWindows()) encoding = "ISO-8859-1"; //$NON-NLS-1$
+		BufferedReader reader = new BufferedReader(new InputStreamReader(
+				new FileInputStream(registryfile), encoding));
+		OutputStreamWriter writer = new OutputStreamWriter(
+				new FileOutputStream(temp), encoding);
+
+		String line = reader.readLine();
+		while (line != null) {
+			//System.out.println("LINE: "+line);
+			if (line.startsWith("HOME")) //$NON-NLS-1$
+				writer.write("HOME \"" + datadir + "\"\n"); //$NON-NLS-1$ //$NON-NLS-2$
+			else if (line.startsWith("INFO")) //$NON-NLS-1$
+				writer.write("INFO \"" + datadir + "/.info\"\n"); //$NON-NLS-1$ //$NON-NLS-2$
+			else
+				writer.write(line + "\n"); //$NON-NLS-1$
+			line = reader.readLine();
+		}
+		writer.close();
+		reader.close();
+		
+		registryfile.delete();
+		
+//		System.out.println("TMP file: "+temp);
+//		System.out.println("TMP file exists?: "+temp.exists());
+//		System.out.println("REG file exists?: "+registryfile.exists());
+		if (registryfile.exists()) {
+			System.out.println("ERROR: old registry path still exists. Result in "+temp);
+		} else {
+			temp.renameTo(registryfile);
+		}
+		
+//		System.out.println("TMP file exists?: "+temp.exists());
+//		System.out.println("REG file exists?: "+registryfile.exists());
+	}
+
+	/**
+	 * Change the encoding value.
+	 *
+	 * @param registryfile the registry file to patch
+	 * @param corpusEncoding the new encoding value
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static void patchEncoding(File registryfile, String corpusEncoding)
+			throws IOException {
+		String corpus = registryfile.getName();
+
+		// HOME INFO
+		File temp = File.createTempFile("temp", ".regsitry", registryfile.getParentFile()); //$NON-NLS-1$ //$NON-NLS-2$
+
+		String encoding = "UTF-8"; //$NON-NLS-1$
+		//if (OSDetector.isFamilyWindows()) encoding = "ISO-8859-1"; //$NON-NLS-1$
+		BufferedReader reader = new BufferedReader(new InputStreamReader(
+				new FileInputStream(registryfile), encoding));
+		OutputStreamWriter writer = new OutputStreamWriter(
+				new FileOutputStream(temp), encoding);
+
+		if (corpusEncoding.startsWith("ISO") || corpusEncoding.startsWith("iso")) { //$NON-NLS-1$ //$NON-NLS-2$
+			corpusEncoding = "latin" + corpusEncoding.substring(9);//remove iso-8859- //$NON-NLS-1$
+		}
+		corpusEncoding = corpusEncoding.toLowerCase();
+
+		Log.info(TXMCoreMessages.PatchCwbRegistry_2 + corpus
+				+ TXMCoreMessages.PatchCwbRegistry_23 + corpusEncoding);
+		String line = reader.readLine();
+		while (line != null) {
+			if (line.startsWith("##:: charset") || line.startsWith("charset")) { //$NON-NLS-1$ //$NON-NLS-2$
+				writer.write("charset = \"" + corpusEncoding + "\" # change if your corpus uses dif ferent charset : latin1, latin2 ... utf-8\n"); //$NON-NLS-1$ //$NON-NLS-2$
+			} else {
+				writer.write(line + "\n"); //$NON-NLS-1$
+			}
+			line = reader.readLine();
+		}
+		writer.close();
+		reader.close();
+		registryfile.delete();
+		temp.renameTo(registryfile);
+	}
+	
+	/**
+	 * Change the language value.
+	 *
+	 * @param registryfile the registry file to patch
+	 * @param corpusLanguage the new language value
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static void patchLanguage(File registryfile, String corpusLanguage)
+			throws IOException {
+		String corpus = registryfile.getName();
+
+		// HOME INFO
+		File temp = File.createTempFile("temp", ".regsitry", registryfile.getParentFile()); //$NON-NLS-1$ //$NON-NLS-2$
+
+		String encoding = "UTF-8"; //$NON-NLS-1$
+		//if (OSDetector.isFamilyWindows()) encoding = "ISO-8859-1"; //$NON-NLS-1$
+		BufferedReader reader = new BufferedReader(new InputStreamReader(
+				new FileInputStream(registryfile), encoding));
+		OutputStreamWriter writer = new OutputStreamWriter(
+				new FileOutputStream(temp), encoding);
+
+		corpusLanguage = corpusLanguage.toLowerCase();
+		Log.info(TXMCoreMessages.PatchCwbRegistry_34 + corpus
+				+ TXMCoreMessages.PatchCwbRegistry_35 + corpusLanguage);
+		String line = reader.readLine();
+		while (line != null) {
+			if (line.startsWith("##:: language") || line.startsWith("language")) { //$NON-NLS-1$ //$NON-NLS-2$
+				writer.write("language = \"" + corpusLanguage + "\" # insert ISO code for language (de, en, fr, ...)\n"); //$NON-NLS-1$ //$NON-NLS-2$
+			} else {
+				writer.write(line + "\n"); //$NON-NLS-1$
+			}
+			line = reader.readLine();
+		}
+		writer.close();
+		reader.close();
+		registryfile.delete();
+		temp.renameTo(registryfile);
+	}
+
+	/**
+	 * Add the ALIGNED <corpus> line to a registry file.
+	 *
+	 * @param registryfile the registry file to patch
+	 * @param targetcorpus the aligned corpus
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static boolean patchAlignment(File registryfile, String targetcorpus)
+			throws IOException {
+		targetcorpus = targetcorpus.toLowerCase();
+		String corpus = registryfile.getName();
+
+		if (!new File(registryfile.getParent(), targetcorpus).exists()) {
+			System.out.println(TXMCoreMessages.PatchCwbRegistry_3+" : "+new File(registryfile.getParent(), targetcorpus)); //$NON-NLS-1$
+			return false;
+		}
+		if (!registryfile.exists()) {
+			System.out.println(TXMCoreMessages.PatchCwbRegistry_13+registryfile.getAbsolutePath());
+			return false;
+		}
+		boolean alignmentwritten = false;
+		// HOME INFO
+		File temp = File.createTempFile("temp", ".registry", registryfile.getParentFile()); //$NON-NLS-1$ //$NON-NLS-2$
+
+		String encoding = "UTF-8"; //$NON-NLS-1$
+		//if (OSDetector.isFamilyWindows()) encoding = "ISO-8859-1"; //$NON-NLS-1$
+		BufferedReader reader = new BufferedReader(new InputStreamReader(
+				new FileInputStream(registryfile), encoding));
+		OutputStreamWriter writer = new OutputStreamWriter(
+				new FileOutputStream(temp), encoding);
+
+		Log.info(TXMCoreMessages.PatchCwbRegistry_4 + corpus
+				+ TXMCoreMessages.PatchCwbRegistry_5 + targetcorpus);
+		String line = reader.readLine();
+		while (line != null) {
+			if (line.startsWith("ALIGNED " + targetcorpus)) { //$NON-NLS-1$
+				alignmentwritten = true;
+				writer.write(line + "\n"); //$NON-NLS-1$
+			} else if (line.startsWith("# Yours sincerely, the Encode tool.")) { //$NON-NLS-1$
+				if (!alignmentwritten) {
+					writer.write("ALIGNED " + targetcorpus + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+					alignmentwritten = true;
+				}
+				writer.write("# Yours sincerely, the Encode tool."); //$NON-NLS-1$
+			} else {
+				writer.write(line + "\n"); //$NON-NLS-1$
+			}
+			line = reader.readLine();
+		}
+
+		writer.close();
+		reader.close();
+		return registryfile.delete() && temp.renameTo(registryfile);
+	}
+	
+	/**
+	 * Add the ALIGNED <corpus> line to a registry file.
+	 *
+	 * @param registryfile the registry file to patch
+	 * @param oldname the oldname
+	 * @param newname the newname
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static boolean patchAttribute(File registryfile, String oldname, String newname)
+			throws IOException {
+		
+		boolean found = false;
+		String datapath = ""; //$NON-NLS-1$
+		
+		if (!registryfile.exists()) {
+			Log.warning(TXMCoreMessages.PatchCwbRegistry_16);
+			return false;
+		}
+
+		// HOME INFO
+		File temp = File.createTempFile("temp", ".regsitry", registryfile.getParentFile()); //$NON-NLS-1$ //$NON-NLS-2$
+
+		String encoding = "UTF-8"; //$NON-NLS-1$
+		//if (OSDetector.isFamilyWindows()) encoding = "ISO-8859-1"; //$NON-NLS-1$
+		BufferedReader reader = new BufferedReader(new InputStreamReader(
+				new FileInputStream(registryfile), encoding));
+		OutputStreamWriter writer = new OutputStreamWriter(
+				new FileOutputStream(temp), encoding);
+
+		String line = reader.readLine();
+		while (line != null) {
+			if (line.startsWith("ATTRIBUTE "+oldname)) { //$NON-NLS-1$
+				writer.write("ATTRIBUTE "+newname+"\n"); //$NON-NLS-1$ //$NON-NLS-2$
+				found = true;
+			} else {
+				if (line.startsWith("HOME")) { //$NON-NLS-1$
+					datapath = line.substring(5);
+				}
+				writer.write(line + "\n"); //$NON-NLS-1$
+			}
+			line = reader.readLine();
+		}
+		
+		if (found && datapath.length() > 0) {
+			System.out.println("rename "+oldname+".* files to "+newname+".*"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			File datadir = new File(datapath);
+			if (datadir.exists()) {
+				for (File f : datadir.listFiles())
+					if (f.getName().startsWith(oldname+".")) //$NON-NLS-1$
+						f.renameTo(new File(f.getParent(), f.getName().replace(oldname+".", newname+"."))); //$NON-NLS-1$ //$NON-NLS-2$
+			} else {
+				System.out.println(TXMCoreMessages.PatchCwbRegistry_27+datadir +TXMCoreMessages.ValidateXml_2);
+				writer.close();
+				reader.close();
+				return false;
+			}
+		}
+		else
+		{
+			System.out.println(TXMCoreMessages.PatchCwbRegistry_28);
+			
+			if(!found)
+				System.out.println(oldname +TXMCoreMessages.PatchCwbRegistry_29+registryfile);
+			
+			if(!(datapath.length() > 0))
+				System.out.println(TXMCoreMessages.PatchCwbRegistry_27+oldname +TXMCoreMessages.PatchCwbRegistry_29+registryfile);
+			writer.close();
+			reader.close();
+			return false;
+		}
+		
+
+		writer.close();
+		reader.close();
+		registryfile.delete();
+		temp.renameTo(registryfile);
+		return true;
+	}
+
+	/**
+	 * The main method.
+	 *
+	 * @param args the arguments
+	 */
+	public static void main(String[] args) {
+		try {
+			/*
+		PatchCwbRegistry.patchEncoding(new File(
+									"~/TXM/corpora/tmxtest/registry/tmxen"), "utf-8"); //$NON-NLS-1$ //$NON-NLS-2$
+			PatchCwbRegistry.patchLanguage(new File(
+					"~/TXM/corpora/tmxtest/registry/tmxen"), "en"); //$NON-NLS-1$ //$NON-NLS-2$
+			PatchCwbRegistry.patchAlignment(new File(
+									"~/TXM/corpora/tmxtest/registry/tmxen"), "TMXFR"); //$NON-NLS-1$ //$NON-NLS-2$
+			*/
+			File registry = new File("/home/mdecorde/TXM/corpora/VOEUX/registry/voeux"); //$NON-NLS-1$
+			File data = new File("/home/mdecorde/TXM/corpora/VOEUX/data/VOEUX");
+			PatchCwbRegistry.patch(registry, data);
+//			PatchCwbRegistry.patchAttribute(registry, "word", "form"); //$NON-NLS-1$ //$NON-NLS-2$
+//			try {
+//				new CwbMakeAll().run("/usr/lib/TXM/cwb/bin/cwb-makeall", "lasla", registry.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
+//			} catch (Exception e) {
+//				// TODO Auto-generated catch block
+//				org.txm.utils.logger.Log.printStackTrace(e);
+//			}
+		} catch (IOException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/ReadRegistryFile.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/ReadRegistryFile.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/ReadRegistryFile.java	(revision 449)
@@ -0,0 +1,71 @@
+package org.txm.importer.cwb;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.txm.utils.io.IOUtils;
+
+public class ReadRegistryFile {
+	File registryFile;
+	ArrayList<String> pAttributes;
+	ArrayList<String> sAttributes;
+	HashMap<String, ArrayList<String>> sattrs;
+	
+	public ReadRegistryFile(File registryFile) {
+		this.registryFile = registryFile;
+		read();
+	}
+	
+	public void read() {
+		pAttributes = new ArrayList();
+		sAttributes = new ArrayList();
+		sattrs = new HashMap<String, ArrayList<String>>();
+		for (String line : IOUtils.getLines(registryFile, System.getProperty("file.encoding"))) {
+			line = line.trim(); // remove first tab
+
+			if (line.startsWith("ATTRIBUTE ")) {
+				line = line.substring(10);
+				pAttributes.add(line);
+			} else if (line.startsWith("STRUCTURE ")) {
+				line = line.substring(9);
+				line = line.replaceAll("\\#.*", "");
+				line = line.trim();
+				String[] split = line.split("_", 2);
+				//println split
+				if (split.length == 1) { // sattr decl
+					sattrs.put(split[0], new ArrayList<String>());
+				} else {
+					sattrs.get(split[0]).add(split[1]);
+				}
+			}
+		}
+		
+		for (String sattr : sattrs.keySet()) {
+			String tmp = ""+sattr+":0";
+			for (String attr : sattrs.get(sattr))
+				tmp += "+"+attr;
+			sAttributes.add(tmp);
+		}
+	}
+	
+	public ArrayList<String> getPAttributes() {
+		return pAttributes;
+	}
+	
+	public ArrayList<String> getSAttributes() {
+		return sAttributes;
+	}
+	
+	public HashMap<String, ArrayList<String>> getSAttributesMap() {
+		return sattrs;
+	}
+	
+	public static void main(String[] args) {
+		File registry = new File("/home/matt/xml/wtc/discours");
+		ReadRegistryFile reader = new ReadRegistryFile(registry);
+		System.out.println("pAttributes: "+reader.getPAttributes());
+		System.out.println("sAttributes Map: "+reader.getSAttributesMap());
+		System.out.println("sAttributes: "+reader.getSAttributes());
+	}
+}
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/BuildCwbEncodeArgsFromTEITXM.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/BuildCwbEncodeArgsFromTEITXM.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/BuildCwbEncodeArgsFromTEITXM.java	(revision 449)
@@ -0,0 +1,205 @@
+// 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: 2013-08-29 14:23:55 +0200 (jeu., 29 août 2013) $
+// $LastChangedRevision: 2519 $
+// $LastChangedBy: nilskredens $ 
+//
+package org.txm.importer.cwb;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+// TODO: Auto-generated Javadoc
+/**
+ * build the sAttributes and pAttributs List from an xmlfile pAttributes
+ * (attributes of tei:w tags) and the sAttributes (attributes + max inclusion of
+ * tags).
+ *
+ * @author mdecorde
+ */
+public class BuildCwbEncodeArgsFromTEITXM {
+	
+	/** The stack. */
+	LinkedList<String> stack = new LinkedList<String>();
+	
+	/** The tagcount. */
+	HashMap<String, Integer> tagcount = new HashMap<String, Integer>();
+	
+	/** The tagmax. */
+	HashMap<String, Integer> tagmax = new HashMap<String, Integer>();
+	
+	/** The tagattrs. */
+	HashMap<String, HashSet<String>> tagattrs = new HashMap<String, HashSet<String>>();
+	
+	/** The wattrs. */
+	HashSet<String> wattrs = new HashSet<String>();
+
+	/**
+	 * process !!!.
+	 *
+	 * @param xmlfile the xmlfile
+	 * @throws XMLStreamException the xML stream exception
+	 * @throws FactoryConfigurationError the factory configuration error
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public void process(File xmlfile) throws XMLStreamException,
+			FactoryConfigurationError, IOException {
+		URL u = xmlfile.toURI().toURL();
+		InputStream in = u.openStream();
+		XMLInputFactory factory = XMLInputFactory.newInstance();
+		XMLStreamReader parser = factory.createXMLStreamReader(in);
+
+		for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser
+				.next()) {
+			switch (event) {
+			case XMLStreamConstants.START_ELEMENT:
+				stack.push(parser.getLocalName());
+
+				if (!tagattrs.containsKey(parser.getLocalName()))// initialize
+																	// HashMaps
+				{
+					tagattrs.put(parser.getLocalName(), new HashSet<String>());
+					tagcount.put(parser.getLocalName(), 0);
+					tagmax.put(parser.getLocalName(), 0);
+				}
+
+				if (parser.getLocalName().matches("w"))//get w attrs //$NON-NLS-1$
+					for (int i = 0; i < parser.getAttributeCount(); i++) {
+						String att = parser.getAttributeLocalName(i);
+						wattrs.add(att);
+					}
+
+				if (parser.getLocalName().matches("interp"))//get w attrs //$NON-NLS-1$
+				{
+					String att = parser.getAttributeValue(null, "type"); //$NON-NLS-1$
+					wattrs.add(att.substring(1));
+				}
+				for (int i = 0; i < parser.getAttributeCount(); i++)// get tags
+																	// attrs
+				{
+					String att = parser.getAttributeLocalName(i);
+					tagattrs.get(parser.getLocalName()).add(att);
+				}
+
+				int count = tagcount.get(parser.getLocalName());
+				count++;
+				tagcount.put(parser.getLocalName(), count);// increment the
+															// recursion counter
+															// of the tag
+				int max = tagmax.get(parser.getLocalName());
+				if (max < count)
+					tagmax.put(parser.getLocalName(), count);// update max
+																// recursion of
+																// the tag
+				break;
+			case XMLStreamConstants.END_ELEMENT:
+				stack.pop();
+
+				count = tagcount.get(parser.getLocalName());
+				count--;
+				tagcount.put(parser.getLocalName(), count);// decrement the
+															// recursion counter
+															// of the tag
+				break;
+			case XMLStreamConstants.CHARACTERS:
+
+				break;
+			case XMLStreamConstants.CDATA:
+
+				break;
+			} // end switch
+		} // end while
+		tagattrs.remove("w");//we dont need to report the w tags :) //$NON-NLS-1$
+		tagmax.remove("w"); //$NON-NLS-1$
+		parser.close();
+	}
+
+	/**
+	 * Gets the p attributes.
+	 *
+	 * @return the p attributes
+	 */
+	public Collection<String> getPAttributes() {
+		return wattrs;
+	}
+
+	/**
+	 * Gets the s attributes.
+	 *
+	 * @return the s attributes
+	 */
+	public Collection<String> getSAttributes() {
+		ArrayList<String> rez = new ArrayList<String>();
+
+		for (String tag : tagattrs.keySet()) {
+			String s = tag;
+			if (tagmax.get(tag) > 1)
+				s += "" + tagmax.get(tag); //$NON-NLS-1$
+			if (tagattrs.get(tag).size() > 0)
+				s += ":"; //$NON-NLS-1$
+			for (String attr : tagattrs.get(tag))
+				s += "+" + attr; //$NON-NLS-1$
+			rez.add(s);
+		}
+		return rez;
+	}
+
+	/**
+	 * The main method.
+	 *
+	 * @param args the arguments
+	 */
+	public static void main(String[] args) {
+		try {
+			BuildCwbEncodeArgsFromTEITXM argsgetter = new BuildCwbEncodeArgsFromTEITXM();
+			argsgetter.process(new File(
+					"~/xml/rgaqcj/anainline/roland-p5.xml")); //$NON-NLS-1$
+
+			System.out.println("pAttributes : " + argsgetter.getPAttributes()); //$NON-NLS-1$
+			System.out.println("sAttributes : " + argsgetter.getSAttributes()); //$NON-NLS-1$
+		} catch (XMLStreamException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} catch (FactoryConfigurationError e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+}
\ No newline at end of file

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/BuildCwbEncodeArgs.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/BuildCwbEncodeArgs.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/BuildCwbEncodeArgs.java	(revision 449)
@@ -0,0 +1,241 @@
+// 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: 2013-08-29 14:23:55 +0200 (jeu., 29 août 2013) $
+// $LastChangedRevision: 2519 $
+// $LastChangedBy: nilskredens $ 
+//
+package org.txm.importer.cwb;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.txm.core.messages.TXMCoreMessages;
+
+// TODO: Auto-generated Javadoc
+/**
+ * build the sAttributes and pAttributs List from an xmlfile pAttributes
+ * (attributes of tei:w tags) and the sAttributes (attributes + max inclusion of
+ * tags).
+ *
+ * @author mdecorde
+ */
+public class BuildCwbEncodeArgs {
+
+	/** The stack. */
+	LinkedList<String> stack = new LinkedList<String>();
+
+	/** The tagcount. */
+	HashMap<String, Integer> tagcount = new HashMap<String, Integer>();
+
+	/** The tagmax. */
+	HashMap<String, Integer> tagmax = new HashMap<String, Integer>();
+
+	/** The tagattrs. */
+	HashMap<String, HashSet<String>> tagattrs = new HashMap<String, HashSet<String>>();
+
+	/** The wattrs. */
+	HashSet<String> wattrs = new HashSet<String>();
+
+	private String scanElem;
+
+	/**
+	 * process !!!.
+	 *
+	 * @param xmlfile the xmlfile
+	 * @param wordstag the wordstag
+	 * @return true, if successful
+	 * @throws XMLStreamException the xML stream exception
+	 * @throws FactoryConfigurationError the factory configuration error
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public boolean process(File xmlfile, ArrayList<String> wordstag)
+			throws XMLStreamException, FactoryConfigurationError, IOException {
+		if (xmlfile == null || !xmlfile.exists()) {
+			System.out.println(TXMCoreMessages.bind(TXMCoreMessages.BuildCwbEncodeArgs_0, xmlfile));
+			return false;
+		}
+		URL u = xmlfile.toURI().toURL();
+		InputStream in = u.openStream();
+		XMLInputFactory factory = XMLInputFactory.newInstance();
+		XMLStreamReader parser = factory.createXMLStreamReader(in);
+
+		gotoStartElement(parser);
+
+		for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser
+				.next()) {
+			switch (event) {
+			case XMLStreamConstants.START_ELEMENT:
+				stack.push(parser.getLocalName());
+
+				if (!tagattrs.containsKey(parser.getLocalName()))// initialize
+					// HashMaps
+				{
+					tagattrs.put(parser.getLocalName(), new HashSet<String>());
+					tagcount.put(parser.getLocalName(), 0);
+					tagmax.put(parser.getLocalName(), 0);
+				}
+
+				if (wordstag.contains(parser.getLocalName()))// get w attrs
+					for (int i = 0; i < parser.getAttributeCount(); i++) {
+						String att = parser.getAttributeLocalName(i);
+						wattrs.add(att);
+					}
+
+				for (int i = 0; i < parser.getAttributeCount(); i++)// get tags
+					// attrs
+				{
+					String att = parser.getAttributeLocalName(i);
+					tagattrs.get(parser.getLocalName()).add(att);
+				}
+
+				int count = tagcount.get(parser.getLocalName());
+				count++;
+				tagcount.put(parser.getLocalName(), count);// increment the
+				// recursion counter
+				// of the tag
+				int max = tagmax.get(parser.getLocalName());
+				if (max < count)
+					tagmax.put(parser.getLocalName(), count);// update max
+				// recursion of
+				// the tag
+				break;
+			case XMLStreamConstants.END_ELEMENT:
+				if (stack.size() > 0) {
+					stack.pop();
+					count = tagcount.get(parser.getLocalName());
+					count--;
+					tagcount.put(parser.getLocalName(), count);// decrement the
+					// recursion counter
+					// of the tag
+				}
+
+				break;
+			case XMLStreamConstants.CHARACTERS:
+
+				break;
+			case XMLStreamConstants.CDATA:
+
+				break;
+			} // end switch
+		} // end while
+		tagattrs.remove("w");//we dont need to report the w tags :) //$NON-NLS-1$
+		tagmax.remove("w"); //$NON-NLS-1$
+		parser.close();
+		in.close();
+		return true;
+	}
+
+	public void gotoStartElement(XMLStreamReader parser) throws XMLStreamException
+	{
+		if (this.scanElem == null) return;
+		for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser
+				.next()) {
+			switch (event) {
+			case XMLStreamConstants.START_ELEMENT:
+				if (parser.getLocalName() == scanElem)
+					return;
+			}
+		}
+	}
+
+	public void setElementToScan(String elem)
+	{
+		this.scanElem = elem;
+	}
+
+	/**
+	 * Gets the p attributes.
+	 *
+	 * @return the p attributes
+	 */
+	public Collection<String> getPAttributes() {
+		return wattrs;
+	}
+
+	/**
+	 * Gets the s attributes.
+	 *
+	 * @return the s attributes
+	 */
+	public Collection<String> getSAttributes() {
+		ArrayList<String> rez = new ArrayList<String>();
+
+		for (String tag : tagattrs.keySet()) {
+			String s = tag.toLowerCase();
+			s += ":"; //$NON-NLS-1$
+
+			if (tagmax.get(tag) >= 0)
+				s += "" + (tagmax.get(tag) - 1); //$NON-NLS-1$
+
+			for (String attr : tagattrs.get(tag))
+				s += "+" + attr.toLowerCase(); //$NON-NLS-1$
+					rez.add(s);
+		}
+		return rez;
+	}
+
+	/**
+	 * The main method.
+	 *
+	 * @param args the arguments
+	 */
+	public static void main(String[] args) {
+		try {
+			BuildCwbEncodeArgs argsgetter = new BuildCwbEncodeArgs();
+			ArrayList<String> wordstag = new ArrayList<String>();
+			String[] awords = { "M", "PC", "MC" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+			for (String s : awords) {
+				wordstag.add(s);
+			}
+			argsgetter.process(new File(
+					"~/xml/fleurs/src/fleursduMal-2.xml"), wordstag); //$NON-NLS-1$
+
+			System.out.println("pAttributes : " + argsgetter.getPAttributes()); //$NON-NLS-1$
+			System.out.println("sAttributes : " + argsgetter.getSAttributes()); //$NON-NLS-1$
+		} catch (XMLStreamException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} catch (FactoryConfigurationError e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbAlign.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbAlign.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbAlign.java	(revision 449)
@@ -0,0 +1,515 @@
+// 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: 2017-01-24 18:11:42 +0100 (Tue, 24 Jan 2017) $
+// $LastChangedRevision: 3400 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.importer.cwb;
+
+import java.util.Date;
+import java.util.Locale;
+import java.text.DateFormat;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+
+import org.txm.utils.logger.Log;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Align a corpus with an other Generated with ProcessBuilderBuilder 28/07/2010.
+ */
+public class CwbAlign {
+	
+	/** The binpath. */
+	String binpath = ""; //$NON-NLS-1$
+
+	/**
+	 * Instantiates a new cwb align.
+	 *
+	 * @param binpath the binpath
+	 */
+	public CwbAlign(String binpath) {
+		this.binpath = binpath;
+	}
+
+	/** The version. */
+	String version = "3.2"; //$NON-NLS-1$
+	
+	/** The desc. */
+	String desc = "Align a corpus with an other"; //$NON-NLS-1$
+	
+	/** The debug. */
+	boolean debug = false;
+
+	/**
+	 * Debug.
+	 *
+	 * @param b the b
+	 */
+	public void debug(boolean b) {
+		debug = b;
+	};
+
+	// use positional attribute [word]
+	/** The is p. */
+	private Boolean isP = false;
+	
+	/** The P. */
+	private String P;
+
+	/**
+	 * Sets the p.
+	 *
+	 * @param arg the new p
+	 */
+	public void setP(String arg) {
+		this.isP = true;
+		this.P = arg;
+	}
+
+	/**
+	 * Unset p.
+	 */
+	public void unsetP() {
+		this.isP = false;
+	}
+
+	// ordered prealignment
+	/** The is s. */
+	private Boolean isS = false;
+	
+	/** The S. */
+	private String S;
+
+	/**
+	 * Sets the s.
+	 *
+	 * @param arg the new s
+	 */
+	public void setS(String arg) {
+		this.isS = true;
+		this.S = arg;
+	}
+
+	/**
+	 * Unset s.
+	 */
+	public void unsetS() {
+		this.isS = false;
+	}
+
+	// ordered prealignment with annotations, ex : seg_id
+	/** The is v. */
+	private Boolean isV = false;
+	
+	/** The V. */
+	private String V;
+
+	/**
+	 * Sets the v.
+	 *
+	 * @param arg the new v
+	 */
+	public void setV(String arg) {
+		this.isV = true;
+		this.V = arg;
+	}
+
+	/**
+	 * Unset v.
+	 */
+	public void unsetV() {
+		this.isV = false;
+	}
+
+	// outfile file [out.align]
+	/** The iso. */
+	private Boolean iso = false;
+	
+	/** The o. */
+	private String o;
+
+	/**
+	 * Sets the o.
+	 *
+	 * @param arg the new o
+	 */
+	public void seto(String arg) {
+		this.iso = true;
+		this.o = arg;
+	}
+
+	/**
+	 * Unseto.
+	 */
+	public void unseto() {
+		this.iso = false;
+	}
+
+	// set 2:2 alignment split factor [1.2]
+	/** The iss. */
+	private Boolean iss = false;
+	
+	/** The s. */
+	private String s;
+
+	/**
+	 * Sets the s.
+	 *
+	 * @param arg the new s
+	 */
+	public void sets(String arg) {
+		this.iss = true;
+		this.s = arg;
+	}
+
+	/**
+	 * Unsets.
+	 */
+	public void unsets() {
+		this.iss = false;
+	}
+
+	// use best path search beam of width [50]
+	/** The isw. */
+	private Boolean isw = false;
+	
+	/** The w. */
+	private String w;
+
+	/**
+	 * Sets the w.
+	 *
+	 * @param arg the new w
+	 */
+	public void setw(String arg) {
+		this.isw = true;
+		this.w = arg;
+	}
+
+	/**
+	 * Unsetw.
+	 */
+	public void unsetw() {
+		this.isw = false;
+	}
+
+	// use registry directory
+	/** The isr. */
+	private Boolean isr = false;
+	
+	/** The r. */
+	private String r;
+
+	/**
+	 * Sets the r.
+	 *
+	 * @param arg the new r
+	 */
+	public void setr(String arg) {
+		this.isr = true;
+		this.r = arg;
+	}
+
+	/**
+	 * Unsetr.
+	 */
+	public void unsetr() {
+		this.isr = false;
+	}
+
+	// verbose mode
+	/** The isv. */
+	private Boolean isv = false;
+
+	/**
+	 * Setv.
+	 */
+	public void setv() {
+		this.isv = true;
+	}
+
+	/**
+	 * Unsetv.
+	 */
+	public void unsetv() {
+		this.isv = false;
+	}
+
+	// show help
+	/** The ish. */
+	private Boolean ish = false;
+
+	/**
+	 * Seth.
+	 */
+	public void seth() {
+		this.ish = true;
+	}
+
+	/**
+	 * Unseth.
+	 */
+	public void unseth() {
+		this.ish = false;
+	}
+
+	// create align file
+	/**
+	 * Cwbalign.
+	 *
+	 * @param source the source
+	 * @param target the target
+	 * @param sattrib the sattrib
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public void cwbalign(String source, String target, String sattrib)
+			throws IOException
+	// arg : source corpus identif ier
+	// arg : target corpus identif ier
+	// arg : the aligned structure, ex : seg
+	{
+		ArrayList<String> args = new ArrayList<String>();
+		args.add(binpath + "cwb-align"); //$NON-NLS-1$
+		if (isP) {
+			args.add("-P"); //$NON-NLS-1$
+			args.add("" + P); //$NON-NLS-1$
+		}
+		if (isS) {
+			args.add("-S"); //$NON-NLS-1$
+			args.add("" + S); //$NON-NLS-1$
+		}
+		if (isV) {
+			args.add("-V"); //$NON-NLS-1$
+			args.add("" + V);} //$NON-NLS-1$
+		if (iso) {
+			args.add("-o"); //$NON-NLS-1$
+			args.add("" + o); //$NON-NLS-1$
+		}
+		if (iss) {
+			args.add("-s"); //$NON-NLS-1$
+			args.add("" + s); //$NON-NLS-1$
+		}
+		if (isw) {
+			args.add("-w"); //$NON-NLS-1$
+			args.add("" + w); //$NON-NLS-1$
+		}
+		if (isr) {
+			args.add("-r"); //$NON-NLS-1$
+			args.add("" + r); //$NON-NLS-1$
+		}
+		if (isv)
+			args.add("-v"); //$NON-NLS-1$
+		if (ish)
+			args.add("-h"); //$NON-NLS-1$
+		args.add("" + source); //$NON-NLS-1$
+		args.add("" + target); //$NON-NLS-1$
+		args.add("" + sattrib); //$NON-NLS-1$
+
+		ProcessBuilder pb = new ProcessBuilder(args);
+		pb.redirectErrorStream(true);
+		Process process = null;
+		try {
+			process = pb.start();
+		} catch (IOException e) {
+			System.err.println(e);
+		}
+		InputStream is = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(is);
+		BufferedReader br = new BufferedReader(isr);
+		String line;
+		while ((line = br.readLine()) != null) {
+			System.out.println(line);
+		}
+		int e = 0;
+		try {
+			e = process.waitFor();
+		} catch (Exception err) {
+		}
+		if (e != 0) {
+			System.err
+					.println("Process exited abnormally with code " + e + " at " + DateFormat.getDateInstance(DateFormat.FULL, Locale.UK).format(new Date())); //$NON-NLS-1$ //$NON-NLS-2$
+			for (int c = 0; c < args.size(); c++)
+				System.out.print("" + args.get(c) + " "); //$NON-NLS-1$ //$NON-NLS-2$
+			System.out.println();
+		}
+	}
+
+	// write data file to directory
+	/** The isd. */
+	private Boolean isd = false;
+	
+	/** The d. */
+	private String d;
+
+	/**
+	 * Sets the d.
+	 *
+	 * @param arg the new d
+	 */
+	public void setd(String arg) {
+		this.isd = true;
+		this.d = arg;
+	}
+
+	/**
+	 * Unsetd.
+	 */
+	public void unsetd() {
+		this.isd = false;
+	}
+
+	// write data files to corpus data directory
+	/** The is d. */
+	private Boolean isD = false;
+
+	/**
+	 * Sets the d.
+	 */
+	public void setD() {
+		this.isD = true;
+	}
+
+	/**
+	 * Unset d.
+	 */
+	public void unsetD() {
+		this.isD = false;
+	}
+
+	// compatibility mode (creates .alg file)
+	/** The is c. */
+	private Boolean isC = false;
+
+	/**
+	 * Sets the c.
+	 */
+	public void setC() {
+		this.isC = true;
+	}
+
+	/**
+	 * Unset c.
+	 */
+	public void unsetC() {
+		this.isC = false;
+	}
+
+	// create corpus align data
+	/**
+	 * Cwbalignencode.
+	 *
+	 * @param alignmentfile the alignmentfile
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public void cwbalignencode(String alignmentfile) throws IOException
+	// arg : the align file created by cwb-align
+	{
+		ArrayList<String> args = new ArrayList<String>();
+		args.add(binpath + "cwb-align-encode"); //$NON-NLS-1$
+		if (isd) {
+			args.add("-d"); //$NON-NLS-1$
+			args.add("" + d); //$NON-NLS-1$
+		}
+		if (isD)
+			args.add("-D"); //$NON-NLS-1$
+		if (isC)
+			args.add("-C"); //$NON-NLS-1$
+		if (isr) {
+			args.add("-r"); //$NON-NLS-1$
+			args.add("" + r); //$NON-NLS-1$
+		}
+		if (isv)
+			args.add("-v"); //$NON-NLS-1$
+		if (ish)
+			args.add("-h"); //$NON-NLS-1$
+		args.add("" + alignmentfile); //$NON-NLS-1$
+
+		ProcessBuilder pb = new ProcessBuilder(args);
+		pb.redirectErrorStream(true);
+		Process process = null;
+		try {
+			process = pb.start();
+		} catch (IOException e) {
+			System.err.println(e);
+		}
+		InputStream is = process.getInputStream();
+		InputStreamReader isr = new InputStreamReader(is);
+		BufferedReader br = new BufferedReader(isr);
+		String line;
+		while ((line = br.readLine()) != null) {
+			System.out.println(line);
+		}
+		int e = 0;
+		try {
+			e = process.waitFor();
+		} catch (Exception err) {
+		}
+		if (e != 0) {
+			System.err
+					.println("Process exited abnormally with code " + e + " at " + DateFormat.getDateInstance(DateFormat.FULL, Locale.UK).format(new Date())); //$NON-NLS-1$ //$NON-NLS-2$
+			for (int c = 0; c < args.size(); c++)
+				System.out.print("" + args.get(c) + " "); //$NON-NLS-1$ //$NON-NLS-2$
+			System.out.println();
+		}
+	}
+
+	/**
+	 * The main method.
+	 *
+	 * @param args the arguments
+	 */
+	public static void main(String[] args) {
+		// ./cwb-align -V seg_id -r ~/TXM/corpora/tmxtest/registry/
+		// tmxen tmxfr seg
+		// ./cwb-align-encode -D -r ~/TXM/corpora/tmxtest/registry/
+		// -v out.align
+		CwbAlign tt = new CwbAlign("~/TXMinstall/cwb/bin/"); //$NON-NLS-1$
+		tt.setV("seg_id"); //$NON-NLS-1$
+		tt
+				.setr(new File("~/TXM/corpora/tmxtest/registry/").getAbsolutePath()); //$NON-NLS-1$
+		try {
+			tt.cwbalign("tmxen", "tmxfr", "seg"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		} catch (IOException e) {
+			Log.severe("Error while calling cwb-align: "+e.getLocalizedMessage());
+			return;
+		}
+
+		tt = new CwbAlign("~/TXMinstall/cwb/bin/"); //$NON-NLS-1$
+		tt.setD();
+		tt.setv();
+		tt
+				.setr(new File("~/TXM/corpora/tmxtest/registry/").getAbsolutePath()); //$NON-NLS-1$
+		try {
+			tt.cwbalignencode("out.align"); //$NON-NLS-1$
+		} catch (IOException e) {
+			Log.severe("Error while calling cwb-align: "+e.getLocalizedMessage());
+			return;
+		}
+	}
+}
\ No newline at end of file

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/summary/Summary.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/summary/Summary.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/summary/Summary.java	(revision 449)
@@ -0,0 +1,259 @@
+package org.txm.functions.summary;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.txm.Toolbox;
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.core.results.TXMResult;
+import org.txm.objects.Edition;
+import org.txm.objects.Page;
+import org.txm.objects.Text;
+import org.txm.searchengine.cqp.CQPEngine;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.corpus.MainCorpus;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.QueryResult;
+import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
+import org.txm.searchengine.cqp.corpus.query.Query;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
+
+public class Summary extends TXMResult  {
+	MainCorpus corpus;
+	TreeNode treenodes = new TreeNode("root"); //$NON-NLS-1$
+	private ArrayList<StructuralUnitProperty> properties;
+
+	public Summary(MainCorpus corpus)
+	{
+		this.corpus = corpus;
+	}
+
+	public TreeNode getRoot()
+	{
+		return treenodes;
+	}
+
+	public boolean init(ArrayList<StructuralUnitProperty> properties) throws CqiClientException, IOException, CqiServerError
+	{
+		this.properties = properties;
+		treenodes.end = corpus.getSize();
+		treenodes.id = corpus.getName();
+		treenodes.start = 0;
+		treenodes.parent = null;
+		// get all type of structures
+		for (int j = 0 ; j < properties.size() ; j++) {
+			String suname = properties.get(j).getStructuralUnit().getName();
+			//System.out.println("getting : "+properties.get(j).getFullName());
+
+			QueryResult result = corpus.query(new Query("<"+properties.get(j).getFullName()+">[]"), "summary", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			int[] starts = result.getStarts();
+			result.drop();
+			result = corpus.query(new Query("[]</"+properties.get(j).getFullName()+">"), "summary", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			int[] ends = result.getStarts();
+			result.drop();
+			//System.out.println("starts: "+Arrays.toString(starts));
+			//System.out.println("ends: "+Arrays.toString(ends));
+			int[] strcutpos = CQPEngine.getCqiClient().cpos2Struc(properties.get(j).getQualifiedName(), starts);
+			String[] infos = CQPEngine.getCqiClient().struc2Str(properties.get(j).getQualifiedName(), strcutpos);
+			//allMatches.put(suname, list);
+			if (starts.length != ends.length) {
+				System.out.println(suname+": starts.length "+starts.length+" != ends.length "+ends.length); //$NON-NLS-1$ //$NON-NLS-2$
+				return false;
+			}
+			for (int i = 0 ; i < starts.length ; i++) {
+				//System.out.println("suname: "+suname+" start: "+m.getStart());
+				TreeNode node = new TreeNode();
+				node.start = starts[i];
+				node.end = ends[i];
+				node.struct = suname;
+				node.id = infos[i];
+				treenodes.add(node);
+			}
+		}
+		//this.print();
+
+		//System.out.println("sorting... "+treenodes.size()+" nodes");
+		processNodeList(treenodes);
+
+		//System.out.println("checking result..."+treenodes.size()+" nodes");
+		if (treenodes.check())
+			return true;
+		else
+			return false;
+	}
+
+	private void processNodeList(TreeNode nodes)
+	{
+		//System.out.println("+processing node list: "+nodes.size());
+		if (nodes.size() == 0)
+			return;
+
+		// 1st loop
+		//System.out.println("1st loop: "+nodes.size());
+		for (int i = 0 ; i < nodes.size() ; i++) {
+			TreeNode node = nodes.get(i);
+			if (node.end == -1)
+				System.out.println("ERROR: node.end = -1"); //$NON-NLS-1$
+			for (int j = 0 ; j < nodes.size() ; j++) {
+				if (j != i) {
+					TreeNode n2 = nodes.get(j);
+					if (n2.start >= node.start && n2.end <= node.end) {
+						n2.parent = node;
+						node.add(n2);
+						nodes.remove(j);
+						j--;
+						if (j < i)
+							i--;
+					}
+				}
+			}
+		}
+
+		//process sublists
+		//System.out.println("processing sublists: "+nodes.size());
+		for (int i = 0 ; i < nodes.size() ; i++) {
+			TreeNode node = nodes.get(i);
+			processNodeList(node);
+		}
+	}
+
+	public ArrayList<StructuralUnitProperty> getProperties()
+	{
+		return properties;
+	}
+
+	public void print()
+	{
+		for (TreeNode node : treenodes)
+			System.out.println("\n"+node); //$NON-NLS-1$
+	}
+
+
+	public Page getDefaultEditionPage(TreeNode node) throws Exception
+	{
+		StructuralUnitProperty text_id = corpus.getStructuralUnit("text").getProperty("id"); //$NON-NLS-1$ //$NON-NLS-2$
+		Property w_id =  corpus.getProperty("id"); //$NON-NLS-1$
+		int[] positions = {node.getStart()};
+		final String[] wordids = CQPEngine.getCqiClient().cpos2Str(w_id.getQualifiedName(), positions);
+		int[] textidstruct = CQPEngine.getCqiClient().cpos2Struc(text_id.getQualifiedName(), positions);
+		String[] textids = CQPEngine.getCqiClient().struc2Str(text_id.getQualifiedName(), textidstruct);
+
+		if (wordids.length == 1 && textids.length == 1) {
+			Text text = corpus.getText(textids[0]);
+			if (text == null) {
+				System.out.println(TXMCoreMessages.Summary_13+textids[0]+TXMCoreMessages.Summary_14);
+				return null;
+			}
+
+			Edition edition = text.getEdition("default"); //$NON-NLS-1$
+			if (edition == null) {
+				if (text.getEditions().size() == 0) {
+					System.out.println("No edition for text: "+text);
+				} else {
+					for (Edition ed : text.getEditions()) {
+						edition = ed;
+						break;
+					}
+				}
+			}
+			if (edition == null) {
+				System.out.println(TXMCoreMessages.Summary_15);
+				return null;
+			}
+
+			node.wordid = wordids[0];
+			return edition.getPageForWordId(wordids[0]);
+		} else {
+			System.out.println(TXMCoreMessages.Summary_16+Arrays.toString(textids)+TXMCoreMessages.Summary_17+Arrays.toString(wordids));
+			return null;
+		}
+	}
+
+	public class TreeNode extends ArrayList<TreeNode>
+	{
+		/**
+		 * 
+		 */
+		private static final long serialVersionUID = 1L;
+
+		public TreeNode parent;
+		boolean leaf = false;
+		String struct;
+		String id;
+		int start = -1;
+		int end = -1;
+		public String wordid;
+
+		public TreeNode()
+		{
+
+		}
+
+		public boolean check() {
+			for (TreeNode node : this) {
+				if(node.start >= this.start && node.end <= this.end && (node.end-node.start) < (this.end-this.start))
+					return node.check();
+				else
+					return false;
+			}
+			return true;
+		}
+
+
+		public TreeNode(String struct) {
+			this();
+			this.struct = struct;
+		}
+
+		@Override
+		public String toString()
+		{
+			String str = struct+"("+start+", "+end+")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			if(size() > 0)
+				str +="\n\t"+super.toString(); //$NON-NLS-1$
+			return str;
+		}
+
+		public TreeNode getParent()
+		{
+			return parent;
+		}
+
+		public String getInfo() {
+			return id;
+		}
+
+		public int getStart() {
+			return start;
+		}
+
+		public String getWordId() {
+			return wordid;
+		}
+	}
+
+	@Override
+	public String getName() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public String getSimpleName() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public String getDetails() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public void clean() {
+		// TODO Auto-generated method stub
+		
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/preview/package.html
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/preview/package.html	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/preview/package.html	(revision 449)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>Prototype of Preview functionnaly: shows the begining of a corpus or a partition.</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/preview/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/preview/Preview.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/preview/Preview.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/preview/Preview.java	(revision 449)
@@ -0,0 +1,93 @@
+package org.txm.functions.preview;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.txm.core.results.TXMResult;
+import org.txm.searchengine.cqp.corpus.Corpus;
+import org.txm.searchengine.cqp.corpus.Partition;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.query.Match;
+
+public class Preview extends TXMResult  {
+	private Corpus corpus;
+	private Partition partition;
+	private Property prop;
+	
+	private int n;
+	
+	public Preview(Corpus corpus, Property prop, int n) {
+		this.corpus = corpus;
+		this.prop = prop;
+		this.n = n;
+	}
+	
+	public Preview(Partition partition, Property prop, int n) {
+		this.partition = partition;
+		this.prop = prop;
+		this.n = n;
+	}
+	
+	public boolean compute() {
+		if (partition != null) {
+			return computePartition();
+		} else {
+			return computeCorpus();
+		}
+	}
+	
+	protected boolean computeCorpus() {
+		boolean ok = false;
+		
+		return ok;
+	}
+	
+	protected boolean computePartition() {
+		boolean ok = false;
+		List<Match> matches = corpus.getMatches();
+		for (Match m : matches) {
+			if (m.getLength() >= n) {
+				ok = true;
+			}
+		}
+		return ok;
+	}
+	
+	private String getLine(Corpus corpus) {
+		List<Match> matches = corpus.getMatches();
+		if (matches.size() == 0) return ""; //$NON-NLS-1$
+		
+		Match firstOkMatch = matches.get(0);
+		for (Match m : matches) {
+			if (m.getLength() >= n) {
+				Collection<? extends Integer> positions = m.getRange();
+				
+			}
+		}
+		return "";//getString(firstOkMatch); //$NON-NLS-1$
+	}
+
+	@Override
+	public String getName() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public String getSimpleName() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public String getDetails() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public void clean() {
+		// TODO Auto-generated method stub
+		
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/diagnostic/package.html
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/diagnostic/package.html	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/diagnostic/package.html	(revision 449)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>Diagnostic function</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/diagnostic/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/diagnostic/Diagnostic.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/diagnostic/Diagnostic.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/diagnostic/Diagnostic.java	(revision 449)
@@ -0,0 +1,622 @@
+// 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: 2016-09-19 10:31:00 +0200 (Mon, 19 Sep 2016) $
+// $LastChangedRevision: 3298 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.functions.diagnostic;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Locale;
+
+import org.eclipse.osgi.util.NLS;
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.functions.Function;
+import org.txm.objects.Base;
+import org.txm.searchengine.cqp.AbstractCqiClient;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.corpus.Corpus;
+import org.txm.searchengine.cqp.corpus.CorpusManager;
+import org.txm.searchengine.cqp.corpus.Part;
+import org.txm.searchengine.cqp.corpus.Partition;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.StructuralUnit;
+import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
+import org.txm.utils.logger.Log;
+
+// TODO: Auto-generated Javadoc
+/**
+ * compute a diagnostic of Corpus, sub corpus and partition @ author mdecorde.
+ */
+public class Diagnostic extends Function {
+	// Base base;
+	/** The corpus. */
+	Corpus corpus;
+	
+	/** The partition. */
+	Partition partition;
+	
+	/** The maxvalue. */
+	int maxvalue = 20;
+	
+	// Numbers
+	/** The T. */
+	int T = 0; // number of word
+
+	/** The N properties. */
+	int NProperties = 0; // number of word properties
+	//HashMap<String, Integer> propertiesCounts = new HashMap<String, Integer>(); // properties counts
+	/** The properties values. */
+	HashMap<String, List<String>> propertiesValues = new HashMap<String, List<String>>(); // properties values
+
+	/** The N structures. */
+	int NStructures = 0; // number of structures
+	
+	/** The structures counts. */
+	HashMap<String, Integer> structuresCounts = new HashMap<String, Integer>(); // structures counts
+
+	/** The internal architecture. */
+	List<String> internalArchitecture = new ArrayList<String>(); // wtc structures = propertiesCounts keys but ordered
+	
+	/** The hierarchie counts. */
+	HashMap<String, Integer> hierarchieCounts = new HashMap<String, Integer>(); // hierarchic structures counts
+	
+	/** The internal architecture properties. */
+	HashMap<String, HashMap<String, List<String>>> internalArchitectureProperties = new HashMap<String, HashMap<String, List<String>>>(); // hierarchic structures counts
+	
+	/** The internal architecture properties counts. */
+	HashMap<String, HashMap<String, Integer>> internalArchitecturePropertiesCounts = new HashMap<String, HashMap<String, Integer>>(); // hierarchic structures counts
+
+	// Annotations description
+	/** The annotations types. */
+	HashMap<String, Integer> annotationsTypes = new HashMap<String, Integer>(); // for each annotation its description
+	
+	/** The annotations origins. */
+	HashMap<String, Integer> annotationsOrigins = new HashMap<String, Integer>(); // for each annoation its origin description
+
+	// Import description
+	/** The import description. */
+	String importDescription = ""; //$NON-NLS-1$
+	
+	/** The properties. */
+	List<Property> properties;
+	
+	/** The structures. */
+	List<StructuralUnit> structures;
+
+	/**
+	 * Instantiates a new diagnostic.
+	 *
+	 * @param corpus a MainCorpus or a SubCorpus
+	 * @param maxvalue the number of values of properties shown
+	 */
+	public Diagnostic(Corpus corpus, int maxvalue) {
+		// long start = System.currentTimeMillis();
+		// base = b;
+		super(corpus);
+		this.corpus = corpus;
+		if (maxvalue <= 0)
+			maxvalue = 10;
+		this.maxvalue = maxvalue;
+	}
+	
+	/**
+	 * Process.
+	 */
+	public void process() {
+		stepGeneralInfos();
+		stepLexicalProperties();
+		stepStructuralUnits();
+	}
+	
+	/**
+	 * Step general infos.
+	 */
+	public void stepGeneralInfos()
+	{
+		try {
+			properties = corpus.getProperties();
+			NProperties = properties.size();
+		} catch (CqiClientException e1) {
+			Log.severe(TXMCoreMessages.Diagnostic_1 + corpus.getName()
+					+ TXMCoreMessages.Diagnostic_4);
+			return;
+		}
+		try {
+			T = corpus.getSize();// corpus.getLexicon(corpus.getProperty("id")).nbrOfToken();
+		} catch (CqiClientException e1) {
+			Log.severe(TXMCoreMessages.Diagnostic_6 + corpus.getName()
+					+ TXMCoreMessages.Diagnostic_8);
+			return;
+		} 
+	}
+	
+	/**
+	 * step2.
+	 * randomly position are choose
+	 */
+	public void stepLexicalProperties()
+	{
+		AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient();
+		for (Property p : properties) {
+			//int size;
+			try {
+				//size = CorpusManager.getCorpusManager().getCqiClient().lexiconSize(p.getQualifiedName());
+				//propertiesCounts.put(p.getName(), size);
+				//List<String> list = Arrays.asList(corpus.getLexicon(p).getForms(this.maxvalue));
+
+				int[] positions = new int[Math.min(maxvalue, T)];
+				for(int i = 0 ; i < Math.min(maxvalue, T) ; i++)
+					positions[i] = i;
+				
+				//ArrayList<String> values = new ArrayList<String>();
+				LinkedHashSet<String> values = new LinkedHashSet<String>(cqiClient.getSingleData(p, positions));
+				propertiesValues.put(p.getName(), new ArrayList<String>(values));
+			} catch (Exception e) {
+				org.txm.utils.logger.Log.printStackTrace(e);
+			}
+
+			// System.out.println("Lexi size "+p+" : "+(System.currentTimeMillis()-
+			// start));
+			// start = System.currentTimeMillis();
+		}
+	}
+	
+	/**
+	 * Step structural units.
+	 */
+	public void stepStructuralUnits()
+	{
+		try {
+			structures = corpus.getOrderedStructuralUnits();
+		} catch (CqiClientException e1) {
+			Log.severe(TXMCoreMessages.Diagnostic_1 + corpus.getName()
+					+ TXMCoreMessages.Diagnostic_11);
+			return;
+		}
+		NStructures = structures.size();
+		for (StructuralUnit su : structures) { // for each structural unit
+			internalArchitecture.add(su.getName());
+			hierarchieCounts.put(su.getName(), -1);
+			internalArchitectureProperties.put(su.getName(),
+					new HashMap<String, List<String>>());
+			internalArchitecturePropertiesCounts.put(su.getName(),
+					new HashMap<String, Integer>());
+			if (su.getProperties().size() > 0) {
+				for (StructuralUnitProperty sup : su.getProperties())  {// for each of its property
+					try {
+						List<String> allvalues = sup.getValues(corpus);
+						internalArchitectureProperties.get(su.getName()).put(
+								sup.getName(),
+								allvalues.subList(0, Math.min(allvalues.size(),
+										maxvalue)));
+						internalArchitecturePropertiesCounts.get(su.getName())
+						.put(sup.getName(), allvalues.size());
+					} catch (Exception e) {
+						ArrayList<String> list = new ArrayList<String>(1);
+						list.add(TXMCoreMessages.Diagnostic_2);
+						internalArchitectureProperties.get(su.getName()).put(
+								sup.getName(), list);
+						internalArchitecturePropertiesCounts.get(su.getName())
+						.put(sup.getName(), -1);
+					}
+				}
+			}
+		}
+	}
+
+	/**
+	 * Instantiates a new diagnostic.
+	 *
+	 * @param partition the partition
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Diagnostic(Partition partition) throws CqiClientException {
+		corpus = partition.getCorpus();
+		this.partition = partition;
+		int T = corpus.getSize();
+		System.out.println(TXMCoreMessages.Diagnostic_12);
+		int nbParts = partition.getNPart();
+		List<String> partNames = partition.getPartNames();
+		List<Integer> partSizes = new ArrayList<Integer>();
+		List<List<Property>> partProperties = new ArrayList<List<Property>>();
+		List<String> partQueries = new ArrayList<String>();
+		for (Part part : partition.getParts()) {
+			partSizes.add(part.getSize());
+			partProperties.add(part.getProperties());
+			partQueries.add(part.getQuery().getQueryString());
+		}
+	}
+
+	/**
+	 * dump the results of the diagnostic in a String containing HTML code.
+	 *
+	 * @return the string
+	 */
+	public String htmldump() {
+		StringBuffer buff = new StringBuffer();
+
+		buff.append("<? version=\"1.0\" encoding=\"UTF-8\"?>\n" + //$NON-NLS-1$
+				"<html>" + //$NON-NLS-1$
+				"<head>" + //$NON-NLS-1$
+				"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>" + //$NON-NLS-1$
+				"</head>" + //$NON-NLS-1$
+				"<body>\n"); //$NON-NLS-1$
+		buff.append("<h2 style'font-family:\"Arial\";'>"+TXMCoreMessages.Diagnostic_3 + this.corpus.getName() + "</h2>\n"); //$NON-NLS-2$ //$NON-NLS-1$
+		
+		if (corpus.getDescription() != null && corpus.getDescription().length() > 0) {
+			buff.append("<p>"+corpus.getDescription()+"</p>"); //$NON-NLS-1$ //$NON-NLS-2$
+		}
+		
+		buff.append("<h3 style'font-family:\"Arial\";'>"+TXMCoreMessages.Diagnostic_5+ "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$ 
+
+		
+		
+		// counts
+		buff.append("<ul>\n"); //$NON-NLS-1$
+		buff.append("<li>" + TXMCoreMessages.Diagnostic_7 + T + "</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ 
+		buff
+		.append("<li>" + TXMCoreMessages.Diagnostic_9 + (NProperties - 1) + "</li>\n"); //$NON-NLS-2$ //$NON-NLS-1$
+		buff.append("<li>" + TXMCoreMessages.Diagnostic_16 + NStructures + "</li>\n"); //$NON-NLS-2$ //$NON-NLS-1$
+		buff.append("</ul>\n"); //$NON-NLS-1$
+
+		// Propriétés d'occurrences
+		buff.append("<h3 style'font-family:\"Arial\";'>"+NLS.bind(TXMCoreMessages.Diagnostic_14, maxvalue) + "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$ 
+		ArrayList<String> properties = new ArrayList<String>(propertiesValues.keySet());
+		Collections.sort(properties);
+		buff.append("<ul>\n"); //$NON-NLS-1$
+		for (String s : properties) {
+			if (!s.equals("id")) //$NON-NLS-1$
+			{
+				//buff.append("<li> " + s + " (" + propertiesCounts.get(s) + ") : "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+				buff.append("<li> " + s + " : "); //$NON-NLS-1$ //$NON-NLS-2$ 
+				for (String v : propertiesValues.get(s))
+					buff.append(v + ", "); //$NON-NLS-1$
+				buff.append("..."); //$NON-NLS-1$
+				buff.append("</li>\n"); //$NON-NLS-1$ 
+			}
+		}
+		buff.append("</ul>\n"); //$NON-NLS-1$
+
+		// Propriété de structures
+		buff.append("<h3 style'font-family:\"Arial\";'>"+NLS.bind(TXMCoreMessages.Diagnostic_22, maxvalue)+"</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$
+		buff.append("<ul>\n"); //$NON-NLS-1$
+		for (String s : internalArchitecture) {
+			StringBuffer subbuffer = new StringBuffer();
+			if (s.equals("txmcorpus")) //$NON-NLS-1$
+				continue;//ignore the txmcorpus structure
+			
+			properties = new ArrayList<String>(internalArchitectureProperties.get(s).keySet());
+			
+			subbuffer.append("<li> " + s + "\n<ul>\n"); //$NON-NLS-1$ //$NON-NLS-2$
+			if (internalArchitectureProperties.get(s).keySet().size() == 0)
+				subbuffer.append("<li>"+TXMCoreMessages.Diagnostic_26+"</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ 
+
+			
+			//System.out.println("struct: "+s+" >> "+properties);
+			Collections.sort(properties);
+			//System.out.println("struct: "+s+" >sort> "+properties);
+			int nbOfValues = 0;
+			for (String ps : properties) {
+				if (!ps.equals("project") && !ps.equals("base") ) //$NON-NLS-1$ //$NON-NLS-2$ 
+				{
+					//System.out.println("struct: "+s+" >> "+ps);
+					int valuecount = internalArchitecturePropertiesCounts.get(s).get(ps);
+					ArrayList<String> values = new ArrayList<String>(
+							internalArchitectureProperties.get(s).get(ps));
+					subbuffer.append("<li> " + ps + " (" + valuecount + ") = "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+					//System.out.println("VALUES: "+values);
+					Collections.sort(values);
+					for (int i = 0 ; i < values.size() ; i++) {
+						nbOfValues++;
+						String psv = values.get(i);
+						if (psv != null && psv.length() > 0)
+							subbuffer.append(psv.replace("<", "&lt;")); //$NON-NLS-1$ //$NON-NLS-2$
+						else
+							subbuffer.append("\"\""); //$NON-NLS-1$
+						
+						if (i == values.size() -1)
+							subbuffer.append("."); //$NON-NLS-1$
+						else
+							subbuffer.append(", "); //$NON-NLS-1$
+						
+						if (i >= maxvalue) {
+							subbuffer.append("..."); //$NON-NLS-1$
+							break;
+						}
+					}
+					subbuffer.append("</li>\n"); //$NON-NLS-1$
+				}
+			}
+			subbuffer.append("</ul>\n</li>\n"); //$NON-NLS-1$
+			if (nbOfValues > 0) {
+				buff.append(subbuffer);
+			}
+		}
+		buff.append("</ul>\n"); //$NON-NLS-1$
+		buff.append("</body>\n"); //$NON-NLS-1$
+		buff.append("</html>\n"); //$NON-NLS-1$
+		
+		return buff.toString();
+	}
+
+	
+	
+	/**
+	 * dump the result in the console.
+	 *
+	 * @param maxvalue the maxvalue
+	 * @return the string
+	 */
+	public String dump(int maxvalue) {
+		StringBuffer buff = new StringBuffer();
+
+		buff.append(TXMCoreMessages.Diagnostic_40);
+		buff.append(TXMCoreMessages.Diagnostic_41 + String.format(Locale.FRANCE,"%,d", T) + "\n"); //$NON-NLS-1$ 
+		buff.append(TXMCoreMessages.Diagnostic_43 + String.format("%,d", NProperties) + "\n"); //$NON-NLS-1$ 
+		/*for (String s : propertiesCounts.keySet())
+			if (!s.equals("id")) //$NON-NLS-1$
+				buff.append(" - " + s + " " + propertiesCounts.get(s) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+				*/
+		buff.append(TXMCoreMessages.Diagnostic_49 + String.format("%,d", NStructures) + "\n"); //$NON-NLS-1$ 
+		for (String s : structuresCounts.keySet())
+			buff.append(" - " + s + "\n");//+structuresCounts.get(s)+"\n"); //$NON-NLS-1$ //$NON-NLS-2$
+
+		/*
+		 * buff.append("* Structural Units counts\n"); for(String s :
+		 * internalArchitecture)
+		 * buff.append(" - "+s+" "+hierarchieCounts.get(s)+"\n");
+		 */
+		buff.append(TXMCoreMessages.Diagnostic_0);
+		for (String s : internalArchitecture) {
+			buff.append(" - " + s + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+			for (String ps : internalArchitectureProperties.get(s).keySet()) {
+				if (!(s.equals("text") && (ps.equals("project") || ps.equals("base") || ps.equals("id")))) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+				{
+					buff
+					.append("   - " + ps + "(" + internalArchitectureProperties.get(s).get(ps).size() + ") = "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+					int valuecount = 0;
+					for (String psv : internalArchitectureProperties.get(s)
+							.get(ps)) {
+						buff.append(psv);
+						if (valuecount++ >= maxvalue) {
+							buff.append("..."); //$NON-NLS-1$
+							break;
+						}
+						if (valuecount < internalArchitectureProperties.get(s)
+								.get(ps).size())
+							buff.append(", "); //$NON-NLS-1$
+					}
+
+					buff.append("\n"); //$NON-NLS-1$
+				}
+			}
+		}
+
+		return buff.toString();
+	}
+
+	/**
+	 * dump the result in the console with maxvalue=30.
+	 *
+	 * @return the string
+	 */
+	public String dump() {
+		return dump(30);
+	}
+
+	/**
+	 * Gets the name.
+	 *
+	 * @return the name
+	 */
+	public String getName() {
+		return corpus.getName();
+	}
+
+	/**
+	 * Gets the base.
+	 *
+	 * @return the base
+	 */
+	public Base getBase() {
+		return corpus.getBase();
+	}
+
+	/**
+	 * Gets the t.
+	 *
+	 * @return the t
+	 */
+	public int getT() {
+		return T;
+	}
+
+	/**
+	 * Gets the n properties.
+	 *
+	 * @return the n properties
+	 */
+	public int getNProperties() {
+		return NProperties;
+	}
+
+	/**
+	 * Gets the internal architecture.
+	 *
+	 * @return the internal architecture
+	 */
+	public List<String> getInternalArchitecture() {
+		return internalArchitecture;
+	}
+
+	/*public HashMap<String, Integer> getPropertiesCounts() {
+		return propertiesCounts;
+	}*/
+
+	/**
+	 * Gets the n structures.
+	 *
+	 * @return the n structures
+	 */
+	public int getNStructures() {
+		return NStructures;
+	}
+
+	/**
+	 * Gets the structures counts.
+	 *
+	 * @return the structures counts
+	 */
+	public HashMap<String, Integer> getStructuresCounts() {
+		return structuresCounts;
+	}
+
+	/**
+	 * Gets the annotations types.
+	 *
+	 * @return the annotations types
+	 */
+	public HashMap<String, Integer> getAnnotationsTypes() {
+		return annotationsTypes;
+	}
+
+	/**
+	 * Gets the annotations origins.
+	 *
+	 * @return the annotations origins
+	 */
+	public HashMap<String, Integer> getAnnotationsOrigins() {
+		return annotationsOrigins;
+	}
+
+	/**
+	 * Gets the import description.
+	 *
+	 * @return the import description
+	 */
+	public String getImportDescription() {
+		return importDescription;
+	}
+
+	/**
+	 * dump the diagnostic in a text file.
+	 *
+	 * @param outfile the outfile
+	 * @param maxvalue the maxvalue
+	 * @return true, if successful
+	 */
+	public boolean toTxt(File outfile, String encoding, int maxvalue) {
+		BufferedWriter writer;
+		try {
+			writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outfile),	encoding));
+		} catch (UnsupportedEncodingException e1) {
+			org.txm.utils.logger.Log.printStackTrace(e1);
+			return false;
+		} catch (FileNotFoundException e1) {
+			org.txm.utils.logger.Log.printStackTrace(e1);
+			return false;
+		}
+
+		try {
+			writer.write(this.dump(maxvalue));
+			writer.close();
+		} catch (IOException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return false;
+		}
+
+		return true;
+	}
+
+	/**
+	 * dump the diagnostic in a HTML file.
+	 *
+	 * @param outfile the outfile
+	 * @return true, if successful
+	 */
+	public boolean toHTML(File outfile) {
+		OutputStreamWriter writer;
+		try {
+			writer = new OutputStreamWriter(new FileOutputStream(outfile), "UTF-8"); //$NON-NLS-1$
+			writer.write(this.htmldump());
+			writer.close();
+		} catch (IOException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return false;
+		}
+
+		return true;
+	}
+
+	/**
+	 * dump the diagnostic in a text file, maxvalue = 100.
+	 *
+	 * @param outfile the outfile
+	 * @return true, if successful
+	 */
+	public boolean toTxt(File outfile) {
+
+		return toTxt(outfile, "UTF-8", 100); //$NON-NLS-1$
+	}
+
+	@Override
+	public void clean() {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public boolean toTxt(File outfile, String encoding, String colseparator,
+			String txtseparator) throws Exception {
+		return toTxt(outfile, encoding, 100);
+	}
+
+
+
+
+	@Override
+	public String getSimpleName() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public String getDetails() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/selection/package.html
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/selection/package.html	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/selection/package.html	(revision 449)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>Selection: select text using metadata values</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/selection/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/selection/SelectionResult.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/selection/SelectionResult.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/selection/SelectionResult.java	(revision 449)
@@ -0,0 +1,13 @@
+package org.txm.functions.selection;
+
+import java.util.*;
+
+public class SelectionResult extends ArrayList<String>{
+	public HashMap<String,ArrayList<String>> critera = new HashMap<String, ArrayList<String>>();
+	
+	@Override
+	public String toString()
+	{
+		return super.toString() + critera.toString();
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/selection/Selection.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/selection/Selection.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/selection/Selection.java	(revision 449)
@@ -0,0 +1,488 @@
+// 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:$
+// $LastChangedRevision:$
+// $LastChangedBy:$ 
+//
+package org.txm.functions.selection;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.core.results.TXMResult;
+import org.txm.metadatas.Metadata;
+import org.txm.metadatas.MetadataGroup;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
+import org.txm.searchengine.cqp.corpus.Corpus;
+import org.txm.searchengine.cqp.corpus.CorpusManager;
+import org.txm.searchengine.cqp.corpus.MainCorpus;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.QueryResult;
+import org.txm.searchengine.cqp.corpus.StructuralUnit;
+import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
+import org.txm.searchengine.cqp.corpus.query.Match;
+import org.txm.searchengine.cqp.corpus.query.Query;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
+import org.txm.utils.logger.Log;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Used to build sub-corpus of texts.
+ * It links texts to their properties and compute some stats 
+ * @author mdecorde
+ *
+ */
+public class Selection extends TXMResult  {
+
+	/** Full selection. */
+	Corpus corpus;
+	
+	/** The query to get texts metadatas and number. */
+	Query query;
+	
+	/** The cqp positions of the texts start element. */
+	int[] positions;
+	
+	/** The all properties. */
+	List<StructuralUnitProperty> allProperties;
+	
+	/** The textids. */
+	List<String> textids;
+	
+	/** The numberofwords. */
+	HashMap<String, Integer> numberOfWordsPerText;
+
+	/** The text metadatas values. */
+	HashMap<String, HashMap<String, String>> metadatasValuesPerText;
+	HashMap<String, List<String>> valuesPerMetadata;
+	
+	/** The metadatas and groups. */
+	ArrayList<Metadata> metadatas;
+	ArrayList<MetadataGroup> metadatagroups;
+	
+	/** The property and group names per usage. */
+	private ArrayList<String> selectionPropertyNames;
+	private ArrayList<String> displayPropertyNames;
+	private ArrayList<String> selectionGroupNames;
+	private ArrayList<String> displayGroupNames;
+	
+	/** the list of property used per group**/
+	private HashMap<String, List<String>> propertyNamesPerGroup;
+	
+	/**
+	 * Instantiates a new selection.
+	 *
+	 * @param corpus the corpus
+	 */
+	public Selection(MainCorpus corpus) {
+		// this query returns N results, where N is the number of text
+		this.query = new Query("<text>[]"); //$NON-NLS-1$
+		this.corpus = corpus;
+		init();
+	}
+	
+	/**
+	 * get positions, properties
+	 * and compute texts stats (but not words)
+	 * and get texts metadatas.
+	 */
+	private boolean init() {
+		try {
+			if (corpus.getBase() == null) {
+				System.out.println(TXMCoreMessages.Selection_6+corpus+TXMCoreMessages.Selection_7);
+				return false;
+			}
+			metadatas = corpus.getImportMetadata();
+			metadatagroups = corpus.getMetadataGroups();
+			
+			//get texts positions
+			QueryResult result = corpus.query(query, "selection", false); //$NON-NLS-1$
+			List<Match> matches = result.getMatches();
+			result.drop();
+			//System.out.println("Nb of texts: "+matches.size());
+			positions = new int[matches.size()]; // starting positions of texts in the corpus
+			for (int i = 0 ; i < matches.size() ; i++)
+				positions[i] = matches.get(i).getStart();
+			
+			// select used structuralUnitsProperties in corpus structuralUnitsProperties
+			StructuralUnit text_su = corpus.getStructuralUnit("text"); //$NON-NLS-1$
+			allProperties = new ArrayList<StructuralUnitProperty>();
+			if (metadatas.size() > 0) {
+				for (Metadata m : metadatas) {
+					try {
+						StructuralUnitProperty sup = text_su.getProperty(m.id);
+						if (sup == null) {
+							Log.warning(TXMCoreMessages.Selection_8+m.id);
+							continue;
+						}
+						allProperties.add(sup);
+					} catch(Exception e) {
+						Log.severe(TXMCoreMessages.Selection_9+e);
+					}
+				}
+			}
+
+			// in case no metadatas are declared in import.xml
+			if (allProperties.size() == 0) 
+				for (StructuralUnitProperty sup : text_su.getProperties())
+					allProperties.add(sup);
+
+			//get text ids (using starting position of texts) + text size using the positions
+			StructuralUnitProperty sup = text_su.getProperty("id"); //$NON-NLS-1$
+			int[] idx = CorpusManager.getCorpusManager().getCqiClient().cpos2Struc(sup.getQualifiedName(), positions);
+			//System.out.println("cpos2Struc: "+Arrays.toString(idx));
+			String[] textsIdArray = CorpusManager.getCorpusManager().getCqiClient().struc2Str(sup.getQualifiedName(), idx);
+			//System.out.println("struc2Str: "+Arrays.toString(textsIdArray));
+			textids = Arrays.asList(textsIdArray);
+
+			metadatasValuesPerText = new HashMap<String, HashMap<String,String>>();
+			numberOfWordsPerText = new HashMap<String, Integer>();
+			for (int i = 0 ; i < textids.size() ; i++) {
+				this.metadatasValuesPerText.put(textids.get(i), new HashMap<String, String>());
+				
+				//QueryResult result2 = corpus.query(new Query("[_.text_id=\""+textids.get(i)+"\"] expand to text"), "temp", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+				QueryResult result2 = corpus.query(new Query("/region[text,a]:: a.text_id=\""+textids.get(i)+"\""), "temp", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+				int tot = 0;
+				for (Match m : result2.getMatches(0,0))
+					tot += m.getEnd()- m.getStart();
+				numberOfWordsPerText.put(textids.get(i), tot);
+				result2.drop();
+			}
+
+			//System.out.println(textMetadatas);
+			//INITIALIZATIONS
+			for (StructuralUnitProperty property : allProperties) {	
+				readTextMetadatas(property);
+			}
+
+			getTextMetadatas();
+			getStructuralUnitPropertyValues();
+			getDisplayPropertyNames();
+			getSelectionPropertyNames();
+			getDisplayGroupNames();
+			getSelectionGroupNames();
+			getMetadataGroupNames();
+		}
+		catch (Exception e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return false;
+		}
+		return true;
+	}
+	
+	public Corpus getCorpus() {
+		return this.corpus;
+	}
+	
+	public HashMap<String, List<String>> getMetadataGroupNames() {
+		if (propertyNamesPerGroup != null)
+			return propertyNamesPerGroup;
+		propertyNamesPerGroup = new HashMap<String, List<String>>();
+		for (MetadataGroup gp : metadatagroups) {
+			ArrayList<String> list = new ArrayList<String>();
+			System.out.println("gp: "+gp.id); //$NON-NLS-1$
+			propertyNamesPerGroup.put(gp.id, list);
+			for (Metadata m : gp.metadatas)
+				list.add(m.id);
+		}
+		return propertyNamesPerGroup;
+	}
+	
+	/**
+	 * print the full texts stats.
+	 *
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public void fullDump() throws CqiClientException {
+		System.out.println(TXMCoreMessages.Selection_5);
+		System.out.println(TXMCoreMessages.Corpus_2+corpus);
+		System.out.println("Text query: "+query); //$NON-NLS-1$
+		System.out.println("Texts ids: "+textids); //$NON-NLS-1$
+		System.out.println("Text positions: "+Arrays.toString(positions)); //$NON-NLS-1$
+		System.out.println("Text nbwords: "+numberOfWordsPerText); //$NON-NLS-1$
+		System.out.println();
+		System.out.println("StructuralUnitsProperties: "+allProperties); //$NON-NLS-1$
+		System.out.println("Meta values per texts: "+metadatasValuesPerText); //$NON-NLS-1$
+		System.out.println("Meta values per name: "+valuesPerMetadata); //$NON-NLS-1$
+		System.out.println();
+		System.out.println("Declared metadatas: "+metadatas); //$NON-NLS-1$
+		System.out.println("Declared metadata groups: "+metadatagroups); //$NON-NLS-1$
+		System.out.println(""); //$NON-NLS-1$
+		System.out.println("Selection props: "+selectionPropertyNames); //$NON-NLS-1$
+		System.out.println("Displayed props: "+displayPropertyNames); //$NON-NLS-1$
+		System.out.println("Selection groups: "+selectionGroupNames); //$NON-NLS-1$
+		System.out.println("Displayed groups: "+displayGroupNames); //$NON-NLS-1$
+		System.out.println("Properties used per group: "+ propertyNamesPerGroup); //$NON-NLS-1$
+	}
+	
+	/**
+	 * Gets the number of word.
+	 *
+	 * @param property the property
+	 * @param value the value
+	 * @return the number of words which 'property' value matches param 'value'
+	 */
+	public int getNumberOfWord(StructuralUnitProperty property, String value) {
+		int nb = 0;
+		for (String text : metadatasValuesPerText.keySet())
+			if (metadatasValuesPerText.get(text).get(property).equals(value))
+				nb+= numberOfWordsPerText.get(text);
+		return nb;
+	}
+	
+	/**
+	 * Gets the text number.
+	 *
+	 * @param property the property
+	 * @param value the value
+	 * @return the number of text which 'property' value matches param 'value'
+	 */
+	public int getNumberOfText(StructuralUnitProperty property, String value) 
+	{
+		int nb = 0;
+		for (String text : metadatasValuesPerText.keySet())
+			if (metadatasValuesPerText.get(text).get(property).equals(value))
+				nb++;
+		return nb;
+	}
+	
+	/**
+	 * Loads the metadatas values and store them per text id.
+	 *
+	 * @param property the property
+	 * @return 
+	 * @return the text metadatas
+	 * @throws UnexpectedAnswerException the unexpected answer exception
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	private HashMap<String, HashMap<String, String>> readTextMetadatas(StructuralUnitProperty property) throws UnexpectedAnswerException, IOException, CqiServerError
+	{
+		int[] idx = CorpusManager.getCorpusManager().getCqiClient().cpos2Struc(property.getQualifiedName(), positions);
+		String[] values = CorpusManager.getCorpusManager().getCqiClient().struc2Str(property.getQualifiedName(), idx);
+
+		for (int i = 0 ; i < values.length ; i++) {
+			this.metadatasValuesPerText.get(textids.get(i)).put(property.getName(), values[i]);
+		}
+		
+		return metadatasValuesPerText;
+	}
+	
+	/**
+	 * Gets the text metadatas values per text.
+	 *
+	 * @return the text metadatas
+	 */
+	public HashMap<String, HashMap<String, String>> getTextMetadatas() {
+		return this.metadatasValuesPerText;
+	}
+	
+	/**
+	 * Gets the number of words.
+	 *
+	 * @return the number of words
+	 */
+	public HashMap<String, Integer> getNumberOfWordsPerText() {
+		return this.numberOfWordsPerText;
+	}
+	
+	/**
+	 * Gets the text ids.
+	 *
+	 * @return the text ids, corpus ordered
+	 */
+	public List<String> getTextIds() {
+		return this.textids;
+	}
+	
+	/**
+	 * Gets and loads the selection properties name.
+	 *
+	 * @return the selection text metadata
+	 */
+	public ArrayList<String> getSelectionPropertyNames()
+	{
+		if (selectionPropertyNames != null)
+			return selectionPropertyNames;
+		StructuralUnit text_su;
+		selectionPropertyNames = new ArrayList<String>();
+		/*try {
+			text_su = corpus.getStructuralUnit("text");
+
+			// if corpus has metadatas declared
+			if (metadatas.size() > 0)
+			{
+				for(Metadata m : metadatas)
+				{
+						selectionPropertyNames.add(m.id);
+				}
+			}
+
+			//if no props added via metadata then get all text properties
+			if (selectionPropertyNames.size() == 0) 
+			{
+				for(Property p : text_su.getProperties())
+					selectionPropertyNames.add(p.getName());
+			}
+
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} //$NON-NLS-1$*/
+		for (StructuralUnitProperty prop : allProperties)
+			selectionPropertyNames.add(prop.getName());
+		return selectionPropertyNames;
+	}
+
+	/**
+	 * Gets and loads the selection group names.
+	 *
+	 * @return the selection text metadata
+	 */
+	public ArrayList<String> getSelectionGroupNames()
+	{
+		if (selectionGroupNames != null)
+			return selectionGroupNames;
+		selectionGroupNames = new ArrayList<String>();
+		for (Metadata m : metadatagroups) {
+			if (m.selection) {	
+				selectionGroupNames.add(m.id);
+			}
+		}
+
+		return selectionGroupNames;
+	}
+
+	/**
+	 * Gets the display properties name.
+	 *
+	 * @return the display text metadata
+	 */
+	public ArrayList<String> getDisplayPropertyNames()
+	{
+		if (displayPropertyNames != null)
+			return displayPropertyNames;
+		StructuralUnit text_su;
+		displayPropertyNames = new ArrayList<String>();
+		try {
+			text_su = corpus.getStructuralUnit("text"); //$NON-NLS-1$
+
+			// if corpus has metadatas declared
+			if (metadatas.size() > 0) {
+				for (Metadata m : metadatas) {
+					if (m.display) // only keep metadata for selection
+						displayPropertyNames.add(m.id);
+				}
+			}
+
+			if (displayPropertyNames.size() == 0) {
+				for (Property p : text_su.getProperties())
+					displayPropertyNames.add(p.getName());
+			}
+
+		} catch (Exception e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} 
+		return displayPropertyNames;
+	}
+
+	/**
+	 * Gets and loads the display group names.
+	 *
+	 * @return the display text metadata
+	 */
+	public ArrayList<String> getDisplayGroupNames()
+	{
+		if (displayGroupNames != null)
+			return displayGroupNames;
+		displayGroupNames = new ArrayList<String>();
+		for (Metadata m : metadatagroups) {
+			if (m.display) // only keep metadata for selection
+				displayGroupNames.add(m.id);
+		}
+		return displayGroupNames;
+	}
+
+	/**
+	 * Gets the structural unit property values per structuralUnitProperty.
+	 *
+	 * @return 
+	 */
+	public HashMap<String, List<String>> getStructuralUnitPropertyValues()
+	{
+		if (valuesPerMetadata != null)
+			return valuesPerMetadata;
+		valuesPerMetadata = new HashMap<String, List<String>>();
+
+		try {
+			for (StructuralUnitProperty sup : allProperties) {
+				try {
+					valuesPerMetadata.put(sup.getName(), sup.getValues());
+				} catch (CqiClientException e) {
+					System.out.println(TXMCoreMessages.Selection_26+sup.getFullName());
+					org.txm.utils.logger.Log.printStackTrace(e);
+					return valuesPerMetadata;
+				}
+			}
+		} catch(Exception e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+		return valuesPerMetadata;
+	}
+
+	public ArrayList<Metadata> getMetadatas() {
+		return metadatas;
+	}
+
+	public ArrayList<MetadataGroup> getMetadatagroups() {
+		return metadatagroups;
+	}
+
+	@Override
+	public String getName() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public String getSimpleName() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public String getDetails() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public void clean() {
+		// TODO Auto-generated method stub
+		
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/internal/InternalView.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/internal/InternalView.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/internal/InternalView.java	(revision 449)
@@ -0,0 +1,210 @@
+package org.txm.functions.internal;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+
+import org.txm.Toolbox;
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.core.results.TXMResult;
+import org.txm.searchengine.cqp.CQPEngine;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.corpus.Corpus;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.QueryResult;
+import org.txm.searchengine.cqp.corpus.StructuralUnit;
+import org.txm.searchengine.cqp.corpus.query.Match;
+import org.txm.searchengine.cqp.corpus.query.Query;
+
+public class InternalView extends TXMResult  {
+	Corpus corpus;
+	List<Property> properties;
+	StructuralUnit struct;
+	List<Property> structProperties;
+
+	int currentStruct = -1;
+	int nmatches = 0;
+	List<Match> matches = new ArrayList<Match>();
+
+
+	public InternalView(Corpus corpus, List<Property> properties, StructuralUnit struct, List<Property> structProperties) throws CqiClientException {
+		this.corpus = corpus;
+		this.properties = properties;
+		this.struct = struct;
+		this.structProperties = structProperties;
+
+		//find struct start-end
+		Query query = new Query("<"+struct.getName()+"> [] expand to "+struct); //$NON-NLS-1$ //$NON-NLS-2$
+		//System.out.println(query);
+		QueryResult result = corpus.query(query, "test", false); //$NON-NLS-1$
+		nmatches = result.getNMatch();
+		if (nmatches > 0) {
+			matches = result.getMatches();
+		}
+		result.drop();
+		//System.out.println(matches);
+	}
+
+	public String getStructInfos() {
+
+		try {
+			if (structProperties.size() > 0) {
+				String str = TXMCoreMessages.InternalView_3;
+				for (Property sup : structProperties) {
+					int[] array = {getCurrentSegmentNo()};
+					str += " "+sup.getName()+"="+CQPEngine.getCqiClient().struc2Str(sup.getQualifiedName(), array)[0]; //$NON-NLS-1$ //$NON-NLS-2$
+				}
+				return str;
+			}
+		} catch (Exception e) {
+			System.out.println(TXMCoreMessages.InternalView_6+e.getMessage());
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+		return TXMCoreMessages.InternalView_7;
+	}
+
+	public HashMap<Property, List<String>> getNext() throws CqiClientException {
+		int next = currentStruct + 1;
+		if (next < nmatches) {
+			return getSegment(next);
+		} 
+		return new HashMap<Property, List<String>>();
+	}
+
+	public HashMap<Property, List<String>> getPrevious() throws CqiClientException {
+		int previous = currentStruct - 1;
+		if (previous >= 0 && previous < nmatches) {
+			return getSegment(previous);
+		}
+		return new HashMap<Property, List<String>>();
+	}
+
+	public HashMap<Property, List<String>> getFirst() throws CqiClientException {
+		if (0 < nmatches) {
+			return getSegment(0);
+		}
+		return new HashMap<Property, List<String>>();
+	}
+
+	public HashMap<Property, List<String>> getLast() throws CqiClientException {
+		if (nmatches - 1 >= 0) {
+			return getSegment(nmatches - 1);
+		}
+		return new HashMap<Property, List<String>>();
+	}
+
+	public HashMap<Property, List<String>> getSegment(int i) throws CqiClientException {
+		HashMap<Property, List<String>> rez = new HashMap<Property, List<String>>();
+
+		if (i >= 0 && i < nmatches) {
+			Match m = matches.get(i);
+			Collection<? extends Integer> positions = m.getRange();
+			int[] p = new int[positions.size()];
+			int c = 0;
+			for(int v : positions) p[c++] = v;
+			for (Property prop : properties) {
+				rez.put(prop, Match.getValuesForProperty(prop, p));
+			}
+			currentStruct = i;
+		}
+		return rez;
+	}
+
+	public void printNext() throws CqiClientException {
+		HashMap<Property, List<String>> seg = getNext();
+		if (seg.size() > 0)
+			System.out.println(seg);
+	}
+
+	public void printPrevious() throws CqiClientException {
+		HashMap<Property, List<String>> seg = getPrevious();
+		if (seg.size() > 0)
+			System.out.println(seg);
+	}
+
+	public void printSeg(HashMap<Property, List<String>> seg) {
+		Collection<List<String>> values = seg.values();
+		if(values.size() == 0) return;
+
+		for(List<String> list : values) {
+			for(String value : list)
+				System.out.print("\t"+value); //$NON-NLS-1$
+			System.out.println();
+		}
+		System.out.println();
+	}
+
+	public Corpus getCorpus() {
+		return corpus;
+	}
+
+	public StructuralUnit getStructuralUnit() {
+		return struct;
+	}
+
+	public List<Property> getProperties() {
+		return properties;
+	}
+
+	public int getCurrentSegmentNo() {
+		return currentStruct;
+	}
+
+	public int getNSegment() {
+		return nmatches;
+	}
+
+	public int getSegmentLength() {
+		if (matches.size() == 0) return 0;
+		Match m = matches.get(currentStruct);
+		return m.size();
+	}
+
+	public boolean isFirst() {
+		return currentStruct == 0;
+	}
+
+	public boolean isLast() {
+		return currentStruct == nmatches - 1;
+	}
+
+	public String getLocationTail() {
+		return " / "+nmatches; //$NON-NLS-1$
+	}
+	
+	public String getCurrentLocation() {
+		return ""+(currentStruct+1); //$NON-NLS-1$
+	}
+
+	public String getDetails() {
+		// TODO Auto-generated method stub
+		return corpus.getName()+" "+struct.getName()+" "+(currentStruct+1); //$NON-NLS-1$ //$NON-NLS-2$
+	}
+
+	public void setProperties(List<Property> properties2) {
+		this.properties = properties2;
+	}
+
+	public void setStructProperties(List<Property> properties2) {
+		this.structProperties = properties2;
+	}
+
+	@Override
+	public String getName() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public String getSimpleName() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public void clean() {
+		// TODO Auto-generated method stub
+		
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/internal/package.html
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/internal/package.html	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/internal/package.html	(revision 449)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>Internal view</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.searchengine.cqp.core/src/org/txm/functions/internal/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/package.html
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/package.html	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/package.html	(revision 449)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>Implementation of full text indexing and querying using the CQP engine.</p>
+</body>
+</html>
\ No newline at end of file

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CqpDataProxy.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CqpDataProxy.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CqpDataProxy.java	(revision 449)
@@ -0,0 +1,203 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
+import org.txm.utils.SparseList;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqpDataProxy.
+ */
+public class CqpDataProxy {
+	/**
+	 * Data is cached in a sparse list which give for each position the
+	 * corresponding string (given the property it is dedicated to).
+	 */
+	private SparseList<String> data;
+
+	/** The property getQualifiedName. */
+	private String property;
+	private boolean isWordProperty = true;
+	private NetCqiClient netCqiClient;
+	/**
+	 * Instantiates a new cqp data proxy.
+	 *
+	 * @param property the property getQualifiedName
+	 */
+	public CqpDataProxy(NetCqiClient netCqiClient, String property) {
+		this(netCqiClient,  property, true);
+	}
+	
+	public CqpDataProxy(NetCqiClient netCqiClient, Property property) {
+		this(netCqiClient,  property.getQualifiedName(), !(property instanceof StructuralUnitProperty));
+	}
+	
+	/**
+	 * Instantiates a new cqp data proxy.
+	 *
+	 * @param property the property getQualifiedName
+	 * @param isWordProperty true is the default value
+	 */
+	public CqpDataProxy(NetCqiClient netCqiClient, String property, boolean isWordProperty) {
+		this.data = new SparseList<String>();
+		this.property = property;
+		this.isWordProperty = isWordProperty;
+		this.netCqiClient = netCqiClient;
+	}
+
+	/**
+	 * Return lists of strings. The positions parameter gives a list of starting
+	 * points, and the nWords parameter gives a list of sizes: The i^th string
+	 * starts at the position positions.get(i) and is nWords.get(i)
+	 *
+	 * @param positions the positions
+	 * @param nWords the n words
+	 * @return the data
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public List<List<String>> getData(List<Integer> positions,
+			List<Integer> nWords) throws CqiClientException {
+		List<List<String>> lines = new ArrayList<List<String>>();
+		for (int i = 0; i < positions.size(); i++)
+			lines.add(data.getRange(positions.get(i), positions.get(i)
+					+ nWords.get(i)));
+		List<Integer> allPositionsNeeded = new ArrayList<Integer>();
+		// the position in the corpus of the missing values
+		
+		for (int i = 0; i < lines.size(); i++) {
+			List<String> line = lines.get(i);
+			for (int j = 0; j < line.size(); j++) {
+				if (line.get(j) == null)
+					allPositionsNeeded.add(positions.get(i) + j);
+			}
+		}
+		if (allPositionsNeeded.size() > 0) {
+			String[] missingValues;
+			try {
+				if (!isWordProperty) {
+					//System.out.println("DataProxy: "+allPositionsNeeded);
+					int[] strucs = netCqiClient.cpos2Struc(
+									property,
+									ArrayUtils
+											.toPrimitive(allPositionsNeeded
+													.toArray(new Integer[0])));
+					//System.out.println("structs: "+Arrays.toString(strucs));
+					missingValues = netCqiClient._struc2Str(
+									property, strucs);
+					//System.out.println("missingValues: "+missingValues);
+				} else {
+					missingValues = netCqiClient._cpos2Str(
+									property,
+									ArrayUtils
+											.toPrimitive(allPositionsNeeded
+													.toArray(new Integer[0])));
+				}
+			} catch (Exception e) {
+				throw new CqiClientException(e);
+			}
+			for (int i = 0; i < missingValues.length; i++)
+				data.add(allPositionsNeeded.get(i), missingValues[i]);
+			// There is no more missing values in data, we can query it again
+			// This is is pretty ugly since all the non missing values have
+			// already been retrieved...
+			lines = new ArrayList<List<String>>();
+			for (int i = 0; i < positions.size(); i++)
+				lines.add(data.getRange(positions.get(i), positions.get(i)
+						+ nWords.get(i)));
+		}
+		return lines;
+	}
+
+	public List<String> getData(List<Integer> positions) throws CqiClientException {
+		int [] ipositions = new int[positions.size()];
+		for(int i = 0 ; i < positions.size() ; i++)
+			ipositions[i] = positions.get(i);
+		return getData(ipositions);
+	}
+	
+	/**
+	 * Gets the data.
+	 *
+	 * @param positions the positions
+	 * @return the data
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public List<String> getData(int[] positions) throws CqiClientException {
+		//System.out.println("CqpDataProxy: start "+property);
+		//System.out.println("positions: "+Arrays.toString(positions));
+		List<String> lines = new ArrayList<String>();
+		for (int i = 0; i < positions.length; i++)
+			lines.add(data.getRange(positions[i], positions[i] + 1).get(0));
+		//System.out.println("lines: "+lines);
+		List<Integer> missingValuePositions = new ArrayList<Integer>();// the position in the corpus of the missing values
+		for (int i = 0; i < lines.size(); i++) {
+			String line = lines.get(i);
+			if (line == null)
+				missingValuePositions.add(positions[i]);
+		}
+		//System.out.println("missingValuePositions: "+missingValuePositions);
+		if (missingValuePositions.size() > 0) {
+			String[] missingValues;
+			try {
+				if (!isWordProperty) {
+					int[] strucs = netCqiClient.cpos2Struc(
+									property,
+									ArrayUtils.toPrimitive(missingValuePositions
+													.toArray(new Integer[0])));
+					//System.out.println("structs: "+Arrays.toString(strucs));
+					missingValues = netCqiClient._struc2Str(property, strucs);
+				} else {
+					missingValues = netCqiClient._cpos2Str(
+									property,
+									ArrayUtils.toPrimitive(missingValuePositions
+													.toArray(new Integer[0])));
+					//System.out.println("missingValues: "+missingValues);
+				}
+			} catch (Exception e) {
+				throw new CqiClientException(e);
+			}
+			for (int i = 0; i < missingValues.length; i++)
+				data.add(missingValuePositions.get(i), missingValues[i]);
+			// There is no more missing values in data, we can query it again
+			// This is is pretty ugly since all the non missing values have
+			// already been retrieved...
+			lines = new ArrayList<String>();
+			for (int i = 0; i < positions.length; i++)
+				lines.add(data.getRange(positions[i], positions[i] + 1).get(0));
+		}
+		return lines;
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/NetCqiClient.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/NetCqiClient.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/NetCqiClient.java	(revision 449)
@@ -0,0 +1,1956 @@
+// 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.cqp;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.util.Arrays;
+import java.util.HashMap;
+
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.clientExceptions.ServerNotFoundException;
+import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
+import org.txm.searchengine.cqp.serverException.CqiClErrorCorpusAccess;
+import org.txm.searchengine.cqp.serverException.CqiClErrorInternal;
+import org.txm.searchengine.cqp.serverException.CqiClErrorNoSuchAttribute;
+import org.txm.searchengine.cqp.serverException.CqiClErrorOutOfMemory;
+import org.txm.searchengine.cqp.serverException.CqiClErrorOutOfRange;
+import org.txm.searchengine.cqp.serverException.CqiClErrorRegex;
+import org.txm.searchengine.cqp.serverException.CqiClErrorWrongAttributeType;
+import org.txm.searchengine.cqp.serverException.CqiCqpErrorErrorGeneral;
+import org.txm.searchengine.cqp.serverException.CqiCqpErrorInvalidField;
+import org.txm.searchengine.cqp.serverException.CqiCqpErrorNoSuchCorpus;
+import org.txm.searchengine.cqp.serverException.CqiCqpErrorOutOfRange;
+import org.txm.searchengine.cqp.serverException.CqiCqpErrorSyntax;
+import org.txm.searchengine.cqp.serverException.CqiErrorConnectRefused;
+import org.txm.searchengine.cqp.serverException.CqiErrorGeneralError;
+import org.txm.searchengine.cqp.serverException.CqiErrorSyntaxError;
+import org.txm.searchengine.cqp.serverException.CqiErrorUserAbort;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
+import org.txm.utils.ExecTimer;
+import org.txm.utils.logger.Log;
+
+// TODO: Auto-generated Javadoc
+/**
+ * This class implements a Java CQi client.
+ *
+ * @author Jean-Philippe Magué
+ */
+public class NetCqiClient extends AbstractCqiClient {
+
+	/** The socket. */
+	private Socket socket;
+
+	/** The server address. */
+	private SocketAddress serverAddress;
+
+	/** The stream to write data on the socket. */
+	private DataOutput streamToServer;
+
+	/** The stream to read data from the socket. */
+	private DataInput streamFromServer;
+
+	/** The host. */
+	private String host;
+
+	/** The port. */
+	private int port;
+
+	private String username;
+
+	private String password;
+	
+	//key 1 : property name
+	private HashMap<String,CqpDataProxy> corporacache = new HashMap<String, CqpDataProxy>();
+
+	/**
+	 * Write a string on the socket.
+	 * 
+	 * @param string
+	 *            the string
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 */
+	private synchronized void writeString(String string) throws IOException {
+		byte[] bytes = string.getBytes("UTF-8"); //$NON-NLS-1$
+		this.streamToServer.writeShort(bytes.length);
+		this.streamToServer.write(bytes);
+
+		// short length = (short) string.length();
+
+		// long start = System.currentTimeMillis();
+		// this.streamToServer.writeShort(length);
+		// this.streamToServer.write(string.getBytes("UTF-8"));
+		// long end = System.currentTimeMillis();
+		// System.out.println("String \"" + string + "\" writen at " +
+		// (string.getBytes("ISO-8859-1").length/(1+end-start)) +"kb/s");
+
+	}
+
+	/**
+	 * Write a string array on the socket.
+	 * 
+	 * @param strings
+	 *            the string array
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 */
+	private synchronized void writeStringArray(String[] strings)
+			throws IOException {
+		int length = strings.length;
+		this.streamToServer.writeInt(length);
+		for (int i = 0; i < length; i++)
+			writeString(strings[i]);
+	}
+
+	/**
+	 * Write int array on the socket.
+	 * 
+	 * @param ints
+	 *            the int array
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 */
+	private synchronized void writeIntArray(int[] ints) throws IOException {
+		int length = ints.length;
+		this.streamToServer.writeInt(length);
+		for (int i = 0; i < length; i++) {
+			// System.out.println(i+"/"+length);
+			this.streamToServer.writeInt(ints[i]);
+		}
+	}
+
+	/**
+	 * Read a string from the socket.
+	 * 
+	 * @return the string
+	 * 
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             Signals that the cqi server raised an error
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 */
+	private synchronized String readString() throws UnexpectedAnswerException,
+	CqiServerError, IOException {
+		Log.finest(TXMCoreMessages.READING_STRING_FROM_CQI_SERVER);
+		if (readHeaderFromServer() != CQI_DATA_STRING) {
+			throw new UnexpectedAnswerException();
+		}
+		short length = this.streamFromServer.readShort();
+		byte[] bytes = new byte[length];
+		this.streamFromServer.readFully(bytes);
+		String res = new String(bytes, "UTF-8"); //$NON-NLS-1$
+		Log.finest(TXMCoreMessages.bind(TXMCoreMessages.READ_STRING_FROM_CQI_SERVER, res));
+		return res;
+	}
+
+	/**
+	 * Read a boolean from the socket.
+	 * 
+	 * @return the boolean
+	 * 
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             Signals that the cqi server raised an error
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 */
+	private synchronized boolean readBoolean()
+			throws UnexpectedAnswerException, CqiServerError, IOException {
+		byte b = 0;
+		Log.finest(TXMCoreMessages.READING_BOOLEAN_FROM_CQI_SERVER);
+		if (readHeaderFromServer() != CQI_DATA_BOOL) {
+			throw new UnexpectedAnswerException();
+		}
+		b = this.streamFromServer.readByte();
+		boolean res = (b == 1);
+		Log.finest(TXMCoreMessages.READ_BOOLEAN_FROM_CQI_SERVER);
+		return res;
+	}
+
+	/**
+	 * Read an int from the socket.
+	 * 
+	 * @return the int
+	 * 
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             Signals that the cqi server raised an error
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 */
+	private synchronized int readInt() throws UnexpectedAnswerException,
+	CqiServerError, IOException {
+		Log.finest(TXMCoreMessages.READING_INTEGER_FROM_CQI_SERVER);
+		if (readHeaderFromServer() != CQI_DATA_INT) {
+			throw new UnexpectedAnswerException();
+		}
+		int res = this.streamFromServer.readInt();
+		Log.finest(TXMCoreMessages.READ_INTEGER_FROM_CQI_SERVER + res);
+		return res;
+	}
+
+	/**
+	 * Read a string array from the socket.
+	 * 
+	 * @return the string array
+	 * 
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             Signals that the cqi server raised an error
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 */
+	private synchronized String[] readStringArray()
+			throws UnexpectedAnswerException, CqiServerError, IOException {
+		Log.finest(TXMCoreMessages.READING_STRING_ARRAY_FROM_CQI_SERVER);
+		byte[] header = readHeaderFromServer();
+		if (header != CQI_DATA_STRING_LIST) {
+			throw new UnexpectedAnswerException();
+		}
+		// long start = System.currentTimeMillis();
+		int arrayLength = this.streamFromServer.readInt();
+		int nByteRead = 4;
+		String[] strings = new String[arrayLength];
+		/*
+		 * System.out.println("Available: "+this.socket.getInputStream().available
+		 * ()); byte[] allb = readInByte(this.socket.getInputStream());
+		 * 
+		 * System.out.println("count = "+allb.length);
+		 * System.out.println("array length = "+arrayLength);
+		 * 
+		 * int readindex = 0; for(int i=0; i<arrayLength; i++){ short
+		 * stringLength = bytesToShort(allb[readindex],allb[readindex+1]);
+		 * readindex += 2;
+		 * 
+		 * byte[] strbytes = new byte[stringLength]; System.arraycopy(allb,
+		 * readindex, strbytes, 0, stringLength); strings[i] = new
+		 * String(strbytes,"UTF-8");
+		 * //System.out.println(""+i+" Str len "+stringLength
+		 * +" >> "+strings[i]); readindex += stringLength; }
+		 */
+		for (int i = 0; i < arrayLength; i++) {
+			short stringLength = this.streamFromServer.readShort();
+			nByteRead += 2;
+			byte[] bytes = new byte[stringLength];
+			// long start2 = System.currentTimeMillis();
+			this.streamFromServer.readFully(bytes);
+			// long end2 = System.currentTimeMillis();
+			// System.out.println("Reading at " +
+			// (stringLength/(1+end2-start2))+ "kb/s");
+			nByteRead += stringLength;
+			strings[i] = new String(bytes, "UTF-8");//, "ISO-8859-1"); //$NON-NLS-1$
+		}
+		// System.out.println("read : "+nByteRead);
+		// long end = System.currentTimeMillis();
+		// System.out.println(nByteRead + " bytes read in " +(end-start)+ "ms ("
+		// + (nByteRead/(1+end-start)) + "kb/s)");
+		Log.finest(TXMCoreMessages.READ_STRING_ARRAY_FROM_CQI_SERVER
+				+ Arrays.asList(strings));
+		return strings;
+	}
+
+	/**
+	 * Read in byte.
+	 *
+	 * @param in the in
+	 * @return the byte[]
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	private synchronized byte[] readInByte(InputStream in) throws IOException {
+		int count;
+		byte[] buffer = new byte[8192];
+		ByteArrayOutputStream out = new ByteArrayOutputStream();
+		while ((count = in.read(buffer)) > 0) {
+			out.write(buffer, 0, count);
+		}
+		out.close();
+		return out.toByteArray();
+	}
+
+	/**
+	 * Byte array to string.
+	 *
+	 * @param b the b
+	 * @return the string
+	 */
+	private synchronized String byteArrayToString(byte[] b) {
+		StringBuffer res = new StringBuffer("["); //$NON-NLS-1$
+		if (b.length > 0) {
+			res.append(b[0]);
+			for (int i = 1; i < b.length; i++)
+				res.append("; " + b[i]); //$NON-NLS-1$
+		}
+		res.append("]"); //$NON-NLS-1$
+		return res.toString();
+	}
+
+	/**
+	 * Read an int array from the socket.
+	 * 
+	 * @return the int array
+	 * 
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             Signals that the cqi server raised an error
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 */
+	private synchronized int[] readIntList() throws UnexpectedAnswerException,
+	CqiServerError, IOException {
+		Log.finest(TXMCoreMessages.READING_INT_ARRAY_FROM_CQI_SERVER);
+		if ((readHeaderFromServer()) != CQI_DATA_INT_LIST) {
+			throw new UnexpectedAnswerException();
+		}
+		int arrayLength = this.streamFromServer.readInt();
+		int bsize = arrayLength * 4;
+
+		int[] ints = new int[arrayLength];
+		byte[] b = new byte[bsize];// int size
+
+		// System.out.println("bsize : "+bsize);
+		streamFromServer.readFully(b);
+		// System.out.println("read "+ ((DataInputStream)
+		// streamFromServer).readFully(b));
+		int nbline = 0;
+		for (int i = 0; i + 3 < bsize; i += 4) {
+			ints[nbline++] = bytesToInt(b[i], b[i + 1], b[i + 2], b[i + 3]);
+		}
+		/*
+		 * for(int i=0; i<arrayLength; i++){ ints[i] =
+		 * this.streamFromServer.readInt(); }
+		 */
+		// Log.finest(Messages.READ_INT_ARRAY_FROM_CQI_SERVER+Arrays.asList(ints));
+		return ints;
+	}
+
+	/**
+	 * Bytes to int.
+	 *
+	 * @param bytes the bytes
+	 * @return the int
+	 */
+	protected synchronized static int bytesToInt(byte[] bytes) {
+		int value = 0;
+
+		for (int i = 0; i < bytes.length; i++) {
+			value = value << 8;
+			value += bytes[i] & 0xff;
+		}
+
+		return value;
+	}
+
+	/**
+	 * Bytes to int.
+	 *
+	 * @param a the a
+	 * @param b the b
+	 * @param c the c
+	 * @param d the d
+	 * @return the int
+	 */
+	protected synchronized static int bytesToInt(byte a, byte b, byte c, byte d) {
+		return (((a & 0xff) << 24) | ((b & 0xff) << 16) | ((c & 0xff) << 8) | (d & 0xff));
+	}
+
+	/**
+	 * Bytes to short.
+	 *
+	 * @param hi the hi
+	 * @param lo the lo
+	 * @return the short
+	 */
+	protected synchronized static short bytesToShort(byte hi, byte lo) {
+		return (short) (((hi & 0xFF) << 8) | (lo & 0xFF));
+	}
+
+	/**
+	 * Read an int array from the socket.
+	 * 
+	 * @return the int array
+	 * 
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             Signals that the cqi server raised an error
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 */
+	private synchronized int[][] readIntTable()
+			throws UnexpectedAnswerException, CqiServerError, IOException {
+		Log.finest(TXMCoreMessages.READING_2D_INT_ARRAY_FROM_CQI_SERVER);
+		if ((readHeaderFromServer()) != CQI_DATA_INT_TABLE) {
+			throw new UnexpectedAnswerException();
+		}
+		int nRow = this.streamFromServer.readInt();
+		int nCol = this.streamFromServer.readInt();
+		int[][] ints = new int[nRow][nCol];
+		for (int i = 0; i < nRow; i++)
+			for (int j = 0; j < nCol; j++)
+				ints[i][j] = this.streamFromServer.readInt();
+		Log.finest(TXMCoreMessages.READ_2D_INT_ARRAY_FROM_CQI_SERVER
+				+ Arrays.asList(ints));
+		return ints;
+	}
+
+	/**
+	 * Read two successive ints from the socket.
+	 *
+	 * @return an array of size 2 containing the int
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	private synchronized int[] readIntInt() throws IOException,
+	UnexpectedAnswerException, CqiServerError {
+		Log.finest(TXMCoreMessages.READING_INT_ARRAY_FROM_CQI_SERVER);
+		if (readHeaderFromServer() != CQI_DATA_INT_INT) {
+			throw new UnexpectedAnswerException();
+		}
+		int[] res = new int[2];
+		res[0] = this.streamFromServer.readInt();
+		res[1] = this.streamFromServer.readInt();
+		Log.finest(TXMCoreMessages.READ_INT_ARRAY_FROM_CQI_SERVER
+				+ Arrays.asList(res));
+		return res;
+	}
+
+	/**
+	 * Read four successive ints from the socket.
+	 *
+	 * @return an array of size 4 containing the int
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	private synchronized int[] readIntIntIntInt() throws IOException,
+	UnexpectedAnswerException, CqiServerError {
+		Log.finest(TXMCoreMessages.READING_INT_ARRAY_FROM_CQI_SERVER);
+		if (readHeaderFromServer() != CQI_DATA_INT_INT_INT_INT) {
+			throw new UnexpectedAnswerException();
+		}
+		int[] res = new int[4];
+		res[0] = this.streamFromServer.readInt();
+		res[1] = this.streamFromServer.readInt();
+		res[2] = this.streamFromServer.readInt();
+		res[3] = this.streamFromServer.readInt();
+		Log.finest(TXMCoreMessages.READ_INT_ARRAY_FROM_CQI_SERVER
+				+ Arrays.asList(res));
+		return res;
+	}
+
+	/**
+	 * Read the header of the data send by the server.
+	 * 
+	 * @return the header
+	 * 
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             Signals that the cqi server raised an error
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 */
+	private synchronized byte[] readHeaderFromServer()
+			throws UnexpectedAnswerException, CqiServerError, IOException {
+		Log.finest(TXMCoreMessages.READING_HEADER_FROM_CQI_SERVER);
+		byte b = this.streamFromServer.readByte();
+		Log.finest(TXMCoreMessages.bind(TXMCoreMessages.READ_BYTE_FROM_CQI_SERVER, b));
+		switch (b) {
+		case 0x00:// cf cqi.h:29
+			return CQI_PADDING;
+		case 0x01:// cf cqi.h:37
+			b = this.streamFromServer.readByte();
+			Log.finest(TXMCoreMessages.bind(TXMCoreMessages.READ_BYTE_FROM_CQI_SERVER, b));
+			switch (b) {
+			case 0x01:// cf cqi.h:39
+				return CQI_STATUS_OK;
+			case 0x02:// cf cqi.h:40
+				return CQI_STATUS_CONNECT_OK;
+			case 0x03:// cf cqi.h:41
+				return CQI_STATUS_BYE_OK;
+			case 0x04:// cf cqi.h:42
+				return CQI_STATUS_PING_OK;
+			}
+		case 0x02:// cf cqi.h:45
+			b = this.streamFromServer.readByte();
+			Log.finest(TXMCoreMessages.bind(TXMCoreMessages.READ_BYTE_FROM_CQI_SERVER, b));
+			lastError = TXMCoreMessages.MemCqiClient_0+b;
+			switch (b) {
+			case 0x01:// cf cqi.h:39
+				throw new CqiErrorGeneralError();
+			case 0x02:// cf cqi.h:40
+				throw new CqiErrorConnectRefused();
+			case 0x03:// cf cqi.h:41
+				throw new CqiErrorUserAbort();
+			case 0x04:// cf cqi.h:42
+				throw new CqiErrorSyntaxError();
+			}
+		case 0x03:// cf cqi.h:53
+			b = this.streamFromServer.readByte();
+			Log.finest(TXMCoreMessages.bind(TXMCoreMessages.READ_BYTE_FROM_CQI_SERVER, b));
+			switch (b) {
+			case 0x01:// cf cqi.h:39
+				return CQI_DATA_BYTE;
+			case 0x02:// cf cqi.h:40
+				return CQI_DATA_BOOL;
+			case 0x03:// cf cqi.h:41
+				return CQI_DATA_INT;
+			case 0x04:// cf cqi.h:42
+				return CQI_DATA_STRING;
+			case 0x05:// cf cqi.h:42
+				return CQI_DATA_BYTE_LIST;
+			case 0x06:// cf cqi.h:42
+				return CQI_DATA_BOOL_LIST;
+			case 0x07:// cf cqi.h:42
+				return CQI_DATA_INT_LIST;
+			case 0x08:// cf cqi.h:42
+				return CQI_DATA_STRING_LIST;
+			case 0x09:// cf cqi.h:42
+				return CQI_DATA_INT_INT;
+			case 0x0A:// cf cqi.h:42
+				return CQI_DATA_INT_INT_INT_INT;
+			case 0x0B:// cf cqi.h:42
+				return CQI_DATA_INT_TABLE;
+			}
+		case 0x04:// cf cqi.h:67
+
+			b = this.streamFromServer.readByte();
+			lastError = TXMCoreMessages.MemCqiClient_1+b;
+			Log.finest(TXMCoreMessages.bind(TXMCoreMessages.READ_BYTE_FROM_CQI_SERVER, b));
+			switch (b) {
+			case 0x01:// cf cqi.h:39
+				throw new CqiClErrorNoSuchAttribute();
+			case 0x02:// cf cqi.h:40
+				throw new CqiClErrorWrongAttributeType();
+			case 0x03:// cf cqi.h:41
+				throw new CqiClErrorOutOfRange();
+			case 0x04:// cf cqi.h:42
+				lastError = getLastCqiError();
+				throw new CqiClErrorRegex();
+			case 0x05:// cf cqi.h:42
+				throw new CqiClErrorCorpusAccess();
+			case 0x06:// cf cqi.h:42
+				throw new CqiClErrorOutOfMemory();
+			case 0x07:// cf cqi.h:42
+				throw new CqiClErrorInternal();
+			}
+		case 0x05:// cf cqi.h:94
+
+			b = this.streamFromServer.readByte();
+			lastError = TXMCoreMessages.MemCqiClient_2+b;
+			Log.finest(TXMCoreMessages.bind(TXMCoreMessages.READ_BYTE_FROM_CQI_SERVER, b));
+			switch (b) {
+			case 0x01:// cf cqi.h:39
+				throw new CqiCqpErrorErrorGeneral();
+			case 0x02:// cf cqi.h:40
+				throw new CqiCqpErrorNoSuchCorpus();
+			case 0x03:// cf cqi.h:41
+				throw new CqiCqpErrorInvalidField();
+			case 0x04:// cf cqi.h:42
+				throw new CqiCqpErrorOutOfRange();
+			case 0x05:// cf cqi.h:44
+				lastError = getLastCQPError();
+				throw new CqiCqpErrorSyntax();
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * Ask the server to execute a function with a String->String signature.
+	 *
+	 * @param string the argument
+	 * @param function the function to be executed
+	 * @return the result
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	private synchronized String genericStringToString(String string,
+			byte[] function) throws UnexpectedAnswerException, IOException,
+			CqiServerError {
+		this.streamToServer.write(function);
+		this.writeString(string);
+		return readString();
+	}
+
+	/**
+	 * Ask the server to execute a function with a String->StringArray signature.
+	 *
+	 * @param string the argument
+	 * @param function the function to be executed
+	 * @return the result
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	private synchronized String[] genericStringToStringArray(String string,
+			byte[] function) throws UnexpectedAnswerException, IOException,
+			CqiServerError {
+		this.streamToServer.write(function);
+		this.writeString(string);
+		return readStringArray();
+	}
+
+	/**
+	 * Ask the server to execute a function with a String x int[]->String[]
+	 * signature.
+	 *
+	 * @param string the string argument
+	 * @param ints the int[] argument
+	 * @param function the function to be executed
+	 * @return the result
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	private synchronized String[] genericStringXIntArraytoStringArray(
+			String string, int[] ints, byte[] function) throws IOException,
+			UnexpectedAnswerException, CqiServerError {
+		// long start = System.currentTimeMillis();
+		this.streamToServer.write(function);
+		// System.out.println(System.currentTimeMillis()-start);
+		this.writeString(string);
+		// System.out.println(System.currentTimeMillis()-start);
+		this.writeIntArray(ints);
+		// System.out.println(System.currentTimeMillis()-start);
+		String[] res = readStringArray();
+		// System.out.println(System.currentTimeMillis()-start);
+		return res;
+	}
+
+	/**
+	 * Ask the server to execute a function with a String x int[]->int[]
+	 * signature.
+	 *
+	 * @param string the string argument
+	 * @param ints the int[] argument
+	 * @param function the function to be executed
+	 * @return the result
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	private synchronized int[] genericStringXIntArraytoIntArray(String string,
+			int[] ints, byte[] function) throws UnexpectedAnswerException,
+			CqiServerError, IOException {
+		this.streamToServer.write(function);
+		this.writeString(string);
+		this.writeIntArray(ints);
+		return readIntList();
+	}
+
+	/**
+	 * Instantiates a new cqi client.
+	 * 
+	 * @param host
+	 *            the host of the CQI server
+	 * @param port
+	 *            the port of the CQI server
+	 * 
+	 * @throws ServerNotFoundException
+	 *             the server not found exception
+	 */
+	public NetCqiClient(String host, int port) throws ServerNotFoundException {
+		try {
+			Thread.sleep(500);
+		} catch (InterruptedException ix) {
+		}
+
+		int attempts = 10;
+		while (attempts > 0) {
+			try {
+				this.host = host;
+				this.port = port;
+				this.socket = new Socket();
+				this.serverAddress = new InetSocketAddress(host, port);
+				this.socket.connect(serverAddress);
+				this.streamToServer = new DataOutputStream(this.socket
+						.getOutputStream());
+				this.streamFromServer = new DataInputStream(this.socket
+						.getInputStream());
+				System.out.print(TXMCoreMessages.CqiClient_32);
+				return;
+			} catch (IOException e) {
+				System.err.print("."); //$NON-NLS-1$
+				try {
+					Thread.sleep(2000);
+				} catch (InterruptedException ix) {
+				}
+			}
+
+			attempts--;
+		}
+		throw new ServerNotFoundException(TXMCoreMessages.CqiClient_33);
+	}
+
+	// CQI_ERROR_CONNECT_REFUSED
+	/**
+	 * Connect the client to a server.
+	 *
+	 * @param username the username
+	 * @param password the password
+	 * @return true, if successful
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized boolean connect(String username, String password)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		this.username = username;
+		this.password = password;
+		Log.finest(TXMCoreMessages.CONNECTING_CQI_CLIENT + username
+				+ ":" + password + "@" + host + ":" + port); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		this.streamToServer.write(CQI_CTRL_CONNECT);
+		this.writeString(username);
+		this.writeString(password);
+		try {
+			readHeaderFromServer();
+			Log.finest(TXMCoreMessages.CQI_CLIENT_CONNECTED);
+			return true;
+		} catch (CqiErrorConnectRefused e) {
+			return false;
+		} catch (CqiServerError e) {
+			return false;
+		}
+	}
+
+	// None
+	/**
+	 * Disconnect.
+	 * 
+	 * @return true, if successful
+	 * 
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             Signals that the cqi server raised an error
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 */
+	@Override
+	public synchronized boolean disconnect() throws UnexpectedAnswerException,
+	CqiServerError, IOException {
+		this.streamToServer.write(CQI_CTRL_BYE);
+		return (readHeaderFromServer() == CQI_STATUS_BYE_OK);
+	}
+
+	String lastError;
+	@Override
+	public synchronized String getLastError(){	
+		if(lastError != null && lastError.length() > 0)
+			return lastError;
+		return TXMCoreMessages.AbstractCqiClient_2;
+	}
+
+	// CQI_CTRL_LAST_GENERAL_ERROR
+	/**
+	 * return the last CQP error.
+	 *
+	 * @return the last error
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized String getLastCqiError() throws UnexpectedAnswerException, IOException,
+	CqiServerError {
+		Log.severe(TXMCoreMessages.CqiClient_0);
+		this.streamToServer.write(CQI_CTRL_LAST_GENERAL_ERROR);
+
+		try {
+			String ret = readString();
+			return getLastCQPError()+"\t"+ret; //$NON-NLS-1$
+		} catch (CqiServerError e) {
+			System.out.println(TXMCoreMessages.NetCqiClient_1+e);
+			return "error"; //$NON-NLS-1$
+		}
+	}
+
+	// CQI_CTRL_LAST_CQP_ERROR
+	/**
+	 * return the last CQP error.
+	 *
+	 * @return the last error
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized String getLastCQPError() {
+		try {
+			this.streamToServer.write(CQI_CTRL_LAST_CQP_ERROR);
+			String ret = readString();
+			return ret;
+		} catch (Exception e) {
+			System.out.println(TXMCoreMessages.NetCqiClient_3+e);
+			return "error"; //$NON-NLS-1$
+		}
+	}
+
+	// None
+	/**
+	 * Lists the corpora available on the server.
+	 *
+	 * @return the name of the corpora
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized String[] listCorpora()
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		this.streamToServer.write(CQI_CORPUS_LIST_CORPORA);
+		return readStringArray();
+	}
+
+	// None
+	/**
+	 * Gives the corpus charset.
+	 *
+	 * @param corpus the corpus
+	 * @return the name of the charset
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized String corpusCharset(String corpus)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return genericStringToString(corpus, CQI_CORPUS_CHARSET);
+	}
+
+	// None (not really implemented anyway)
+	/**
+	 * Gives the corpus properties.
+	 *
+	 * @param corpus the corpus
+	 * @return the properties
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized String[] corpusProperties(String corpus)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return genericStringToStringArray(corpus, CQI_CORPUS_PROPERTIES);
+	}
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS
+	/**
+	 * Gives the corpus positional attributes.
+	 *
+	 * @param corpusID the corpus id
+	 * @return the name of the attributes
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized String[] corpusPositionalAttributes(String corpusID)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return genericStringToStringArray(corpusID,
+				CQI_CORPUS_POSITIONAL_ATTRIBUTES);
+	}
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS
+	/**
+	 * Gives the corpus structural attributes.
+	 *
+	 * @param corpus the corpus
+	 * @return the name of the attributes
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized String[] corpusStructuralAttributes(String corpus)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return genericStringToStringArray(corpus,
+				CQI_CORPUS_STRUCTURAL_ATTRIBUTES);
+	}
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS, CQI_CL_ERROR_NO_SUCH_ATTRIBUTE,
+	// CQI_CL_ERROR_WRONG_ATTRIBUTE_TYPE
+	/**
+	 * Check wether a structural attribute has values.
+	 *
+	 * @param attribute the attribute
+	 * @return true, if it has values
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized boolean corpusStructuralAttributeHasValues(
+			String attribute) throws UnexpectedAnswerException, IOException,
+			CqiServerError {
+		this.streamToServer.write(CQI_CORPUS_STRUCTURAL_ATTRIBUTE_HAS_VALUES);
+		this.writeString(attribute);
+		return readBoolean();
+	}
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS
+	/**
+	 * Gives the corpus alignement attributes.
+	 *
+	 * @param corpus the corpus
+	 * @return the name of attributes
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized String[] corpusAlignementAttributes(String corpus)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return genericStringToStringArray(corpus,
+				CQI_CORPUS_ALIGNMENT_ATTRIBUTES);
+	}
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS
+	/**
+	 * Gives the corpus full name.
+	 *
+	 * @param corpus the corpus
+	 * @return the full name
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized String corpusFullName(String corpus)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return genericStringToString(corpus, CQI_CORPUS_FULL_NAME);
+	}
+
+	/**
+	 * Gives the corpus info listed in the .INFO file.
+	 *
+	 * @param corpus the corpus
+	 * @return the info
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized String[] corpusInfo(String corpus)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		throw new UnsupportedOperationException();
+	}
+
+	/**
+	 * Drop a corpus.
+	 * 
+	 * @param corpus
+	 *            the corpus
+	 */
+	@Override
+	public synchronized void dropCorpus(String corpus) {
+		throw new UnsupportedOperationException();
+	}
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS, CQI_CL_ERROR_NO_SUCH_ATTRIBUTE,
+	// CQI_CL_ERROR_WRONG_ATTRIBUTE_TYPE, CQI_CL_ERROR_CORPUS_ACCESS
+	/**
+	 * Gives an attribute size (the number of token).
+	 *
+	 * @param attribute the attribute
+	 * @return the size
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized int attributeSize(String attribute) throws IOException,
+	UnexpectedAnswerException, CqiServerError {
+		this.streamToServer.write(CQI_CL_ATTRIBUTE_SIZE);
+		this.writeString(attribute);
+		return readInt();
+	}
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS, CQI_CL_ERROR_NO_SUCH_ATTRIBUTE,
+	// CQI_CL_ERROR_WRONG_ATTRIBUTE_TYPE, CQI_CL_ERROR_CORPUS_ACCESS
+	/**
+	 * Gives the lexicon size of an attribute.
+	 *
+	 * @param attribute the attribute
+	 * @return the int
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 * @returns the number of entries in the lexicon of a positional attribute
+	 */
+	@Override
+	public synchronized int lexiconSize(String attribute) throws IOException,
+	UnexpectedAnswerException, CqiServerError {
+		this.streamToServer.write(CQI_CL_LEXICON_SIZE);
+		this.writeString(attribute);
+		return readInt();
+	}
+
+	/**
+	 * Drop attribute.
+	 *
+	 * @param attribute the attribute
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized void dropAttribute(String attribute)
+			throws IOException, UnexpectedAnswerException, CqiServerError {
+		throw new UnsupportedOperationException();
+	}
+
+	/**
+	 * Converts an array of attribute values to their ID.
+	 *
+	 * @param attribute the attribute
+	 * @param strings the values
+	 * @return the IDs
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized int[] str2Id(String attribute, String[] strings)
+			throws IOException, UnexpectedAnswerException, CqiServerError {
+		this.streamToServer.write(CQI_CL_STR2ID);
+		this.writeString(attribute);
+		this.writeStringArray(strings);
+		return readIntList();
+	}
+
+	/**
+	 * Converts an array of attribute ID to their values.
+	 *
+	 * @param attribute the positional attribute
+	 * @param ids the ids
+	 * @return the values
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized String[] id2Str(String attribute, int[] ids)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+
+		return genericStringXIntArraytoStringArray(attribute, ids,
+				CQI_CL_ID2STR);
+	}
+
+	/**
+	 * Converts an array of attribute IDs to their frequency.
+	 *
+	 * @param attribute the attribute
+	 * @param ids the ids
+	 * @return the frequencies
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized int[] id2Freq(String attribute, int[] ids)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return genericStringXIntArraytoIntArray(attribute, ids, CQI_CL_ID2FREQ);
+	}
+
+	/**
+	 * Converts an array of position to their ID given an attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the positions
+	 * @return the IDs
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public synchronized int[] cpos2Id(String attribute, int[] cpos)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return genericStringXIntArraytoIntArray(attribute, cpos, CQI_CL_CPOS2ID);
+	}
+
+	/**
+	 * Converts an array of position to their value given an attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the cpos
+	 * @return the values
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public synchronized String[] cpos2Str(String attribute, int[] cpos)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		
+		if (corporacache.get(attribute) == null) {
+			corporacache.put(attribute, new CqpDataProxy(this, attribute, true));
+		}
+		
+		try {
+			return corporacache.get(attribute).getData(cpos).toArray(new String[cpos.length]);
+		} catch (CqiClientException e) {
+			throw new CqiServerError(e.getMessage());
+		}
+//		return genericStringXIntArraytoStringArray(attribute, cpos,
+//				CQI_CL_CPOS2STR);
+	}
+	
+	public synchronized String[] _cpos2Str(String attribute, int[] cpos)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return genericStringXIntArraytoStringArray(attribute, cpos,
+				CQI_CL_CPOS2STR);
+	}
+
+	/**
+	 * Computes for each position of an array the Id of the enclosing structural
+	 * attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the positions
+	 * @return the IDs
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public synchronized int[] cpos2Struc(String attribute, int[] cpos)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return genericStringXIntArraytoIntArray(attribute, cpos,
+				CQI_CL_CPOS2STRUC);
+	}
+
+	/**
+	 * Computes for each position of an array the position of the left boundary
+	 * of the enclosing structural attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the cpos
+	 * @return the positions of the left boundaries
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public synchronized int[] cpos2LBound(String attribute, int[] cpos)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return genericStringXIntArraytoIntArray(attribute, cpos,
+				CQI_CL_CPOS2LBOUND);
+	}
+
+	/**
+	 * Computes for each position of an array the position of the right boundary
+	 * of the enclosing structural attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the cpos
+	 * @return the positions of the right boundaries
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public synchronized int[] cpos2RBound(String attribute, int[] cpos)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return genericStringXIntArraytoIntArray(attribute, cpos,
+				CQI_CL_CPOS2RBOUND);
+	}
+
+	/**
+	 * Computes for each position of an array the Id of the enclosing alignment
+	 * attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the cpos
+	 * @return the int[]
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public synchronized int[] cpos2Alg(String attribute, int[] cpos)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return genericStringXIntArraytoIntArray(attribute, cpos,
+				CQI_CL_CPOS2ALG);
+	}
+
+	/**
+	 * Retrieves annotated string values of structure regions in <strucs>; "" if
+	 * out of range.
+	 *
+	 * @param attribute the attribute
+	 * @param strucs the strucs
+	 * @return the string[]
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public synchronized String[] struc2Str(String attribute, int[] strucs)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return _struc2Str(attribute, strucs);
+	}
+	
+	/**
+	 * Retrieves annotated string values of structure regions in <strucs>; "" if
+	 * out of range.
+	 *
+	 * @param attribute the attribute
+	 * @param strucs the strucs
+	 * @return the string[]
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	public synchronized String[] _struc2Str(String attribute, int[] strucs)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return genericStringXIntArraytoStringArray(attribute, strucs,
+				CQI_CL_STRUC2STR);
+	}
+
+	/**
+	 * Retrieves all corpus positions where the given token occurs.
+	 *
+	 * @param attribute the attribute
+	 * @param id the id
+	 * @return the position
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public synchronized int[] id2Cpos(String attribute, int id)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		this.streamToServer.write(CQI_CL_ID2CPOS);
+		this.writeString(attribute);
+		this.streamToServer.writeInt(id);
+		return readIntList();
+	}
+
+	/**
+	 * Retrieves all corpus positions where one of the tokens in <id_list>
+	 * occurs; the returned list is sorted as a whole, not per token id.
+	 *
+	 * @param attribute the attribute
+	 * @param ids the ids
+	 * @return the positions
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public synchronized int[] idList2Cpos(String attribute, int[] ids)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		return genericStringXIntArraytoIntArray(attribute, ids,
+				CQI_CL_IDLIST2CPOS);
+	}
+
+	/**
+	 * Retrieves the lexicon IDs of all tokens that match <regex>; the returned
+	 * list may be empty (size 0);.
+	 *
+	 * @param attribute the attribute
+	 * @param regex the regex
+	 * @return the IDs
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public synchronized int[] regex2Id(String attribute, String regex)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		this.streamToServer.write(CQI_CL_REGEX2ID);
+		this.writeString(attribute);
+		this.writeString(regex);
+		return readIntList();
+	}
+
+	/**
+	 * Retrieves the start and end corpus positions of structure region <struc>.
+	 *
+	 * @param attribute the attribute
+	 * @param struc the struc
+	 * @return an array of size 2 containing the start and end positions
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public synchronized int[] struc2Cpos(String attribute, int struc)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		this.streamToServer.write(CQI_CL_STRUC2CPOS);
+		this.writeString(attribute);
+		this.streamToServer.writeInt(struc);
+		return this.readIntInt();
+	}
+
+	/**
+	 * Retrieves start and end corpus positions of an alignement region in the
+	 * source and target corpora<struc>.
+	 *
+	 * @param attribute the attribute
+	 * @param struc the struc
+	 * @return an array of size 4 containing (src_start, src_end, target_start,
+	 * target_end)
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public synchronized int[] alg2Cpos(String attribute, int struc)
+			throws UnexpectedAnswerException, IOException, CqiServerError {
+		this.streamToServer.write(CQI_CL_ALG2CPOS);
+		this.writeString(attribute);
+		this.streamToServer.writeInt(struc);
+		return readIntIntIntInt();
+	}
+
+	/**
+	 * Runs a CQP query.
+	 *
+	 * @param motherCorpus the mother corpus
+	 * @param subcorpus the subcorpus
+	 * @param query the query
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public synchronized void cqpQuery(String motherCorpus, String subcorpus,
+			String query) throws IOException, UnexpectedAnswerException, CqiServerError {
+		//System.out.println("CQPQUERY: Mother: "+motherCorpus+", sub:"+subcorpus+", "+query);
+		this.streamToServer.write(CQI_CQP_QUERY);
+		this.writeString(motherCorpus);
+		this.writeString(subcorpus);
+		this.writeString(query);
+		this.readHeaderFromServer(); // may receive a CQI_CQP_ERROR_GENERAL
+
+	}
+	
+	/**
+	 * Evaluate and run a raw CQP query.
+	 *
+	 * @param motherCorpus the mother corpus
+	 * @param subcorpus the subcorpus
+	 * @param query the query
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError the cqi server error
+	 */
+	public synchronized void query(String query) throws IOException, UnexpectedAnswerException, CqiServerError {
+		//System.out.println("CQPQUERY: Mother: "+motherCorpus+", sub:"+subcorpus+", "+query);
+		this.streamToServer.write(CQI_CQP_QUERY_EVAL);
+		this.writeString(query);
+		this.readHeaderFromServer(); // may receive a CQI_CQP_ERROR_GENERAL
+
+	}
+
+	/**
+	 * Lists all the subcorpora of a corpus.
+	 *
+	 * @param corpus the corpus
+	 * @return the name of the subcorpora
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiCqpErrorNoSuchCorpus the cqi cqp error no such corpus
+	 */
+	@Override
+	public synchronized String[] listSubcorpora(String corpus)
+			throws UnexpectedAnswerException, IOException, CqiCqpErrorNoSuchCorpus {
+		try {
+			return genericStringToStringArray(corpus, CQI_CQP_LIST_SUBCORPORA);
+		} catch (CqiCqpErrorNoSuchCorpus e) {
+			throw e;
+		} catch (CqiServerError e) {
+			throw new UnexpectedAnswerException(e);
+		}
+	}
+
+	/**
+	 * Gives the size of a subcorpus .
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * 
+	 * @return the size
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	@Override
+	public synchronized int subCorpusSize(String subcorpus) throws IOException,
+	UnexpectedAnswerException, CqiServerError {
+		this.streamToServer.write(CQI_CQP_SUBCORPUS_SIZE);
+		this.writeString(subcorpus);
+		return this.readInt();
+	}
+
+	/**
+	 * Checks wether a subcorpus has a field.
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * @param field
+	 *            the field
+	 * 
+	 * @return true, if the subcorpus has the field
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	@Override
+	public synchronized boolean subCorpusHasField(String subcorpus, byte field)
+			throws IOException, UnexpectedAnswerException, CqiServerError {
+		this.streamToServer.write(CQI_CQP_SUBCORPUS_HAS_FIELD);
+		this.writeString(subcorpus);
+		this.streamToServer.writeByte(field);
+		return this.readBoolean();
+	}
+
+	/**
+	 * Dumps the values of <field> for match ranges <first> .. <last> in
+	 * <subcorpus>. <field> is one of the CQI_CONST_FIELD_* constants.
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * @param field
+	 *            the field
+	 * @param first
+	 *            the first
+	 * @param last
+	 *            the last
+	 * 
+	 * @return the values
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	@Override
+	public synchronized int[] dumpSubCorpus(String subcorpus, byte field,
+			int first, int last) throws IOException, UnexpectedAnswerException,
+			CqiServerError {
+		this.streamToServer.write(CQI_CQP_DUMP_SUBCORPUS);
+		this.writeString(subcorpus);
+		this.streamToServer.writeByte(field);
+		this.streamToServer.writeInt(first);
+		this.streamToServer.writeInt(last);
+		return this.readIntList();
+	}
+
+	/**
+	 * Drops a subcorpus.
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	@Override
+	public synchronized void dropSubCorpus(String subcorpus) throws IOException,
+	UnexpectedAnswerException, CqiServerError {
+		this.streamToServer.write(CQI_CQP_DROP_SUBCORPUS);
+		this.writeString(subcorpus);
+		this.readHeaderFromServer();
+	}
+
+	/**
+	 * Returns <n> (id, frequency) pairs flattened into a list of size 2*<n> NB:
+	 * pairs are sorted by frequency desc.
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * @param cutoff
+	 *            the cutoff
+	 * @param field
+	 *            the field : one of CQI_CONST_FIELD_MATCH,
+	 *            CQI_CONST_FIELD_TARGET, CQI_CONST_FIELD_KEYWORD
+	 * @param attribute
+	 *            the attribute
+	 * 
+	 * @return the int[][]
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	@Override
+	public synchronized int[][] fdist1(String subcorpus, int cutoff,
+			byte field, String attribute) throws IOException,
+			UnexpectedAnswerException, CqiServerError {
+		this.streamToServer.write(CQI_CQP_FDIST_1);
+		this.writeString(subcorpus);
+		this.streamToServer.writeInt(cutoff);
+		this.streamToServer.writeByte(field);
+		this.writeString(attribute);
+		return this.readIntTable();
+	}
+
+	/**
+	 * Returns <n> (id1, id2, frequency) pairs flattened into a list of size
+	 * 3*<n> NB: triples are sorted by frequency desc. .
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * @param cutoff
+	 *            the cutoff
+	 * @param field1
+	 *            the field1
+	 * @param attribute1
+	 *            the attribute1
+	 * @param field2
+	 *            the field2
+	 * @param attribute2
+	 *            the attribute2
+	 * 
+	 * @return the int[]
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	@Override
+	public synchronized int[][] fdist2(String subcorpus, int cutoff,
+			byte field1, String attribute1, byte field2, String attribute2)
+					throws IOException, UnexpectedAnswerException, CqiServerError {
+		this.streamToServer.write(CQI_CQP_FDIST_1);
+		this.writeString(subcorpus);
+		this.streamToServer.writeInt(cutoff);
+		this.streamToServer.writeByte(field1);
+		this.writeString(attribute1);
+		this.streamToServer.writeByte(field2);
+		this.writeString(attribute2);
+		return this.readIntTable();
+	}
+
+	@Override
+	public boolean reconnect() {
+		try {
+			return connect(username, password);
+		} catch (Exception e) {
+			System.out.println(TXMCoreMessages.NetCqiClient_5+e);
+			return false;
+		}
+	}
+
+	/**
+	 * @param args
+	 * @throws Exception 
+	 */
+	public static void main(String[] args) throws Exception {
+		String pathToExecutable = "/usr/lib/TXM/cwb/bin/cqpserver"; //$NON-NLS-1$
+		String pathToRegistry = "/home/mdecorde/TXM/registry"; //$NON-NLS-1$
+		String pathToInitFile = "/usr/lib/TXM/cwb/cqpserver.init"; //$NON-NLS-1$
+
+		String corpus = "DISCOURS"; //$NON-NLS-1$
+		String subcorpusname = "SUB"; //$NON-NLS-1$
+		String subcorpusid = corpus+":"+subcorpusname; //$NON-NLS-1$
+		String query = "[word=\"j.*\"]"; //$NON-NLS-1$
+		String regex = "j.*"; //$NON-NLS-1$
+		String pattribute1 = corpus+".word"; //$NON-NLS-1$
+		String pattribute2 = corpus+".frpos"; //$NON-NLS-1$
+		String pattribute3 = corpus+".frlemma"; //$NON-NLS-1$
+		String sattribute1 = corpus+".text_id"; //$NON-NLS-1$
+		String sattribute2 = corpus+".p_id"; //$NON-NLS-1$
+		String sattribute3 = corpus+".s_id"; //$NON-NLS-1$
+		
+		String align_attr = "p_id"; //$NON-NLS-1$
+
+		int[] cpos = {0,1,2,3,4,5,6,7,8,9,10};
+//		int id = 1;
+		int[] ids = {0,1,2,3,4,5,6,7,8,9,10};
+		String[] strings = {"je", "jamais"}; //$NON-NLS-1$ //$NON-NLS-2$
+		int[] strucpos = {0, 1, 2, 3 , 4};
+
+		NetCqiServer server = new NetCqiServer(pathToExecutable, pathToRegistry, pathToInitFile, "", false); //$NON-NLS-1$
+		if (server.start()) System.out.println("Server ok"); //$NON-NLS-1$
+		NetCqiClient client = new NetCqiClient("127.0.0.1", 4877); //$NON-NLS-1$
+		if (client.connect("anonymous", "")) System.out.println("Client ok"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+		ExecTimer.start();
+		try {
+			System.out.println("client.alg2Cpos(sattribute, struct_id) : "+Arrays.toString(client.alg2Cpos(sattribute1, 0))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.attributeSize(sattribute1) : "+client.attributeSize(sattribute1)); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.attributeSize(sattribute2) : "+client.attributeSize(sattribute2)); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		
+		try {
+			System.out.println("client.attributeSize(sattribute3) : "+client.attributeSize(sattribute3)); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		
+		try {
+			System.out.println("client.corpusAlignementAttributes(corpus) : "+Arrays.toString(client.corpusAlignementAttributes(corpus))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.corpusCharset(corpus) : "+client.corpusCharset(corpus)); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.corpusFullName(corpus) : "+client.corpusFullName(corpus)); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.corpusInfo(corpus) : "+client.corpusInfo(corpus)); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.corpusPositionalAttributes(corpus) : "+Arrays.toString(client.corpusPositionalAttributes(corpus))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.corpusProperties(corpus) : "+Arrays.toString(client.corpusProperties(corpus))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.corpusStructuralAttributeHasValues(sattribute1) : "+client.corpusStructuralAttributeHasValues(sattribute1)); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.corpusStructuralAttributeHasValues(sattribute2) : "+client.corpusStructuralAttributeHasValues(sattribute2)); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.corpusStructuralAttributeHasValues(sattribute3) : "+client.corpusStructuralAttributeHasValues(sattribute3)); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		
+		try {
+			System.out.println("client.corpusStructuralAttributes(corpus) : "+Arrays.toString(client.corpusStructuralAttributes(corpus))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.cpos2Alg(align_attr, cpos) : "+Arrays.toString(client.cpos2Alg(align_attr, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.cpos2Id(pattribute1, cpos) : "+Arrays.toString(client.cpos2Id(pattribute1, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.cpos2Id(pattribute2, cpos) : "+Arrays.toString(client.cpos2Id(pattribute2, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.cpos2Id(pattribute3, cpos) : "+Arrays.toString(client.cpos2Id(pattribute3, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.cpos2LBound(sattribute1, cpos) : "+Arrays.toString(client.cpos2LBound(sattribute1, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.cpos2LBound(sattribute2, cpos) : "+Arrays.toString(client.cpos2LBound(sattribute2, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.cpos2LBound(sattribute3, cpos) : "+Arrays.toString(client.cpos2LBound(sattribute3, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.cpos2RBound(sattribute1, cpos) : "+Arrays.toString(client.cpos2RBound(sattribute1, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.cpos2RBound(sattribute2, cpos) : "+Arrays.toString(client.cpos2RBound(sattribute2, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.cpos2RBound(sattribute3, cpos) : "+Arrays.toString(client.cpos2RBound(sattribute3, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.cpos2Str(pattribute1, cpos) : "+Arrays.toString(client.cpos2Str(pattribute1, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.cpos2Str(pattribute2, cpos) : "+Arrays.toString(client.cpos2Str(pattribute2, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.cpos2Str(pattribute3, cpos) : "+Arrays.toString(client.cpos2Str(pattribute3, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.cpos2Struc(sattribute1, cpos) : "+Arrays.toString(client.cpos2Struc(sattribute1, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.cpos2Struc(sattribute2, cpos) : "+Arrays.toString(client.cpos2Struc(sattribute2, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.cpos2Struc(sattribute3, cpos) : "+Arrays.toString(client.cpos2Struc(sattribute3, cpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.cqpQuery(corpus, subcorpus, query)");client.cqpQuery(corpus, subcorpusname, query); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.dropAttribute(pattribute1)");client.dropAttribute(pattribute1); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.dropAttribute(pattribute2)");client.dropAttribute(pattribute2); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.dropAttribute(pattribute3)");client.dropAttribute(pattribute3); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.dropCorpus(corpus)");client.dropCorpus(corpus); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println(TXMCoreMessages.NetCqiClient_97+Arrays.toString(client.dumpSubCorpus(subcorpusid, NetCqiClient.CQI_CONST_FIELD_MATCH, 1, 10)));
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.dumpSubCorpus(subcorpus, NetCqiClient.CQI_CONST_FIELD_MATCHEND, 1, 2) : "+Arrays.toString(client.dumpSubCorpus(subcorpusid, NetCqiClient.CQI_CONST_FIELD_MATCHEND, 1, 10))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			//System.out.println("//client.fdist1(arg0, arg1, arg2, arg3) : "+client.fdist1(arg0, arg1, arg2, arg3));
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			//System.out.println("//client.fdist2(arg0, arg1, arg2, arg3, arg4, arg5) : "+client.fdist2(arg0, arg1, arg2, arg3, arg4, arg5));
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.getLastCqiError() : "+client.getLastCqiError()); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.getLastCQPError() : "+client.getLastCQPError()); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.id2Cpos(pattribute1, 0) : "+Arrays.toString(client.id2Cpos(pattribute1, 0))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.id2Cpos(pattribute2, 0) : "+Arrays.toString(client.id2Cpos(pattribute2, 0))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.id2Cpos(pattribute3, 0) : "+Arrays.toString(client.id2Cpos(pattribute3, 0))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		
+		try {
+			System.out.println("client.id2Cpos(pattribute1, 1) : "+Arrays.toString(client.id2Cpos(pattribute1, 1))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.id2Cpos(pattribute2, 1) : "+Arrays.toString(client.id2Cpos(pattribute2, 1))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.id2Cpos(pattribute3, 1) : "+Arrays.toString(client.id2Cpos(pattribute3, 1))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		
+		try {
+			System.out.println("client.id2Cpos(pattribute1, 2) : "+Arrays.toString(client.id2Cpos(pattribute1, 2))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.id2Cpos(pattribute2, 2) : "+Arrays.toString(client.id2Cpos(pattribute2, 2))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.id2Cpos(pattribute3, 2) : "+Arrays.toString(client.id2Cpos(pattribute3, 2))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.id2Freq(pattribute1, ids) : "+Arrays.toString(client.id2Freq(pattribute1, ids))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.id2Freq(pattribute2, ids) : "+Arrays.toString(client.id2Freq(pattribute2, ids))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.id2Freq(pattribute3, ids) : "+Arrays.toString(client.id2Freq(pattribute3, ids))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.id2Str(pattribute1, ids) : "+Arrays.toString(client.id2Str(pattribute1, ids))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.id2Str(pattribute2, ids) : "+Arrays.toString(client.id2Str(pattribute2, ids))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.id2Str(pattribute3, ids) : "+Arrays.toString(client.id2Str(pattribute3, ids))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.idList2Cpos(pattribute1, ids) : "+Arrays.toString(client.idList2Cpos(pattribute1, ids))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.idList2Cpos(pattribute2, ids) : "+Arrays.toString(client.idList2Cpos(pattribute2, ids))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.idList2Cpos(pattribute3, ids) : "+Arrays.toString(client.idList2Cpos(pattribute3, ids))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.lexiconSize(pattribute1) : "+client.lexiconSize(pattribute1)); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.lexiconSize(pattribute2) : "+client.lexiconSize(pattribute2)); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.lexiconSize(pattribute3) : "+client.lexiconSize(pattribute3)); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.listCorpora() : "+Arrays.toString(client.listCorpora())); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.listSubcorpora(corpus) : "+Arrays.toString(client.listSubcorpora(corpus))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.regex2Id(pattribute1, regex) : "+Arrays.toString(client.regex2Id(pattribute1, regex))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.regex2Id(pattribute2, regex) : "+Arrays.toString(client.regex2Id(pattribute2, regex))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.regex2Id(pattribute3, regex) : "+Arrays.toString(client.regex2Id(pattribute3, regex))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.str2Id(pattribute1, strings) : "+Arrays.toString(client.str2Id(pattribute1, strings))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.str2Id(pattribute2, strings) : "+Arrays.toString(client.str2Id(pattribute2, strings))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.str2Id(pattribute3, strings) : "+Arrays.toString(client.str2Id(pattribute3, strings))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.struc2Cpos(sattribute1, 0) : "+Arrays.toString(client.struc2Cpos(sattribute1, 0))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.struc2Cpos(sattribute2, 0) : "+Arrays.toString(client.struc2Cpos(sattribute2, 0))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.struc2Cpos(sattribute3, 0) : "+Arrays.toString(client.struc2Cpos(sattribute3, 0))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		
+		try {
+			System.out.println("client.struc2Cpos(sattribute1, 1) : "+Arrays.toString(client.struc2Cpos(sattribute1, 1))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.struc2Cpos(sattribute2, 1) : "+Arrays.toString(client.struc2Cpos(sattribute2, 1))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.struc2Cpos(sattribute3, 1) : "+Arrays.toString(client.struc2Cpos(sattribute3, 1))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		
+		try {
+			System.out.println("client.struc2Cpos(sattribute1, 2) : "+Arrays.toString(client.struc2Cpos(sattribute1, 2))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.struc2Cpos(sattribute2, 2) : "+Arrays.toString(client.struc2Cpos(sattribute2, 2))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.struc2Cpos(sattribute3, 2) : "+Arrays.toString(client.struc2Cpos(sattribute3, 2))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		
+		try {
+			System.out.println("client.struc2Cpos(sattribute1, 3) : "+Arrays.toString(client.struc2Cpos(sattribute1, 3))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.struc2Cpos(sattribute2, 3) : "+Arrays.toString(client.struc2Cpos(sattribute2, 3))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.struc2Cpos(sattribute3, 3) : "+Arrays.toString(client.struc2Cpos(sattribute3, 3))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		
+		try {
+			System.out.println("client.struc2Str(sattribute1, strucpos) : "+Arrays.toString(client.struc2Str(sattribute1, strucpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.struc2Str(sattribute2, strucpos) : "+Arrays.toString(client.struc2Str(sattribute2, strucpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+		try {
+			System.out.println("client.struc2Str(sattribute3, strucpos) : "+Arrays.toString(client.struc2Str(sattribute3, strucpos))); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.subCorpusHasField(subcorpus, (byte)0) : "+client.subCorpusHasField(subcorpusid, (byte)0)); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.subCorpusSize(subcorpus) : "+client.subCorpusSize(subcorpusid)); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		try {
+			System.out.println("client.dropSubCorpus(subcorpus)"); client.dropSubCorpus(subcorpusid); //$NON-NLS-1$
+		} catch(Exception e) { System.out.println("Exception : "+e);} //$NON-NLS-1$
+
+		System.out.println("TIME: "+ExecTimer.stop()); //$NON-NLS-1$
+
+		server.stop();
+		
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CqpPropertyDataProxy.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CqpPropertyDataProxy.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CqpPropertyDataProxy.java	(revision 449)
@@ -0,0 +1,64 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp;
+
+import java.util.List;
+
+import org.txm.searchengine.cqp.corpus.Corpus;
+import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqpPropertyDataProxy.
+ */
+public class CqpPropertyDataProxy {
+	/**
+	 * Data is cached in a sparse list which give for each position the
+	 * corresponding string (given the property it is dedicated to).
+	 */
+	private List<String> data = null;
+
+	/** The property. */
+	private StructuralUnitProperty property;
+
+	/** the corpus. */
+	private Corpus corpus;
+
+	/**
+	 * The Constructor.
+	 *
+	 * @param corpus the corpus
+	 * @param property The property the dataProxy is dedicated to
+	 */
+	public CqpPropertyDataProxy(Corpus corpus, StructuralUnitProperty property) {
+		this.property = property;
+		this.corpus = corpus;
+	}
+
+
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ICqiClient.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ICqiClient.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ICqiClient.java	(revision 449)
@@ -0,0 +1,820 @@
+// 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: 2012-03-01 08:14:11 +0100 (jeu., 01 mars 2012) $
+// $LastChangedRevision: 2134 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp;
+
+import java.io.IOException;
+
+import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
+import org.txm.searchengine.cqp.serverException.CqiCqpErrorNoSuchCorpus;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
+
+/**
+ * This class implements a Java Interface CQi client.
+ *
+ * @author mdecorde
+ */
+public interface ICqiClient {
+
+	/** The Constant CQI_PADDING. */
+	final static public byte[] CQI_PADDING = { (byte) 0x00 };
+
+	/** The Constant CQI_STATUS_OK. */
+	final static public byte[] CQI_STATUS_OK = { (byte) 0x01, (byte) 0x01 };
+
+	/** The Constant CQI_STATUS_CONNECT_OK. */
+	final static public byte[] CQI_STATUS_CONNECT_OK = { (byte) 0x01, (byte) 0x02 };
+
+	/** The Constant CQI_STATUS_BYE_OK. */
+	final static public byte[] CQI_STATUS_BYE_OK = { (byte) 0x01, (byte) 0x03 };
+
+	/** The Constant CQI_STATUS_PING_OK. */
+	final static public byte[] CQI_STATUS_PING_OK = { (byte) 0x01, (byte) 0x04 };
+
+	/** The Constant CQI_ERROR_GENERAL_ERROR. */
+	final static public byte[] CQI_ERROR_GENERAL_ERROR = { (byte) 0x02, (byte) 0x01 };
+
+	/** The Constant CQI_ERROR_CONNECT_REFUSED. */
+	final static public byte[] CQI_ERROR_CONNECT_REFUSED = { (byte) 0x02, (byte) 0x02 };
+
+	/** The Constant CQI_ERROR_USER_ABORT. */
+	final static public byte[] CQI_ERROR_USER_ABORT = { (byte) 0x02, (byte) 0x03 };
+
+	/** The Constant CQI_ERROR_SYNTAX_ERROR. */
+	final static public byte[] CQI_ERROR_SYNTAX_ERROR = { (byte) 0x02, (byte) 0x04 };
+
+	/** The Constant CQI_DATA_BYTE. */
+	final static public byte[] CQI_DATA_BYTE = { (byte) 0x03, (byte) 0x01 };
+
+	/** The Constant CQI_DATA_BOOL. */
+	final static public byte[] CQI_DATA_BOOL = { (byte) 0x03, (byte) 0x02 };
+
+	/** The Constant CQI_DATA_INT. */
+	final static public byte[] CQI_DATA_INT = { (byte) 0x03, (byte) 0x03 };
+
+	/** The Constant CQI_DATA_STRING. */
+	final static public byte[] CQI_DATA_STRING = { (byte) 0x03, (byte) 0x04 };
+
+	/** The Constant CQI_DATA_BYTE_LIST. */
+	final static public byte[] CQI_DATA_BYTE_LIST = { (byte) 0x03, (byte) 0x05 };
+
+	/** The Constant CQI_DATA_BOOL_LIST. */
+	final static public byte[] CQI_DATA_BOOL_LIST = { (byte) 0x03, (byte) 0x06 };
+
+	/** The Constant CQI_DATA_INT_LIST. */
+	final static public byte[] CQI_DATA_INT_LIST = { (byte) 0x03, (byte) 0x07 };
+
+	/** The Constant CQI_DATA_STRING_LIST. */
+	final static public byte[] CQI_DATA_STRING_LIST = { (byte) 0x03, (byte) 0x08 };
+
+	/** The Constant CQI_DATA_INT_INT. */
+	final static public byte[] CQI_DATA_INT_INT = { (byte) 0x03, (byte) 0x09 };
+
+	/** The Constant CQI_DATA_INT_INT_INT_INT. */
+	final static public byte[] CQI_DATA_INT_INT_INT_INT = { (byte) 0x03, (byte) 0x0A };
+
+	/** The Constant CQI_DATA_INT_TABLE. */
+	final static public byte[] CQI_DATA_INT_TABLE = { (byte) 0x03, (byte) 0x0B };
+
+	/** The Constant CQI_CL_ERROR_NO_SUCH_ATTRIBUTE. */
+	final static public byte[] CQI_CL_ERROR_NO_SUCH_ATTRIBUTE = { (byte) 0x04,
+		(byte) 0x01 };
+
+	/** The Constant CQI_CL_ERROR_WRONG_ATTRIBUTE_TYPE. */
+	final static public byte[] CQI_CL_ERROR_WRONG_ATTRIBUTE_TYPE = { (byte) 0x04,
+		(byte) 0x02 };
+
+	/** The Constant CQI_CL_ERROR_OUT_OF_RANGE. */
+	final static public byte[] CQI_CL_ERROR_OUT_OF_RANGE = { (byte) 0x04, (byte) 0x03 };
+
+	/** The Constant CQI_CL_ERROR_REGEX. */
+	final static public byte[] CQI_CL_ERROR_REGEX = { (byte) 0x04, (byte) 0x04 };
+
+	/** The Constant CQI_CL_ERROR_CORPUS_ACCESS. */
+	final static public byte[] CQI_CL_ERROR_CORPUS_ACCESS = { (byte) 0x04, (byte) 0x05 };
+
+	/** The Constant CQI_CL_ERROR_OUT_OF_MEMORY. */
+	final static public byte[] CQI_CL_ERROR_OUT_OF_MEMORY = { (byte) 0x04, (byte) 0x06 };
+
+	/** The Constant CQI_CL_ERROR_INTERNAL. */
+	final static public byte[] CQI_CL_ERROR_INTERNAL = { (byte) 0x04, (byte) 0x07 };
+
+	/** The Constant CQI_CQP_ERROR_GENERAL. */
+	final static public byte[] CQI_CQP_ERROR_GENERAL = { (byte) 0x05, (byte) 0x01 };
+
+	/** The Constant CQI_CQP_ERROR_NO_SUCH_CORPUS. */
+	final static public byte[] CQI_CQP_ERROR_NO_SUCH_CORPUS = { (byte) 0x05,
+		(byte) 0x02 };
+
+	/** The Constant CQI_CQP_ERROR_INVALID_FIELD. */
+	final static public byte[] CQI_CQP_ERROR_INVALID_FIELD = { (byte) 0x05,
+		(byte) 0x03 };
+
+	/** The Constant CQI_CQP_ERROR_OUT_OF_RANGE. */
+	final static public byte[] CQI_CQP_ERROR_OUT_OF_RANGE = { (byte) 0x05, (byte) 0x04 };
+
+	/** The Constant CQI_CQP_ERROR_OUT_OF_RANGE. */
+	final static public byte[] CQI_CQP_ERROR_SYNTAX = { (byte) 0x05, (byte) 0x05 };
+
+	/** The Constant CQI_CTRL_CONNECT. */
+	final static public byte[] CQI_CTRL_CONNECT = { (byte) 0x11, (byte) 0x01 };
+
+	/** The Constant CQI_CTRL_BYE. */
+	final static public byte[] CQI_CTRL_BYE = { (byte) 0x11, (byte) 0x02 };
+
+	/** The Constant CQI_CTRL_USER_ABORT. */
+	final static public byte[] CQI_CTRL_USER_ABORT = { (byte) 0x11, (byte) 0x03 };
+
+	/** The Constant CQI_CTRL_PING. */
+	final static public byte[] CQI_CTRL_PING = { (byte) 0x11, (byte) 0x04 };
+
+	/** The Constant CQI_CTRL_LAST_GENERAL_ERROR. */
+	final static public byte[] CQI_CTRL_LAST_GENERAL_ERROR = { (byte) 0x11,
+		(byte) 0x05 };
+
+	/** The Constant CQI_CTRL_LAST_CQP_ERROR. */
+	final static public byte[] CQI_CTRL_LAST_CQP_ERROR = { (byte) 0x11,
+		(byte) 0x06 };
+
+	/** The Constant CQI_CORPUS_LIST_CORPORA. */
+	final static public byte[] CQI_CORPUS_LIST_CORPORA = { (byte) 0x13, (byte) 0x01 };
+
+	/** The Constant CQI_CORPUS_CHARSET. */
+	final static public byte[] CQI_CORPUS_CHARSET = { (byte) 0x13, (byte) 0x03 };
+
+	/** The Constant CQI_CORPUS_PROPERTIES. */
+	final static public byte[] CQI_CORPUS_PROPERTIES = { (byte) 0x13, (byte) 0x04 };
+
+	/** The Constant CQI_CORPUS_POSITIONAL_ATTRIBUTES. */
+	final static public byte[] CQI_CORPUS_POSITIONAL_ATTRIBUTES = { (byte) 0x13,
+		(byte) 0x05 };
+
+	/** The Constant CQI_CORPUS_STRUCTURAL_ATTRIBUTES. */
+	final static public byte[] CQI_CORPUS_STRUCTURAL_ATTRIBUTES = { (byte) 0x13,
+		(byte) 0x06 };
+
+	/** The Constant CQI_CORPUS_STRUCTURAL_ATTRIBUTE_HAS_VALUES. */
+	final static public byte[] CQI_CORPUS_STRUCTURAL_ATTRIBUTE_HAS_VALUES = {
+		(byte) 0x13, (byte) 0x07 };
+
+	/** The Constant CQI_CORPUS_ALIGNMENT_ATTRIBUTES. */
+	final static public byte[] CQI_CORPUS_ALIGNMENT_ATTRIBUTES = { (byte) 0x13,
+		(byte) 0x08 };
+
+	/** The Constant CQI_CORPUS_FULL_NAME. */
+	final static public byte[] CQI_CORPUS_FULL_NAME = { (byte) 0x13, (byte) 0x09 };
+
+	/** The Constant CQI_CORPUS_INFO. */
+	final static public byte[] CQI_CORPUS_INFO = { (byte) 0x13, (byte) 0x0A };
+
+	/** The Constant CQI_CORPUS_DROP_CORPUS. */
+	final static public byte[] CQI_CORPUS_DROP_CORPUS = { (byte) 0x13, (byte) 0x0B };
+
+	/** The Constant CQI_CL_ATTRIBUTE_SIZE. */
+	final static public byte[] CQI_CL_ATTRIBUTE_SIZE = { (byte) 0x14, (byte) 0x01 };
+
+	/** The Constant CQI_CL_LEXICON_SIZE. */
+	final static public byte[] CQI_CL_LEXICON_SIZE = { (byte) 0x14, (byte) 0x02 };
+
+	/** The Constant CQI_CL_DROP_ATTRIBUTE. */
+	final static public byte[] CQI_CL_DROP_ATTRIBUTE = { (byte) 0x14, (byte) 0x03 };
+
+	/** The Constant CQI_CL_STR2ID. */
+	final static public byte[] CQI_CL_STR2ID = { (byte) 0x14, (byte) 0x04 };
+
+	/** The Constant CQI_CL_ID2STR. */
+	final static public byte[] CQI_CL_ID2STR = { (byte) 0x14, (byte) 0x05 };
+
+	/** The Constant CQI_CL_ID2FREQ. */
+	final static public byte[] CQI_CL_ID2FREQ = { (byte) 0x14, (byte) 0x06 };
+
+	/** The Constant CQI_CL_CPOS2ID. */
+	final static public byte[] CQI_CL_CPOS2ID = { (byte) 0x14, (byte) 0x07 };
+
+	/** The Constant CQI_CL_CPOS2STR. */
+	final static public byte[] CQI_CL_CPOS2STR = { (byte) 0x14, (byte) 0x08 };
+
+	/** The Constant CQI_CL_CPOS2STRUC. */
+	final static public byte[] CQI_CL_CPOS2STRUC = { (byte) 0x14, (byte) 0x09 };
+
+	/** The Constant CQI_CL_CPOS2LBOUND. */
+	final static public byte[] CQI_CL_CPOS2LBOUND = { (byte) 0x14, (byte) 0x20 };
+
+	/** The Constant CQI_CL_CPOS2RBOUND. */
+	final static public byte[] CQI_CL_CPOS2RBOUND = { (byte) 0x14, (byte) 0x21 };
+
+	/** The Constant CQI_CL_CPOS2ALG. */
+	final static public byte[] CQI_CL_CPOS2ALG = { (byte) 0x14, (byte) 0x0A };
+
+	/** The Constant CQI_CL_STRUC2STR. */
+	final static public byte[] CQI_CL_STRUC2STR = { (byte) 0x14, (byte) 0x0B };
+
+	/** The Constant CQI_CL_ID2CPOS. */
+	final static public byte[] CQI_CL_ID2CPOS = { (byte) 0x14, (byte) 0x0C };
+
+	/** The Constant CQI_CL_IDLIST2CPOS. */
+	final static public byte[] CQI_CL_IDLIST2CPOS = { (byte) 0x14, (byte) 0x0D };
+
+	/** The Constant CQI_CL_REGEX2ID. */
+	final static public byte[] CQI_CL_REGEX2ID = { (byte) 0x14, (byte) 0x0E };
+
+	/** The Constant CQI_CL_STRUC2CPOS. */
+	final static public byte[] CQI_CL_STRUC2CPOS = { (byte) 0x14, (byte) 0x0F };
+
+	/** The Constant CQI_CL_ALG2CPOS. */
+	final static public byte[] CQI_CL_ALG2CPOS = { (byte) 0x14, (byte) 0x10 };
+
+	/** The Constant CQI_CQP_QUERY. */
+	final static public byte[] CQI_CQP_QUERY = { (byte) 0x15, (byte) 0x01 };
+
+	/** The Constant CQI_CQP_LIST_SUBCORPORA. */
+	final static public byte[] CQI_CQP_LIST_SUBCORPORA = { (byte) 0x15, (byte) 0x02 };
+
+	/** The Constant CQI_CQP_SUBCORPUS_SIZE. */
+	final static public byte[] CQI_CQP_SUBCORPUS_SIZE = { (byte) 0x15, (byte) 0x03 };
+
+	/** The Constant CQI_CQP_SUBCORPUS_HAS_FIELD. */
+	final static public byte[] CQI_CQP_SUBCORPUS_HAS_FIELD = { (byte) 0x15,
+		(byte) 0x04 };
+
+	/** The Constant CQI_CQP_DUMP_SUBCORPUS. */
+	final static public byte[] CQI_CQP_DUMP_SUBCORPUS = { (byte) 0x15, (byte) 0x05 };
+
+	/** The Constant CQI_CQP_DROP_SUBCORPUS. */
+	final static public byte[] CQI_CQP_DROP_SUBCORPUS = { (byte) 0x15, (byte) 0x09 };
+
+	/** The Constant CQI_CQP_FDIST_1. */
+	final static public byte[] CQI_CQP_FDIST_1 = { (byte) 0x15, (byte) 0x10 };
+
+	/** The Constant CQI_CQP_FDIST_2. */
+	final static public byte[] CQI_CQP_FDIST_2 = { (byte) 0x15, (byte) 0x11 };
+
+	/** The Constant CQI_CQP_QUERY. */
+	final static public byte[] CQI_CQP_QUERY_EVAL = { (byte) 0x15, (byte) 0x01 };
+	
+	/** The Constant CQI_CONST_FIELD_MATCH. */
+	final public static byte CQI_CONST_FIELD_MATCH = (byte) 0x10;
+
+	/** The Constant CQI_CONST_FIELD_MATCHEND. */
+	final public static byte CQI_CONST_FIELD_MATCHEND = (byte) 0x11;
+	
+	/** The Constant CQI_CONST_FIELD_TARGET. */
+	final public static byte CQI_CONST_FIELD_TARGET = (byte) 0x00;
+	/** The Constant CQI_CONST_FIELD_KEYWORD. */
+	final public static byte CQI_CONST_FIELD_KEYWORD = (byte) 0x09;
+	
+	final public static byte CQI_CONST_FIELD_TARGET_0 = (byte) 0x00;
+	final public static byte CQI_CONST_FIELD_TARGET_1 = (byte) 0x01;
+	final public static byte CQI_CONST_FIELD_TARGET_2 = (byte) 0x02;
+	final public static byte CQI_CONST_FIELD_TARGET_3 = (byte) 0x03;
+	final public static byte CQI_CONST_FIELD_TARGET_4 = (byte) 0x04;
+	final public static byte CQI_CONST_FIELD_TARGET_5 = (byte) 0x05;
+	final public static byte CQI_CONST_FIELD_TARGET_6 = (byte) 0x06;
+	final public static byte CQI_CONST_FIELD_TARGET_7 = (byte) 0x07;
+	final public static byte CQI_CONST_FIELD_TARGET_8 = (byte) 0x08;
+	final public static byte CQI_CONST_FIELD_TARGET_9 = (byte) 0x09;
+	
+	// CQI_ERROR_CONNECT_REFUSED
+	/**
+	 * Connect the client to a server.
+	 *
+	 * @param username the username
+	 * @param password the password
+	 * @return true, if successful
+	 */
+	public boolean connect(String username, String password) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	// None
+	/**
+	 * Disconnect.
+	 * 
+	 * @return true, if successful
+	 */
+	public boolean disconnect() throws UnexpectedAnswerException, CqiServerError, IOException;
+
+	// CQI_CTRL_LAST_GENERAL_ERROR
+	/**
+	 * return the last CQP error.
+	 *
+	 * @return the last error
+	 */
+	public String getLastCqiError() throws UnexpectedAnswerException, IOException,	CqiServerError;
+
+	// CQI_CTRL_LAST_CQP_ERROR
+	/**
+	 * return the last CQP error.
+	 *
+	 * @return the last error
+	 */
+	public String getLastCQPError() throws UnexpectedAnswerException, IOException,	CqiServerError;
+
+	// None
+	/**
+	 * Lists the corpora available on the server.
+	 *
+	 * @return the name of the corpora
+	 */
+	public String[] listCorpora() throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	// None
+	/**
+	 * Gives the corpus charset.
+	 *
+	 * @param corpus the corpus
+	 * @return the name of the charset
+	 */
+	public String corpusCharset(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	// None (not really implemented anyway)
+	/**
+	 * Gives the corpus properties.
+	 *
+	 * @param corpus the corpus
+	 * @return the properties
+	 */
+	public String[] corpusProperties(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS
+	/**
+	 * Gives the corpus positional attributes.
+	 *
+	 * @param corpusID the corpus id
+	 * @return the name of the attributes
+	 */
+	public String[] corpusPositionalAttributes(String corpusID) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS
+	/**
+	 * Gives the corpus structural attributes.
+	 *
+	 * @param corpus the corpus
+	 * @return the name of the attributes
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	public String[] corpusStructuralAttributes(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS, CQI_CL_ERROR_NO_SUCH_ATTRIBUTE,
+	// CQI_CL_ERROR_WRONG_ATTRIBUTE_TYPE
+	/**
+	 * Check wether a structural attribute has values.
+	 *
+	 * @param attribute the attribute
+	 * @return true, if it has values
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	public boolean corpusStructuralAttributeHasValues(String attribute) throws UnexpectedAnswerException, IOException,
+	CqiServerError;
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS
+	/**
+	 * Gives the corpus alignement attributes.
+	 *
+	 * @param corpus the corpus
+	 * @return the name of attributes
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	public String[] corpusAlignementAttributes(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS
+	/**
+	 * Gives the corpus full name.
+	 *
+	 * @param corpus the corpus
+	 * @return the full name
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	public String corpusFullName(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Gives the corpus info listed in the .INFO file.
+	 *
+	 * @param corpus the corpus
+	 * @return the info
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	public  String[] corpusInfo(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Drop a corpus.
+	 * 
+	 * @param corpus
+	 *            the corpus
+	 */
+	public void dropCorpus(String corpus) throws Exception;
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS, CQI_CL_ERROR_NO_SUCH_ATTRIBUTE,
+	// CQI_CL_ERROR_WRONG_ATTRIBUTE_TYPE, CQI_CL_ERROR_CORPUS_ACCESS
+	/**
+	 * Gives an attribute size (the number of token).
+	 *
+	 * @param attribute the attribute
+	 * @return the size
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	public int attributeSize(String attribute) throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS, CQI_CL_ERROR_NO_SUCH_ATTRIBUTE,
+	// CQI_CL_ERROR_WRONG_ATTRIBUTE_TYPE, CQI_CL_ERROR_CORPUS_ACCESS
+	/**
+	 * Gives the lexicon size of an attribute.
+	 *
+	 * @param attribute the attribute
+	 * @return the int
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 * @returns the number of entries in the lexicon of a positional attribute
+	 */
+	public int lexiconSize(String attribute) throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Drop attribute.
+	 *
+	 * @param attribute the attribute
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	public void dropAttribute(String attribute) throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Converts an array of attribute values to their ID.
+	 *
+	 * @param attribute the attribute
+	 * @param strings the values
+	 * @return the IDs
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	public int[] str2Id(String attribute, String[] strings) throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Converts an array of attribute ID to their values.
+	 *
+	 * @param attribute the attribute
+	 * @param ids the ids
+	 * @return the values
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	public String[] id2Str(String attribute, int[] ids) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Converts an array of attribute IDs to their frequency.
+	 *
+	 * @param attribute the attribute
+	 * @param ids the ids
+	 * @return the frequencies
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	public int[] id2Freq(String attribute, int[] ids) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Converts an array of position to their ID given an attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the positions
+	 * @return the IDs
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	public int[] cpos2Id(String attribute, int[] cpos) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Converts an array of position to their value given an attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the cpos
+	 * @return the values
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	public String[] cpos2Str(String attribute, int[] cpos) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Computes for each position of an array the Id of the enclosing structural
+	 * attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the positions
+	 * @return the IDs
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	public int[] cpos2Struc(String attribute, int[] cpos) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Computes for each position of an array the position of the left boundary
+	 * of the enclosing structural attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the cpos
+	 * @return the positions of the left boundaries
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	public int[] cpos2LBound(String attribute, int[] cpos) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Computes for each position of an array the position of the right boundary
+	 * of the enclosing structural attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the cpos
+	 * @return the positions of the right boundaries
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	public int[] cpos2RBound(String attribute, int[] cpos) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Computes for each position of an array the Id of the enclosing alignment
+	 * attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the cpos
+	 * @return the int[]
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	public int[] cpos2Alg(String attribute, int[] cpos) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Retrieves annotated string values of structure regions in <strucs>; "" if
+	 * out of range.
+	 *
+	 * @param attribute the attribute
+	 * @param strucs the strucs
+	 * @return the string[]
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	public String[] struc2Str(String attribute, int[] strucs) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Retrieves all corpus positions where the given token occurs.
+	 *
+	 * @param attribute the attribute
+	 * @param id the id
+	 * @return the position
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	public int[] id2Cpos(String attribute, int id) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Retrieves all corpus positions where one of the tokens in <id_list>
+	 * occurs; the returned list is sorted as a whole, not per token id.
+	 *
+	 * @param attribute the attribute
+	 * @param ids the ids
+	 * @return the positions
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	public int[] idList2Cpos(String attribute, int[] ids) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Retrieves the lexicon IDs of all tokens that match <regex>; the returned
+	 * list may be empty (size 0).
+	 *
+	 * @param attribute the attribute
+	 * @param regex the regex
+	 * @return the IDs
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	public int[] regex2Id(String attribute, String regex) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Retrieves the start and end corpus positions of structure region <struc>.
+	 *
+	 * @param attribute the attribute
+	 * @param struc the struc
+	 * @return an array of size 2 containing the start and end positions
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	public int[] struc2Cpos(String attribute, int struc) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Retrieves start and end corpus positions of an alignement region in the
+	 * source and target corpora<struc>.
+	 *
+	 * @param attribute the attribute
+	 * @param struc the struc
+	 * @return an array of size 4 containing (src_start, src_end, target_start,
+	 * target_end)
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	public int[] alg2Cpos(String attribute, int struc) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Runs a CQP query.
+	 *
+	 * @param motherCorpus the mother corpus
+	 * @param subcorpus the subcorpus
+	 * @param query the query
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError the cqi server error
+	 */
+	public void cqpQuery(String motherCorpus, String subcorpus, String query) throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Lists all the subcorpora of a corpus.
+	 *
+	 * @param corpus the corpus
+	 * @return the name of the subcorpora
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiCqpErrorNoSuchCorpus the cqi cqp error no such corpus
+	 */
+	public String[] listSubcorpora(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Gives the size of a subcorpus .
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * 
+	 * @return the size
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	public int subCorpusSize(String subcorpus) throws IOException,
+	UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Checks wether a subcorpus has a field.
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * @param field CQI_CONST_FIELD_MATCH, CQI_CONST_FIELD_MATCHEND or CQI_CONST_FIELD_TARGET
+	 * 
+	 * @return true, if the subcorpus has the field
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	public boolean subCorpusHasField(String subcorpus, byte field) throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Dumps the values of <field> for match ranges <first> .. <last> in
+	 * <subcorpus>. <field> is one of the CQI_CONST_FIELD_* constants.
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * @param field CQI_CONST_FIELD_MATCH, CQI_CONST_FIELD_MATCHEND or CQI_CONST_FIELD_TARGET
+	 * @param first
+	 *            the first
+	 * @param last
+	 *            the last
+	 * 
+	 * @return the values
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	public int[] dumpSubCorpus(String subcorpus, byte field, int first, int last) throws IOException, UnexpectedAnswerException,
+	CqiServerError;
+
+	/**
+	 * Drops a subcorpus.
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	public void dropSubCorpus(String subcorpus) throws IOException,
+	UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Returns <n> (id, frequency) pairs flattened into a list of size 2*<n> NB:
+	 * pairs are sorted by frequency desc.
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * @param cutoff
+	 *            the cutoff
+	 * @param field
+	 *            the field : one of CQI_CONST_FIELD_MATCH, CQI_CONST_FIELD_MATCHEND or CQI_CONST_FIELD_TARGET
+	 * @param attribute
+	 *            the attribute
+	 * 
+	 * @return the int[][]
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	public int[][] fdist1(String subcorpus, int cutoff,
+			byte field, String attribute) throws IOException,
+			UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Returns <n> (id1, id2, frequency) pairs flattened into a list of size
+	 * 3*<n> NB: triples are sorted by frequency desc. .
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * @param cutoff
+	 *            the cutoff
+	 * @param field1
+	 *            the field1
+	 * @param attribute1
+	 *            the attribute1
+	 * @param field2
+	 *            the field2
+	 * @param attribute2
+	 *            the attribute2
+	 * 
+	 * @return the int[]
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	public int[][] fdist2(String subcorpus, int cutoff,
+			byte field1, String attribute1, byte field2, String attribute2) throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	public boolean reconnect() ;
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/AbstractCqiServer.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/AbstractCqiServer.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/AbstractCqiServer.java	(revision 449)
@@ -0,0 +1,107 @@
+// 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: 2011-12-14 10:52:18 +0100 (mer., 14 déc. 2011) $
+// $LastChangedRevision: 2080 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+// TODO: Auto-generated Javadoc
+/**
+ * This class aims at handling a CQi server process. It is not a CQi server per
+ * se.
+ * 
+ * @author Jean-Philippe Magué
+ */
+public abstract class AbstractCqiServer implements ICqiServer {
+	
+	@Override
+	public abstract void setDebug(boolean val);
+
+	/**
+	 * Gets the last cmd line.
+	 *
+	 * @return the last cmd line
+	 */
+	public String getLastCmdLine() {
+		return ""; //$NON-NLS-1$
+	}
+
+	/**
+	 * Start.
+	 *
+	 * @return true, if successful
+	 */
+	@Override
+	public abstract Boolean start();
+	
+	/**
+	 * Convert stream to string.
+	 *
+	 * @param is the is
+	 * @return the string
+	 */
+	@Override
+	public abstract String convertStreamToString(InputStream is);
+	
+	/**
+	 * Stop the server.
+	 */
+	@Override
+	public abstract Boolean stop();
+
+	/**
+	 * Checks if the server is running.
+	 * 
+	 * @return true, if is running
+	 */
+	@Override
+	public abstract Boolean isRunning();
+
+	/**
+	 * Gets the error stream.
+	 *
+	 * @return the error stream
+	 */
+	@Override
+	public abstract InputStream getErrorStream();
+
+	/**
+	 * Gets the input stream.
+	 *
+	 * @return the input stream
+	 */
+	@Override
+	public abstract InputStream getInputStream();
+	/**
+	 * Gets the output stream.
+	 *
+	 * @return the output stream
+	 */
+	@Override
+	public abstract OutputStream getOutputStream();
+}
\ No newline at end of file

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java	(revision 449)
@@ -0,0 +1,717 @@
+// 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: 2016-11-17 17:01:31 +0100 (Thu, 17 Nov 2016) $
+// $LastChangedRevision: 3341 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus;
+
+import java.text.Collator;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.TreeMap;
+
+import org.eclipse.osgi.util.NLS;
+import org.txm.Toolbox;
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.objects.TxmObject;
+import org.txm.searchengine.cqp.CQPEngine;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.corpus.query.Query;
+import org.txm.searchengine.cqp.corpus.query.QueryPart;
+import org.txm.utils.logger.Log;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * A partition on a corpus.
+ *
+ * @author sjacquot 
+ * @author Jean-Philippe Magué
+ * 
+ */
+public class Partition extends TxmObject {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 4420732757687971253L;
+
+	/** The parts. */
+	private List<Part> parts;
+
+	/** The structure. */
+	private StructuralUnit structure;
+
+	/** The property. */
+	private Property property;
+
+	/** An association between name of analysis property and lexical table. */
+//	private Map<String, LexicalTable> lexicalTables = new HashMap<String, LexicalTable>();
+
+	
+	/** The results stored by class. */
+	private TreeMap<String, List<Object>> results = new TreeMap<String, List<Object>>();
+
+	public static Integer SUBCORPUS_COUNTER = new Integer(0);
+	
+
+	
+	int totalsize = -1;
+	int[] partSizes;
+
+	
+	/**
+	 * Creates a new partition on a corpus given a structure, a property of this
+	 * structure and a liste of values this property can take
+	 * 
+	 * The partition has as many parts as the size of the list of value. The ith
+	 * part is composed by all the structure <code>structure</code> such as
+	 * <code>strucutre.getValue(property) == values.get(i)<code>
+	 * 
+	 * @param corpus
+	 *            the corpus
+	 * @param structure
+	 *            the structure
+	 * @param property
+	 *            the property
+	 * @param values
+	 *            the values
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	protected Partition(Corpus corpus, StructuralUnit structure, StructuralUnitProperty property, List<String> values)	throws CqiClientException {
+		super(corpus);
+		this.name = corpus.getName()+ "_" + structure.getName() + "_" + property.getName(); //$NON-NLS-1$ //$NON-NLS-2$
+		Log.finest(NLS.bind(TXMCoreMessages.NEW_PARTION, this.getCorpus(), this.name)); 
+		long start = System.currentTimeMillis();
+		this.structure = structure;
+		this.property = property;
+		this.parts = new ArrayList<Part>();
+		HashMap<String, String> infos = this.getCorpus().getSAttributesInfos().get(property.getFullName());
+		String type = "String"; //$NON-NLS-1$
+		if (infos != null) {
+			type = infos.get("type"); //$NON-NLS-1$
+		}
+		if (type == null || type.trim().length() == 0 || type.equals("String")) { //$NON-NLS-1$
+			Collections.sort(values, Collator.getInstance(Locale.getDefault())); // alpha sort
+		} else if (type.equals("Integer")) { //$NON-NLS-1$
+			Collections.sort(values, new Comparator<String>() {
+				@Override
+				public int compare(String arg0, String arg1) {
+					int i0 = Integer.parseInt(arg0);
+					int i1 = Integer.parseInt(arg1);
+					return i0-i1;
+				}
+			}); 
+		} else if (type.equals("Date")) { //$NON-NLS-1$
+			String format = infos.get("inputFormat"); //$NON-NLS-1$
+			final DateFormat formater = new SimpleDateFormat(format);
+			Collections.sort(values, new Comparator<String>() {
+				@Override
+				public int compare(String arg0, String arg1) {
+					try {
+						Date i0 = formater.parse(arg0);
+						Date i1 = formater.parse(arg1);
+						return i0.compareTo(i1);
+					} catch (ParseException e) {
+						return arg0.compareTo(arg1);
+					}
+				}
+			}); 
+		} else  if(type.contains("|")){ //$NON-NLS-1$
+			final List<String> sortedValues = Arrays.asList(type.split("\\|")); //$NON-NLS-1$
+			Collections.sort(values, new Comparator<String>() {
+				@Override
+				public int compare(String arg0, String arg1) {
+						int i0 = sortedValues.indexOf(arg0);
+						int i1 = sortedValues.indexOf(arg1);
+						return i0-i1;
+				}
+			}); 
+		}
+		//System.out.println("Parts sorted with type: "+type);
+		//System.out.println("values: "+values);
+		for (String value : values) {
+			String partitionName = this.getName();
+			String partName = value.replace("\\",""); //$NON-NLS-1$ //$NON-NLS-2$
+			//System.out.println("VALUE: "+value);
+			Query query = new QueryPart(structure, property, Query.addBackSlash(value));
+			Part part = createPart(partitionName, partName, query);
+			// System.out.println("part id: "+part.getQualifiedCqpId());
+			parts.add(part);
+		}
+		long end = System.currentTimeMillis();
+		Log.finest(NLS.bind(TXMCoreMessages.PARTITION_CREATED, this.name, (end - start)));
+	}
+
+	/**
+	 * Instantiates a new partition.
+	 *
+	 * @param corpus the corpus
+	 * @param structure the structure
+	 * @param property the property
+	 * @throws CqiClientException the cqi client exception
+	 */
+	protected Partition(Corpus corpus, StructuralUnit structure, StructuralUnitProperty property) throws CqiClientException {
+		this(corpus, structure, property, property.getValues(corpus));
+	}
+
+
+	/**
+	 * Create a partition with a set of raw queries.
+	 *
+	 * @param corpus the corpus
+	 * @param name the name
+	 * @param queries the queries
+	 * @throws CqiClientException the cqi client exception
+	 * @author Sylvain Loiseau
+	 */
+	protected Partition(Corpus corpus, String name, List<String> queries) throws CqiClientException {
+		super(corpus);
+		this.structure = null;
+		this.property = null;
+		if (name == null || name.trim().length() == 0)
+			name = "noname"; //$NON-NLS-1$
+		this.name = name;
+		Log.info(NLS.bind(TXMCoreMessages.NEW_PARTION, this.getCorpus(), this.name));
+		long start = System.currentTimeMillis();
+		this.parts = new ArrayList<Part>();
+		for (int i = 0; i < queries.size(); i++) {
+			String queryS = queries.get(i);
+			String partitionName = this.getName();
+			String partName = String.valueOf(i);
+			if (partName.length() == 0) partName = "-"; //$NON-NLS-1$
+			Part part = createPart(partitionName, partName, queryS);
+			parts.add(part);
+		}
+		long end = System.currentTimeMillis();
+		Log.info(NLS.bind(TXMCoreMessages.PARTITION_CREATED, this.name, (end - start)));
+	}
+
+	/**
+	 * Instantiates a new partition.
+	 *
+	 * @param corpus the corpus
+	 * @param name the name
+	 * @param queries the queries
+	 * @param partnames the partnames
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Partition(Corpus corpus, String name, List<String> queries, List<String> partnames) throws CqiClientException {
+		super(corpus);
+		this.structure = null;
+		this.property = null;
+		if (name == null || name.trim().length() == 0)
+			name = "noname"; //$NON-NLS-1$
+		this.name = name;
+		Log.info(NLS.bind(TXMCoreMessages.NEW_PARTION, this.getCorpus(), this.name));
+		long start = System.currentTimeMillis();
+		this.parts = new ArrayList<Part>();
+		for (int i = 0; i < queries.size(); i++) {
+			String queryS = queries.get(i);
+			String partitionName = this.getName();
+			String partName = partnames.get(i);
+			if (partName.trim().length() == 0) partName = "-"; //$NON-NLS-1$
+			Part part = createPart(partitionName, partName, queryS);
+			parts.add(part);
+		}
+		long end = System.currentTimeMillis();
+		Log.info(NLS.bind(TXMCoreMessages.PARTITION_CREATED, this.name, (end - start)));
+	}
+
+	
+	/**
+	 * Get the safe values (spacial char regexp safe).
+	 *
+	 * @param property the property
+	 * @param corpus the corpus
+	 * @return the safe values
+	 * @throws CqiClientException the cqi client exception
+	 */
+	private static List<String> getSafeValues(StructuralUnitProperty property, Corpus corpus) throws CqiClientException
+	{
+		List<String> values = property.getValues(corpus);
+		//System.out.println("CORPUS: "+corpus);
+		//System.out.println("VALUES: "+values);
+		for(int i = 0 ; i < values.size() ; i++)
+			values.set(i, Query.addBackSlash(values.get(i)));
+		return values;
+	}
+
+	
+	/**
+	 * Create a part with a raw query.
+	 *
+	 * @param partitionName the partition name
+	 * @param partName the part name
+	 * @param query the query
+	 * @return the part
+	 * @throws CqiClientException the cqi client exception
+	 * 
+	 * @author Sylvain Loiseau, mdecorde
+	 */
+	public Part createPart(String partitionName, String partName, String query)
+	throws CqiClientException {
+		Part part;
+		String partCqpId = CqpObject.partNamePrefix + Corpus.getNextSubcorpusCounter();
+		Log.finest(NLS.bind(TXMCoreMessages.CREATING_PART,partName, query));
+		long start = System.currentTimeMillis();
+		try {
+			CorpusManager.getCorpusManager().getCqiClient().cqpQuery(
+					this.getCorpus().getQualifiedCqpId(), partCqpId, query);
+			part = new Part(partCqpId, partitionName, partName, this,
+					new Query(query));
+		} catch (Exception e) {
+			try {
+				throw new CqiClientException(TXMCoreMessages.Partition_9 + partitionName
+						+ "_" + partName+ e +" last error: "+CQPEngine.getCqiClient().getLastCQPError()); //$NON-NLS-1$ //$NON-NLS-2$
+			} catch (Exception e1) {
+				System.out.println(TXMCoreMessages.Partition_18+e1);
+				org.txm.utils.logger.Log.printStackTrace(e1);
+				return null;
+			}
+		}
+		long end = System.currentTimeMillis();
+		Log.finest(NLS.bind(TXMCoreMessages.PART_CREATED, partitionName
+				+ "_" + partName, (end - start))); //$NON-NLS-1$//$NON-NLS-2$
+		return part;
+	}
+
+	/**
+	 * Creates the part.
+	 *
+	 * @param partitionName the partition name
+	 * @param partName the part name
+	 * @param query the query
+	 * @return the part
+	 * @throws CqiClientException the cqi client exception
+	 */
+	private Part createPart(String partitionName, String partName, Query query)
+	throws CqiClientException {
+		if (partName.length() == 0) partName = "-"; //$NON-NLS-1$
+		return createPart(partitionName, partName, query.getQueryString());
+	}
+
+	/**
+	 * Gets the corpus.
+	 * 
+	 * @return the corpus
+	 */
+	public Corpus getCorpus() {
+		return (Corpus) this.parent;
+	}
+
+	//FIXME: useless?
+//	/**
+//	 * Gets the parts.
+//	 * 
+//	 * @return the parts
+//	 */
+//	public List<Part> getOrderedParts() {
+//		List<Part> sparts = parts;
+//		Collections.sort(sparts);
+//		return sparts;
+//	}
+
+	/**
+	 * Gets the parts.
+	 * 
+	 * @return the parts
+	 */
+	public List<Part> getParts() {
+		return parts;
+	}
+
+	/**
+	 * Gets the name of the parts.
+	 * 
+	 * @return the part names
+	 */
+	public List<String> getPartNames() {
+		List<String> partNames = new ArrayList<String>(parts.size());
+		for (Subcorpus part : parts)
+			partNames.add(part.getName());
+		return partNames;
+	}
+
+	//FIXME: useless?
+//	/**
+//	 * Gets the ordered name of the parts.
+//	 * 
+//	 * @return the part names
+//	 */
+//	public List<String> getOrderedPartNames() {
+//		List<String> partNames = getPartNames();
+//		Collections.sort(partNames);
+//		return partNames;
+//	}
+
+	/**
+	 * Gets the short name of the parts.
+	 * 
+	 * @return the part names
+	 */
+	public List<String> getPartShortNames() {
+		List<String> partNames = new ArrayList<String>(parts.size());
+		for (Part part : parts)
+			partNames.add(part.getShortName());
+		return partNames;
+	}
+
+	/**
+	 * Run a query on all the parts of this partition.
+	 * 
+	 * @param query
+	 *            the query
+	 * @param name
+	 *            the name
+	 * 
+	 * @return the list< subcorpus>
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public List<QueryResult> query(Query query, String name)
+	throws CqiClientException {
+		Log.finest(TXMCoreMessages.QUERYING_PARTITION + this.name);
+		List<QueryResult> results = new ArrayList<QueryResult>(parts.size());
+		for (Subcorpus part : parts)
+			results.add(part.query(query, part.getName() + "_" + name, false)); //$NON-NLS-1$
+		return results;
+	}
+
+	/**
+	 * Gets the number of parts.
+	 * 
+	 * @return the the number of parts.
+	 */
+	public int getNPart() {
+		try {
+			return parts.size();
+		}
+		catch(Exception e) {
+		}
+		return 0;
+	}
+
+	/**
+	 * Gets the structure.
+	 *
+	 * @return the structure
+	 */
+	public StructuralUnit getStructure() {
+		return structure;
+	}
+
+	/**
+	 * Gets the property.
+	 *
+	 * @return the property
+	 */
+	public Property getProperty() {
+		return property;
+	}
+
+
+//
+//	/**
+//	 * Stores the result of textometric computation in this corpus.
+//	 *
+//	 * @param result the result
+//	 */
+//	public void storeResult(Object result) {
+//		if (!results.containsKey(result.getClass().getName())) results.put(result.getClass().getName(), new ArrayList<Object>());
+//		if(!results.get(result.getClass().getName()).contains(result))	{
+//			results.get(result.getClass().getName()).add(result);	
+//		}
+//	}
+//
+//	/**
+//	 * Removes a result stored in this corpus.
+//	 *
+//	 * @param result the result
+//	 * @return true, if successful
+//	 */
+//	@Override
+//	public boolean removeResult(Object result) {
+//		if (!results.containsKey(result.getClass().getName())) return false;
+//		
+//		boolean ret = results.get(result.getClass().getName()).remove(result);
+//		return ret;
+//	}
+//
+//	/**
+//	 * Gets the results of textometric computation stored in the corpus.
+//	 *
+//	 * @return the results
+//	 */
+//	@Override
+//	public List<Object> getResults() {
+//		ArrayList<Object> tmp = new ArrayList<Object>();
+//		for (String k : results.keySet()) {
+//			tmp.addAll(results.get(k));
+//		}
+//		return tmp;
+//	}
+
+	/**
+	 * Sets the name.
+	 *
+	 * @param name2 the new name
+	 */
+	public void setName(String name2) {
+		this.name = name2;
+		if(this.getSelfElement() != null)
+			this.getSelfElement().setAttribute("name", name); //$NON-NLS-1$
+	}
+
+//	/* (non-Javadoc)
+//	 * @see org.txm.objects.TxmObject#getChildren()
+//	 */
+//	@Override
+//	public List<? extends TxmObject> getChildren() {
+//		return parts;
+//	}
+
+//	/* (non-Javadoc)
+//	 * @see org.txm.objects.TxmObject#getParent()
+//	 */
+//	@Override
+//	public TxmObject getParent() {
+//		return this.corpus;
+//	}
+
+	/**
+	 * Register to parent.
+	 *
+	 * @param partitionName the partition name
+	 */
+	private void registerToParent(String partitionName) {
+		if (this.getSelfElement() == null && this.getParent() != null)
+		try {
+			Element parentElem = (Element) this.getCorpus().getSelfElement();
+			if (parentElem == null) return;
+			Document doc = parentElem.getOwnerDocument();
+			Element corporaElem;
+			if (this.getParent() instanceof MainCorpus) {
+				NodeList corporaList = parentElem.getElementsByTagName("preBuild"); //$NON-NLS-1$
+				corporaElem = (Element) corporaList.item(0);
+			} else {
+				corporaElem = parentElem;
+			}
+			Element partitionElem = doc.createElement("partition"); //$NON-NLS-1$
+			partitionElem.setAttribute("name", partitionName); //$NON-NLS-1$
+			corporaElem.appendChild(partitionElem);
+			this.setSelfElement(partitionElem);
+			for (Part p : parts) {
+				Element partElem = doc.createElement("part"); //$NON-NLS-1$
+				partElem.setAttribute("name", p.getName()); //$NON-NLS-1$
+				partElem.setAttribute("shortname", p.getShortName()); //$NON-NLS-1$
+				partElem.setAttribute("query", p.getQuery().getQueryString()); //$NON-NLS-1$
+				partitionElem.appendChild(partElem);
+			}
+		} catch (Exception e) {
+			System.out.println(TXMCoreMessages.Partition_21+e);
+		}
+		this.load();
+	}
+
+	/**
+	 * Register to parent.
+	 */
+	public void registerToParent() {
+		registerToParent(this.name);
+	}
+
+//	/* (non-Javadoc)
+//	 * @see org.txm.objects.TxmObject#hasChildren(org.txm.objects.TxmObject)
+//	 */
+//	@Override
+//	public boolean hasChildren(TxmObject children) {
+//		return parts.size() > 0;
+//	}
+
+	/**
+	 * Load.
+	 *
+	 * @param e the e
+	 * @return true, if successful
+	 */
+	public boolean load(Element e) {
+		this.setSelfElement(e);
+		return this.load();
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.objects.TxmObject#load()
+	 */
+	@Override
+	public boolean load() {
+		if (this.getSelfElement() != null && this.getParent() != null) {
+			NodeList partList = getSelfElement().getChildNodes();
+			for (int i = 0; i < partList.getLength(); i++) {
+				if (partList.item(i).getNodeType() == 1) {
+					Element c = (Element) partList.item(i);
+					if (c.getNodeName().equals("part")) //$NON-NLS-1$
+					{
+						String pname = c.getAttribute("name"); //$NON-NLS-1$
+						String pshortname = c.getAttribute("shortname"); //$NON-NLS-1$
+						String pquery = c.getAttribute("query"); //$NON-NLS-1$
+						for (Part part : parts)
+							if (part.getName().equals(pname)) {
+								part.setName(pname);
+								part.setShortName(pshortname);
+								part.setQuery(pquery);
+							}
+					}
+				}
+			}
+			this.loadMetadata();
+			return true;
+		}
+
+		return false;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.objects.TxmObject#removeChildren(org.txm.objects.TxmObject)
+	 */
+	public TxmObject removeChildren(TxmObject children) {
+		if (children instanceof Part) {
+			if (children.getSelfElement() != null && children.getSelfElement().getParentNode() == getSelfElement())
+				getSelfElement().removeChild(children.getSelfElement());
+			parts.remove(children);
+			return children;
+		}
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.objects.TxmObject#save()
+	 */
+	@Override
+	public boolean save() {
+		return false;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.objects.TxmObject#delete()
+	 */
+	@Override
+	public boolean delete() {
+		try {
+			this.getCorpus().dropPartition(this);
+			super.delete();
+			this.getSelfElement().getParentNode().removeChild(getSelfElement());
+			return true;
+		} catch (CqiClientException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+		return false;
+	}
+
+//	/* (non-Javadoc)
+//	 * @see org.txm.HasResults#getSubHasResults()
+//	 */
+//	@Override
+//	public List<HasResults> getSubHasResults() {
+//		return new ArrayList<HasResults>(0);
+//	}
+
+	/**
+	 * Gets the total of all part sizes.
+	 * @return
+	 * @throws CqiClientException
+	 */
+	public int getTotalSize() throws CqiClientException {
+		if (totalsize == -1) {
+			totalsize = 0;
+			for (Part p : parts) {
+				totalsize += p.getSize();
+			}
+		}
+		return totalsize;
+	}
+
+	/**
+	 * Gets the part sizes as int array.
+	 * @return
+	 * @throws CqiClientException
+	 */
+	public int[] getPartSizes() throws CqiClientException {
+		if (partSizes != null)
+			return partSizes;
+		partSizes = new int[getParts().size()];
+		for (int i = 0 ; i < getParts().size() ; i++) {
+			Part p = getParts().get(i);
+			partSizes[i] = p.getSize();
+		}
+		return partSizes;
+	}
+	
+	/**
+	 * Remove the specified <code>Part</code> from the partition.
+	 * @param p
+	 * @throws CqiClientException
+	 */
+	public void removePart(Part p) throws CqiClientException {
+		parts.remove(p);
+		p.dropSubcorpus(p);
+	}
+
+	@Override
+	public String getName() {
+		return this.name + ": "+ this.getNPart();
+	}
+
+
+	@Override
+	public String getSimpleName() {
+		return this.name;
+	}
+
+	@Override
+	public String getDetails() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public void clean() {
+		// TODO Auto-generated method stub
+		
+	}
+
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CqpObject.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CqpObject.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CqpObject.java	(revision 449)
@@ -0,0 +1,125 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus;
+
+import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The top class for all object having a counterpart in CQP.
+ * 
+ * @author Jean-Philippe Magué
+ */
+public interface CqpObject {
+
+	/** The Constant subcorpusNamePrefix. */
+	public static final String subcorpusNamePrefix = "S"; //$NON-NLS-1$
+
+	/** The Constant partNamePrefix. */
+	public static final String partNamePrefix = "P"; //$NON-NLS-1$
+
+	/** The Constant queryResultNamePrefix. */
+	public static final String queryResultNamePrefix = "Q"; //$NON-NLS-1$
+
+	/**
+	 * The cqp id.
+	 *
+	 * @param cqpId the cqp id
+	 * @return true, if successful
+	 * @throws InvalidCqpIdException the invalid cqp id exception
+	 */
+	// protected String cqpId;
+
+	/** The name. */
+	// protected String name;
+
+	/** The size. */
+	// protected int size = -1;
+
+	/** The mother main corpus. */
+	// protected MainCorpus motherMainCorpus;
+
+	/**
+	 * Instantiates a new cqp object mirroring the corpus in CQP with the given
+	 * id.
+	 * 
+	 * @param cqpId
+	 *            the cqp id
+	 * 
+	 * @throws InvalidCqpIdException
+	 *             the invalid cqp id exception
+	 */
+	// public void CqpObject(String cqpId);// throws InvalidCqpIdException;/*{
+
+	/**
+	 * Check whether the ID is a valid CQP ID.
+	 * 
+	 * @param cqpId
+	 *            the cqp id
+	 * 
+	 * @return true, if cqpId is a valid CQP ID.
+	 * 
+	 * @throws InvalidCqpIdException
+	 *             the invalid cqp id exception
+	 */
+	public boolean checkCqpId(String cqpId) throws InvalidCqpIdException;
+
+	/**
+	 * Gets the cqp id.
+	 * 
+	 * @return the cqp id
+	 */
+	public String getCqpId();/*
+							 * { return cqpId; }
+							 */
+
+	/**
+	 * Gets the name.
+	 * 
+	 * @return the name
+	 */
+	public String getName();/*
+							 * { return name; }
+							 */
+
+	/**
+	 * Gets the qualified cqp id.
+	 * 
+	 * @return the qualified cqp id
+	 */
+	public String getQualifiedCqpId();
+
+	/**
+	 * Gets the mother corpus.
+	 * 
+	 * @return the mother corpus
+	 */
+	public MainCorpus getMainCorpus();/*
+											 * { return motherMainCorpus; }
+											 */
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Corpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Corpus.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Corpus.java	(revision 449)
@@ -0,0 +1,1320 @@
+// 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: 2016-11-29 16:47:07 +0100 (Tue, 29 Nov 2016) $
+// $LastChangedRevision: 3349 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+
+import org.eclipse.osgi.util.NLS;
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.core.results.ITXMResult;
+import org.txm.functions.selection.SelectionResult;
+import org.txm.objects.Base;
+import org.txm.objects.TxmObject;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException;
+import org.txm.searchengine.cqp.corpus.query.Match;
+import org.txm.searchengine.cqp.corpus.query.Query;
+import org.txm.searchengine.cqp.corpus.query.QueryPart;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
+import org.txm.utils.logger.Log;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class Corpus. A corpus is either a whole corpus, as managed by CQP or a
+ * subcorpus.
+ * 
+ * @see org.txm.searchengine.cqp.corpus.MainCorpus
+ * @see org.txm.searchengine.cqp.corpus.Subcorpus
+ * 
+ * @author Jean-Philippe Magué, Sylvain Loiseau
+ */
+public abstract class Corpus extends org.txm.objects.Corpus implements CqpObject {
+
+	public static String getNextQueryCounter() {
+		QUERY_COUNTER++;
+		return QUERY_COUNTER.toString();
+	}
+	public static String getNextSubcorpusCounter() {
+		SUBCORPUS_COUNTER++;
+		return SUBCORPUS_COUNTER.toString();
+	}
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -2484830241553310773L;
+
+	/** The cqp id. */
+	protected String cqpId;
+
+	/** The size. */
+	protected int size = -1;
+
+	/** The mother main corpus. */
+	protected MainCorpus motherMainCorpus;
+	/** The corpus structural units. */
+	protected List<StructuralUnit> structuralUnits;
+
+	/** The corpus lexical units properties. */
+	protected List<Property> lexicalUnitsProperties;
+
+	protected int[] textLimits;
+
+	/** All the subcorpora that have been created from this corpus. */
+	protected List<Subcorpus> subcorpora;
+
+	/** All partitions that have been created from this corpus. */
+	protected List<Partition> partitions;
+
+	/** All private infos of the corpus. */
+	private String charset = "latin1"; //$NON-NLS-1$
+
+	/** The language. */
+	private String language = "???"; //$NON-NLS-1$
+	
+	
+	/**
+	 * Gets the locale of the corpus.
+	 * 
+	 * @return the locale
+	 */
+	String lang = null;
+
+	/** The nocorpus. */
+	protected static int nocorpus = 1;
+
+	/** The prefix r. */
+	protected static String prefixR = "Corpus"; //$NON-NLS-1$
+
+	/** The symbol. */
+	private String symbol;
+
+	protected static String WORD = "word"; //$NON-NLS-1$
+
+	protected Property wordProperty = null;
+
+	protected static Integer SUBCORPUS_COUNTER = new Integer(0);
+
+	private static Integer QUERY_COUNTER = new Integer(0);
+
+	/**
+	 * Creates a new object mapping a CQP corpus. This constructor is not
+	 * intended to be used directly. Use {@link CorpusManager#getCorpus(String)}
+	 * .
+	 * 
+	 * @param cqpId
+	 *            the id of the cqp corpus
+	 * 
+	 * @throws InvalidCqpIdException
+	 *             the invalid cqp id exception
+	 */
+	protected Corpus(String cqpId) throws InvalidCqpIdException {
+		super(null, null);
+		checkCqpId(cqpId);
+		this.cqpId = cqpId;
+		subcorpora = new ArrayList<Subcorpus>();
+		partitions = new ArrayList<Partition>();
+	}
+
+	
+	
+	/**
+	 * Creates a partition using a list of CQP queries.
+	 *
+	 * @param name the name
+	 * @param queries the queries
+	 * @return the partition
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Partition createPartition(String name, List<String> queries)
+			throws CqiClientException {
+		Partition partition = createPartition(name, queries, false);
+		return partition;
+	}
+
+	/**
+	 * Creates a partition using a list of CQP queries and save the Partition configuration in Workspace.
+	 * 
+	 * <strong>warning</strong> : this partition is not guaranteed to cover the
+	 * whole corpus neither to be non-intersecting.
+	 *
+	 * @param name the name
+	 * @param queries the queries
+	 * @param registered the registered
+	 * @return the partition
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Partition createPartition(String name, List<String> queries,
+			boolean registered) throws CqiClientException {
+		Partition partition = new Partition(this, name, queries);
+		partitions.add(partition);
+		if (!registered)
+			partition.registerToParent();
+		return partition;
+	}
+
+	/**
+	 * Create a partition from a set of queries and names.
+	 * 
+	 * <strong>warning</strong> : this partition is not guaranteed to cover the
+	 * whole corpus neither to be non-intersecting.
+	 *
+	 * @param name the name
+	 * @param queries the queries
+	 * @param partnames the partnames
+	 * @return the partition
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Partition createPartition(String name, List<String> queries,
+			List<String> partnames) throws CqiClientException {
+		Partition p = createPartition(name, queries, partnames, false);
+		return p;
+	}
+
+	/**
+	 * Creates a partition using a list of CQP queries and names each part.
+	 *
+	 * @param name the name
+	 * @param queries the queries
+	 * @param partnames the partnames
+	 * @param registered the registered
+	 * @return the partition
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Partition createPartition(String name, List<String> queries,
+			List<String> partnames, boolean registered)
+					throws CqiClientException {
+		Partition partition = new Partition(this, name, queries, partnames);
+		partitions.add(partition);
+		if (!registered)
+			partition.registerToParent();
+		return partition;
+	}
+
+	/**
+	 * Create a partition with all values of a structural unit property.
+	 *
+	 * @param name the name
+	 * @param structure the structure
+	 * @param property the property
+	 * @return the partition
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Partition createPartition(String name, StructuralUnit structure,
+			StructuralUnitProperty property) throws CqiClientException {
+		Partition partition = createPartition(structure, property);
+		partition.setName(name);
+		return partition;
+	}
+
+	/**
+	 * Create a partition with a set of values of a structural unit property.
+	 *
+	 * @param name the name
+	 * @param structure the structure
+	 * @param property the property
+	 * @param values the values
+	 * @return the partition
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Partition createPartition(String name, StructuralUnit structure,
+			StructuralUnitProperty property, List<String> values)
+					throws CqiClientException {
+		Partition partition = createPartition(name, structure, property,
+				values, false);
+		return partition;
+	}
+
+	/**
+	 * Create a partition with a set of values of a structural unit property.
+	 * save result configuration in Workspace
+	 *
+	 * @param name the name
+	 * @param structure the structure
+	 * @param property the property
+	 * @param values the values
+	 * @param registered the registered
+	 * @return the partition
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Partition createPartition(String name, StructuralUnit structure,
+			StructuralUnitProperty property, List<String> values,
+			boolean registered) throws CqiClientException {
+		Partition partition = createPartition(structure, property, values,
+				registered);
+		if (name != null)
+			partition.setName(name);
+		return partition;
+	}
+
+	/**
+	 * Creates a new partition from a structural unit and a property of this
+	 * structural unit. One part is created for each possible value of the
+	 * property.
+	 * 
+	 * @param structure
+	 *            the structure
+	 * @param property
+	 *            the property
+	 * 
+	 * @return the partition
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 * 
+	 * @see org.txm.searchengine.cqp.corpus.partition.core.corpusengine.cqp.corpus.Partition#Partition
+	 */
+	public Partition createPartition(StructuralUnit structure,
+			StructuralUnitProperty property) throws CqiClientException {
+		Partition partition = createPartition(structure, property, false);
+		return partition;
+	}
+	/**
+	 * Creates the partition.
+	 *
+	 * @param structure the structure
+	 * @param property the property
+	 * @param registered the registered
+	 * @return the partition
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Partition createPartition(StructuralUnit structure,
+			StructuralUnitProperty property, boolean registered)
+					throws CqiClientException {
+		Partition partition = new Partition(this, structure, property);
+		partitions.add(partition);
+		if (!registered)
+			partition.registerToParent();
+		return partition;
+	}
+	
+
+	/**
+	 * Creates a new partition from a structural unit, a property of this
+	 * structural unit and a list of possible values for the property. One part
+	 * per value is created. <strong>warning</strong> : this partition is not
+	 * guaranteed to cover the whole corpus
+	 * 
+	 * @param structure
+	 *            the structure
+	 * @param property
+	 *            the property
+	 * @param values
+	 *            the values
+	 * 
+	 * @return the partition
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 * 
+	 * @see org.txm.searchengine.cqp.corpus.partition.core.corpusengine.cqp.corpus.Partition#Partition
+	 */
+	public Partition createPartition(StructuralUnit structure,
+			StructuralUnitProperty property, List<String> values)
+					throws CqiClientException {
+		Partition partition = createPartition(structure, property, values,
+				false);
+		return partition;
+	}
+
+	/**
+	 * Creates the partition.
+	 *
+	 * @param structure the structure
+	 * @param property the property
+	 * @param values the values
+	 * @param registered the registered
+	 * @return the partition
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Partition createPartition(StructuralUnit structure,
+			StructuralUnitProperty property, List<String> values,
+			boolean registered) throws CqiClientException {
+		Partition partition = new Partition(this, structure, property, values);
+		partitions.add(partition);
+		if (!registered)
+			partition.registerToParent();
+		return partition;
+	}
+
+	/**
+	 * Creates a subcorpus using workspace definition.
+	 *
+	 * @param elem the XML element
+	 * @return the subcorpus
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Subcorpus createSubcorpus(Element elem) throws CqiClientException {
+		Query query = new Query(elem.getAttribute("query")); //$NON-NLS-1$
+		String subcorpusName = elem.getAttribute("name"); //$NON-NLS-1$
+
+		Subcorpus subcorpus;
+		String subcorpusCqpId = subcorpusNamePrefix	+ getNextSubcorpusCounter();
+
+		// long start = System.currentTimeMillis();
+		try {
+			CorpusManager.getCorpusManager().getCqiClient().cqpQuery(this.getQualifiedCqpId(), subcorpusCqpId,
+					query.getQueryString());
+			subcorpus = new Subcorpus(subcorpusCqpId, subcorpusName, this, query);
+			subcorpus.setSelfElement(elem);
+			subcorpora.add(subcorpus);
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+
+		return subcorpus;
+	}
+
+	/**
+	 * Create a named subcorpus from a query on this corpus.
+	 * 
+	 * @param query
+	 *            the query
+	 * @param subcorpusName
+	 *            the resulting subcorpus name
+	 * 
+	 * @return the resulting subcorpus
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public Subcorpus createSubcorpus(Query query, String subcorpusName)
+			throws CqiClientException {
+		Subcorpus sc = createSubcorpus(query, subcorpusName, false);
+		return sc;
+	}
+
+	/**
+	 * Creates a subcorpus and save configuration in the workspace.
+	 *
+	 * @param query the query
+	 * @param subcorpusName the subcorpus name
+	 * @param registered the registered
+	 * @return the subcorpus
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Subcorpus createSubcorpus(Query query, String subcorpusName,
+			boolean registered) throws CqiClientException {
+		Subcorpus subcorpus;
+		String subcorpusCqpId = subcorpusNamePrefix + getNextSubcorpusCounter().toString();
+		Log.finest(TXMCoreMessages.CREATING_SUBCORPUS + this.getQualifiedCqpId()
+				+ " " + subcorpusName + " " + query.getQueryString()); //$NON-NLS-1$ //$NON-NLS-2$
+
+		long start = System.currentTimeMillis();
+		try {
+			CorpusManager.getCorpusManager().getCqiClient().cqpQuery(
+					this.getQualifiedCqpId(), subcorpusCqpId,
+					query.getQueryString());
+			//System.out.println("SUBCORPUS: "+subcorpusCqpId+" q="+query.getQueryString());
+			subcorpus = new Subcorpus(subcorpusCqpId, subcorpusName, this, query);
+			subcorpora.add(subcorpus);
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+		long end = System.currentTimeMillis();
+		Log.finest(TXMCoreMessages.SUBCORPUS_CREATED + subcorpusName
+				+ TXMCoreMessages.Corpus_8 + (end - start));
+
+		if (!registered) subcorpus.registerToParent();
+		return subcorpus;
+	}
+
+	public Subcorpus createSubcorpus(String name, QueryResult queryResult) throws InvalidCqpIdException {
+		Subcorpus sub = new Subcorpus(queryResult.getCqpId(), name, this, null);
+		subcorpora.add(sub);
+		return sub;
+	}
+
+	public Subcorpus createSubcorpus(String name, String cqpid) throws InvalidCqpIdException {
+		Subcorpus sub = new Subcorpus(cqpid, name, this, null);
+		subcorpora.add(sub);
+		return sub;
+	}
+	
+	/**
+	 * Creates the subcorpus.
+	 *
+	 * @param elem the elem
+	 * @return the subcorpus
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Subcorpus createSubcorpus(String name, SelectionResult selectionResult) throws CqiClientException {
+		Subcorpus sub = createSubcorpus(this.getStructuralUnit("text"), this.getStructuralUnit("text").getProperty("id"), selectionResult, name); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		sub.setSelectionResult(selectionResult);
+		return sub;
+	}
+	
+	/**
+	 * Creates the subcorpus.
+	 *
+	 * @param structuralUnit the structural unit
+	 * @param structuralUnitProperty the structural unit property
+	 * @param values the values
+	 * @param subcorpusName the subcorpus name
+	 * @return the subcorpus
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Subcorpus createSubcorpus(StructuralUnit structuralUnit,
+			StructuralUnitProperty structuralUnitProperty, List<String> values,
+			String subcorpusName) throws CqiClientException {
+		if (values.size() == 0) {
+			Log.warning(TXMCoreMessages.Corpus_5);
+			return null;
+		}
+		String value = ""; //$NON-NLS-1$
+		for (String v : values)
+			value += Query.addBackSlash(v) + "|"; //$NON-NLS-1$
+		value = value.substring(0, value.length() - 1);
+		
+		Query query = new QueryPart(structuralUnit, structuralUnitProperty, value);
+		return createSubcorpus(query, subcorpusName);
+		//return createSubcorpus(structuralUnit, structuralUnitProperty, value, subcorpusName);
+	}
+
+	/**
+	 * Create a subcorpus from a structural unit, a property on this structural
+	 * unit and a value for this property.
+	 *
+	 * @param structuralUnit the structural unit
+	 * @param structuralUnitProperty the structural unit property
+	 * @param value the value
+	 * @param subcorpusName the subcorpus name
+	 * @return the subcorpus
+	 * @throws CqiClientException the cqi client exception
+	 * @author Sylvain Loiseau
+	 */
+	public Subcorpus createSubcorpus(StructuralUnit structuralUnit,
+			StructuralUnitProperty structuralUnitProperty, String value,
+			String subcorpusName) throws CqiClientException {
+		Query query = new QueryPart(structuralUnit, structuralUnitProperty,
+				Query.addBackSlash(value));
+		// System.out.println("forged query : "+query.getQueryString());
+		return createSubcorpus(query, subcorpusName);
+	}
+
+	/**
+	 * Create a subcorpus from a structural unit, a property on this structural
+	 * unit and a value for this property.
+	 *
+	 * @param structuralUnit the structural unit
+	 * @param structuralUnitProperty the structural unit property
+	 * @param value the value
+	 * @param subcorpusName the subcorpus name
+	 * @return the subcorpus
+	 * @throws CqiClientException the cqi client exception
+	 * @author Sylvain Loiseau
+	 */
+	public Subcorpus createSubcorpusWithQueryString(StructuralUnit structuralUnit,
+			StructuralUnitProperty structuralUnitProperty, String value,
+			String subcorpusName) throws CqiClientException {
+		Query query = new QueryPart(structuralUnit, structuralUnitProperty,
+				value);
+		// System.out.println("forged query : "+query.getQueryString());
+		return createSubcorpus(query, subcorpusName);
+	}
+
+	/**
+	 * Drop all the partitions.
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public void dropAllPartitions() throws CqiClientException {
+		List<Partition> _partitions = new ArrayList<Partition>();
+		_partitions.addAll(partitions);
+		for (Partition partition : _partitions)
+			this.dropPartition(partition);
+		_partitions = null;
+	}
+
+	/**
+	 * Drop all the subcorpora.
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public void dropAllSubcorpora() throws CqiClientException {
+		//System.out.println("!! drop all subcorpora: "+subcorpora.size());
+		while(subcorpora.size() > 0)
+			this.dropSubcorpus(subcorpora.get(0));
+	}
+
+	/**
+	 * Drops a partition.
+	 * 
+	 * @param partition
+	 *            the partition
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public void dropPartition(Partition partition) throws CqiClientException {
+		Log.finest(TXMCoreMessages.DROP_PARTITION + partition.getName());
+		for (Part part : partition.getParts())
+			try {
+				CorpusManager.getCorpusManager().getCqiClient().dropSubCorpus(part.getQualifiedCqpId());
+			} catch (Exception e) {
+				throw new CqiClientException(e);
+			}
+		partitions.remove(partition);
+	}
+
+	/**
+	 * Drop query result.
+	 * 
+	 * @param queryResult
+	 *            the query result
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public void dropQueryResult(QueryResult queryResult)
+			throws CqiClientException {
+		Log.finest(TXMCoreMessages.DROP_QUERYRESULT + queryResult.getName());
+		try {
+			CorpusManager.getCorpusManager().getCqiClient().dropSubCorpus(queryResult.getQualifiedCqpId());
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+	}
+
+	/**
+	 * Drops a subcorpus in CQP also its subcorpus and partitions.
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public boolean dropSubcorpus(Corpus subcorpus) throws CqiClientException {
+		Log.finest(NLS.bind(TXMCoreMessages.DROP_SUBCORPUS, subcorpus.getName()));
+		subcorpus.dropAllSubcorpora();
+		subcorpus.dropAllPartitions();
+		try {
+			CorpusManager.getCorpusManager().getCqiClient().dropSubCorpus(
+					subcorpus.getQualifiedCqpId());
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+		return subcorpora.remove(subcorpus);
+	}
+
+	/**
+	 * Test if 2 corpus have the same CQP id.
+	 *
+	 * @param c the c
+	 * @return true, if successful
+	 */
+	public boolean equals(Corpus c) {
+		return cqpId.equals(c.cqpId);
+	}
+
+	/**
+	 * Gets the base.
+	 *
+	 * @return the base
+	 */
+	@Override
+	public abstract Base getBase();
+
+	/**
+	 * Get the charset using CQP registry.
+	 *
+	 * @return the charset
+	 */
+	public String getCharset() {
+		if (this.charset.matches("latin1")) //$NON-NLS-1$
+			return "ISO-8859-1"; //$NON-NLS-1$
+		else if (this.charset.matches("latin2")) //$NON-NLS-1$
+			return "ISO-8859-2"; //$NON-NLS-1$
+		else if (this.charset.matches("latin3")) //$NON-NLS-1$
+			return "ISO-8859-3"; //$NON-NLS-1$
+		else if (this.charset.matches("latin4")) //$NON-NLS-1$
+			return "ISO-8859-4"; //$NON-NLS-1$
+		else if (this.charset.matches("latin5")) //$NON-NLS-1$
+			return "ISO-8859-5"; //$NON-NLS-1$
+		else if (this.charset.matches("latin6")) //$NON-NLS-1$
+			return "ISO-8859-6"; //$NON-NLS-1$
+		else if (this.charset.matches("latin7")) //$NON-NLS-1$
+			return "ISO-8859-7"; //$NON-NLS-1$
+		else if (this.charset.matches("latin8")) //$NON-NLS-1$
+			return "ISO-8859-8"; //$NON-NLS-1$
+		else if (this.charset.matches("latin9")) //$NON-NLS-1$
+			return "ISO-8859-9"; //$NON-NLS-1$
+		return charset;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.objects.TxmObject#getChildren()
+	 */
+	public List<? extends TxmObject> getChildren() {
+		List<? extends TxmObject> ret = subcorpora;
+		return ret;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.searchengine.cqp.corpus.CqpObject#getCqpId()
+	 */
+	@Override
+	public String getCqpId() {
+		return cqpId;
+	}
+
+	/**
+	 * Gets the corpus informations using CQP registry.
+	 *
+	 * @return the infos
+	 */
+	public String getInfos() {
+		return TXMCoreMessages.Corpus_2 + this.name + TXMCoreMessages.Corpus_3 + getCharset()
+				+ TXMCoreMessages.Corpus_4 + getLanguage();
+	}
+
+	/**
+	 * Gets the language.
+	 *
+	 * @return the language
+	 */
+	public String getLanguage() {
+		return language;
+	}
+
+	/**
+	 * Get the corpus locale using txmcorpus_lang property
+	 * @return
+	 */
+	public Locale getLocale() {
+		/*Serializable lang = this.getAttribute("lang"); //$NON-NLS-1$
+		if (lang != null) {
+			return new Locale(lang.toString());
+		} else
+			return Locale.getDefault();*/
+		//System.out.println("getLang1: "+lang);
+		if(lang == null) {
+			try {
+				StructuralUnit su = this.getStructuralUnit("txmcorpus"); //$NON-NLS-1$
+				StructuralUnitProperty prop = su.getProperty("lang"); //$NON-NLS-1$
+				List<String> values = prop.getValues();
+				if(values.size() > 0)
+					lang = values.get(0);
+				//System.out.println("get lang: "+lang);
+			} catch (Exception e) {
+				// TODO Auto-generated catch block
+				//org.txm.utils.logger.Log.printStackTrace(e);
+				System.out.println(TXMCoreMessages.Corpus_13+e);
+			}
+		}
+		if(lang != null)
+			return new Locale(lang);
+		else
+			return Locale.getDefault();
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.searchengine.cqp.corpus.CqpObject#getMotherMainCorpus()
+	 */
+	@Override
+	public MainCorpus getMainCorpus() {
+		if (this instanceof MainCorpus) return (MainCorpus) this;
+
+		if (this.getParent() == null) return null;
+		if (motherMainCorpus == null) {
+			if (this.getParent() instanceof MainCorpus)
+				motherMainCorpus = (MainCorpus) this.getParent();
+			else
+				motherMainCorpus = ((Subcorpus)this.getParent()).getMainCorpus();
+		}
+		return motherMainCorpus;
+	}
+
+	abstract public List<Match> getMatches();
+
+
+	
+	@Override
+	public String getName() {
+		return name;
+	}
+	
+	@Override
+	public String getSimpleName() {
+		return name;
+	}
+	
+	/**
+	 * Get the ordered properties (by name).
+	 *
+	 * @return the ordered properties
+	 * @throws CqiClientException the cqi client exception
+	 */
+	@SuppressWarnings("unchecked") //$NON-NLS-1$
+	public List<Property> getOrderedProperties() throws CqiClientException {
+		List<Property> props = this.getProperties();
+		Collections.sort(props);
+		return props;
+	}
+
+	/**
+	 * Get the ordered Structural unit properties (by name)
+	 * @return
+	 * @throws CqiClientException
+	 */
+	public Collection<? extends Property> getOrderedStructuralUnitProperties()
+			throws CqiClientException {
+		List<StructuralUnitProperty> properties = new ArrayList<StructuralUnitProperty>();
+		for (StructuralUnit su : this.getOrderedStructuralUnits())
+			if (su.getProperties() != null)
+				properties.addAll(su.getProperties());
+
+		return properties;
+	}
+
+	/**
+	 * Get the ordered structural units.
+	 *
+	 * @return the ordered structural units
+	 * @throws CqiClientException the cqi client exception
+	 */
+	@SuppressWarnings("unchecked") //$NON-NLS-1$
+	public List<StructuralUnit> getOrderedStructuralUnits() throws CqiClientException {
+		List<StructuralUnit> units = this.getStructuralUnits();
+		Collections.sort(units);
+		return units;
+	}
+
+	/**
+	 * Get all the partitions defined on a given corpus.
+	 *
+	 * @param name the name
+	 * @return the partitions
+	 */
+	public Partition getPartition(String name) {
+		for (Partition p : partitions)
+			if (p.getName().equals(name))
+				return p;
+		return null;
+	}
+
+	/**
+	 * Gets all the partitions defined on a given corpus.
+	 * 
+	 * @return the partitions
+	 */
+	public List<Partition> getPartitions() {
+		return partitions;
+	}
+
+	/**
+	 * Gets the properties defined for the lexical units of this corpus.
+	 * 
+	 * @return the properties
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public abstract List<Property> getProperties() throws CqiClientException;
+
+	/**
+	 * Gets a property from its name.
+	 * 
+	 * @param name
+	 *            the name
+	 * 
+	 * @return the property
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public abstract Property getProperty(String name) throws CqiClientException;
+
+	
+	//FIXME: to remove when proved, should not be useful anymore in new TXMResult hierarchy
+//	/**
+//	 * Gets the results of textometric computation stored in the corpus.
+//	 * 
+//	 * @return the results
+//	 */
+//	@Override
+//	public ArrayList<ITXMResult> getResults() {
+//		ArrayList<ITXMResult> allResults = new ArrayList<ITXMResult>();
+//		allResults.addAll(this.children);
+//		allResults.addAll(this.lexicons.values());
+//		return allResults;
+//	}
+
+	/**
+	 * Gets the CQP size of the corpus.
+	 *
+	 * @return the size
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public abstract int getSize() throws CqiClientException;
+
+	/**
+	 * Gets a structural unit from its name.
+	 *
+	 * @param name the name
+	 * @return the structural unit
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public abstract StructuralUnit getStructuralUnit(String name)
+			throws CqiClientException;
+
+	/**
+	 * Gets all structural units property of a corpus.
+	 *
+	 * @return the structural unit properties
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public List<StructuralUnitProperty> getStructuralUnitProperties()
+			throws CqiClientException {
+		if (this.structuralUnits == null)
+			getStructuralUnits();
+
+		List<StructuralUnitProperty> properties = new ArrayList<StructuralUnitProperty>();
+		if (this.structuralUnits != null)
+			for (StructuralUnit su : this.structuralUnits)
+				if (su.getProperties() != null)
+					properties.addAll(su.getProperties());
+
+		return properties;
+	}
+
+	/**
+	 * Gets a structural units property of a structural unit by its name.
+	 *
+	 * @param name the name
+	 * @return the structural unit properties
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public List<StructuralUnitProperty> getStructuralUnitProperties(String name)
+			throws CqiClientException {
+		StructuralUnit su = this.getStructuralUnit(name);
+
+		return su.getProperties();
+	}
+
+	/**
+	 * Gets the structural units defined on this corpus.
+	 * 
+	 * @return the structural units
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public abstract List<StructuralUnit> getStructuralUnits()
+			throws CqiClientException;
+
+	/**
+	 * Gets all the subcorpora defined on a given corpus.
+	 * 
+	 * @return the subcorpora
+	 */
+	public List<Subcorpus> getSubcorpora() {
+		return subcorpora;
+	}
+
+	/**
+	 * Gets the subcorpus by name.
+	 *
+	 * @param name the name
+	 * @return the subcorpus by name
+	 */
+	public Corpus getSubcorpusByName(String name)
+	{
+		for (Corpus corpus : subcorpora) {
+			if (corpus.getName().equals(name))
+				return corpus;
+		}
+
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.HasResults#getSubHasResults()
+	 */
+	public ArrayList<ITXMResult> getSubHasResults() {
+		ArrayList<ITXMResult> subresults = new ArrayList<ITXMResult>();
+		subresults.addAll(this.getSubcorpora());
+		subresults.addAll(this.getPartitions());
+		return subresults;
+	}
+	/**
+	 * Gets the R symbol is corpus was sent in R Workspace.
+	 *
+	 * @return the symbol
+	 */
+	public String getSymbol()
+	{
+		return symbol;
+	}
+
+	abstract public int[] getTextEndLimits() throws CqiClientException, IOException, CqiServerError, InvalidCqpIdException;
+
+	/*public List<Property> getPreferedOrderedProperties() throws CqiClientException {
+		if (this.getAttribute("viewprops_order"))
+		List<Property> props = this.getProperties();
+		Collections.sort(props);
+		return props;
+	}*/
+
+	abstract public int[] getTextStartLimits() throws CqiClientException, IOException, CqiServerError, InvalidCqpIdException;
+
+	abstract public int[] getStartLimits(String structural_unit_property) throws IOException, CqiServerError, InvalidCqpIdException, CqiClientException;
+	
+	public Property getWordProperty() throws CqiClientException {
+		if (wordProperty == null)
+			wordProperty = getProperty(WORD);
+		return wordProperty;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.objects.TxmObject#hasChildren(org.txm.objects.TxmObject)
+	 */
+	@Override
+	public boolean hasChildren(TxmObject children) {
+		return this.subcorpora.size() > 0;
+	}
+	/* (non-Javadoc)
+	 * @see org.txm.objects.TxmObject#load()
+	 */
+	@Override
+	public boolean load() {
+		//System.out.println("*** Load corpus: "+name);
+		if (getSelfElement() == null) {
+			System.out.println(TXMCoreMessages.Corpus_14+this+TXMCoreMessages.Corpus_15);
+			return false;
+		}
+
+		// 1- texts queries then
+		// 2- get metadatas, pattributes, sattributes, editions, biblios,  uis,
+		super.load();  
+		// System.out.println("Load corpus : "+this.name);
+		this.loadMetadata(); // read <prop>s
+
+		// 3- build saved subcorpus and partition
+		//System.out.println("restore subcorpora: "+selfElement);
+		NodeList preBuildElems = getSelfElement().getElementsByTagName("preBuild"); //$NON-NLS-1$
+		if (preBuildElems.getLength() > 0) {
+			Element preBuildElem = (Element) preBuildElems.item(0);
+			NodeList subcorpusElems = preBuildElem.getElementsByTagName("subcorpus"); //$NON-NLS-1$
+			for (int i = 0 ; i < subcorpusElems.getLength() ; i++) {
+				Element subcorpusElem = (Element) subcorpusElems.item(i);
+				if (!subcorpusElem.getParentNode().equals(preBuildElem)) continue; //level 1 elements
+				//System.out.println("subcorpus "+subcorpusElem.getAttribute("name"));
+				try {
+					Subcorpus subcorp = this.createSubcorpus(subcorpusElem);
+					subcorp.setSelfElement(subcorpusElem);
+					subcorp.load();
+				} catch (CqiClientException e) {
+					Log.warning(this.name + TXMCoreMessages.Corpus_12 + name
+							+ " : " + e); //$NON-NLS-1$
+				}
+			}
+
+			NodeList partitionElems = preBuildElem.getElementsByTagName("partition"); //$NON-NLS-1$
+			for (int i = 0 ; i < partitionElems.getLength() ; i++) {
+				Element partitionElem = (Element) partitionElems.item(i);
+				if (!partitionElem.getParentNode().equals(preBuildElem)) continue; //level 1 elements
+				String name = partitionElem.getAttribute("name"); //$NON-NLS-1$
+				List<String> names = new ArrayList<String>();
+				List<String> queries = new ArrayList<String>();
+
+				NodeList partElems = partitionElem.getElementsByTagName("part"); //$NON-NLS-1$
+				for (int j = 0; j < partElems.getLength(); j++) {
+					Element part = (Element) partElems.item(j);
+					names.add(part.getAttribute("name")); //$NON-NLS-1$
+					queries.add(part.getAttribute("query")); //$NON-NLS-1$
+				}
+				try {
+					//System.out.println("Create Partition with corpus "+this+" : "+name+", queries "+queries+", names "+names);
+					Partition partition = this.createPartition(name, queries, names, true);
+					partition.load(partitionElem);
+				} catch (CqiClientException e) {
+					Log.warning(this.name + TXMCoreMessages.Corpus_19 + name
+							+ " : " + e); //$NON-NLS-1$
+					//c.getParentNode().removeChild(c);
+				}
+			}
+		}
+
+		// 4- initialize JPA persistence of annotations
+//		try {
+//			AnnotationManager.getInstance().initTemporaryAnnotationDatabase(this);
+//		} catch(Exception e) {
+//			System.out.println("Fail to load annotation service: "+e);
+//			Log.printStackTrace(e);
+//		}
+//		
+		return false;
+	}
+	
+	/**
+	 * Runs a query on the corpus and store the result in a QueryResult.
+	 * 
+	 * !! each working query is store in the Base of the corpus !!
+	 * 
+	 * @param query
+	 *            the query
+	 * @param queryResultName
+	 *            the resulting subcorpus name
+	 * 
+	 * @return the resulting query result
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public QueryResult query(Query query, String queryResultName, boolean save)
+			throws CqiClientException {
+		QueryResult queryResult = null;
+		//String queryResultId = queryResultNamePrefix + UUID.randomUUID().toString();
+		String queryResultId = queryResultNamePrefix + getNextQueryCounter();
+		Log.finest(NLS.bind(TXMCoreMessages.QUERY, new String[]{this.getQualifiedCqpId(), queryResultId, query.getQueryString()})); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+		// long start = System.currentTimeMillis();
+		try {
+			CorpusManager.getCorpusManager().getCqiClient().cqpQuery(
+					this.getQualifiedCqpId(), queryResultId,
+					query.getQueryString());
+			queryResult = new QueryResult(queryResultId, queryResultName, this,	query);
+			if (save) super.addQueryLog(query.toString(), new ArrayList<String>());
+		} catch (Exception e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			throw new CqiClientException(e);
+		}
+		// long end = System.currentTimeMillis();
+		// Log.finest(Messages.RETURN_FROM_QUERY+ " " + queryResult.getNMatch() + " " + (end - start)); //$NON-NLS-1$ //$NON-NLS-2$
+
+		return queryResult;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.objects.TxmObject#removeChildren(org.txm.objects.TxmObject)
+	 */
+	@Override
+	public TxmObject removeChildren(TxmObject children) {
+		Element preBuildElement = this.getBase().getBaseParameters().getPreBuildElement();
+		if (children instanceof Subcorpus) {
+			try {
+				if (children.getSelfElement() != null && 
+						children.getSelfElement().getParentNode() == getSelfElement())
+					preBuildElement.removeChild(children.getSelfElement());
+
+				if (!dropSubcorpus((Corpus) children)) {
+					System.out.println("Corpus.removeChildren: dropSubcorpus returned false.");
+					return null;
+				}
+				return children;
+			} catch (CqiClientException e) {
+				return null;
+			}
+		} else if (children instanceof Partition) {
+			if (children.getSelfElement() != null && 
+					children.getSelfElement().getParentNode() == getSelfElement()) {
+				preBuildElement.removeChild(children.getSelfElement());
+			}
+			partitions.remove(children);
+			try {
+				dropPartition((Partition) children);
+				return children;
+			} catch (CqiClientException e) {
+				return null;
+			}
+
+		}
+		return null;
+	}
+
+//	/**
+//	 * Removes a result stored in this corpus.
+//	 *
+//	 * @param result the result
+//	 * @return true, if successful
+//	 */
+//	public Object removeResult(int idx) {
+//		return results.remove(idx);
+//	}
+
+//	/**
+//	 * Removes a result stored in thsi corpus.
+//	 *
+//	 * @param result the result
+//	 * @return true, if successful
+//	 */
+//	@Override
+//	public boolean removeResult(Object result) {
+//		return results.remove(result);
+//	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.objects.TxmObject#save()
+	 */
+	@Override
+	public boolean save() {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	
+	
+//	/**
+//	 * Send the Corpus indexes to R.
+//	 * 
+//	 * Only the word properties are send.
+//	 * TODO: send structural unit properties too
+//	 *
+//	 * @return the string
+//	 * @throws Exception the exception
+//	 */
+//	public String SendToR() throws Exception
+//	{
+//		int initialPosition = 0;
+//		if (this.getMatches() != null && this.getMatches().size() > 0)
+//			initialPosition = this.getMatches().get(0).getStart();
+//		
+//		// cols name to export
+//		List<Property> props = this.getProperties();
+//		String[] colnames = new String[this.getProperties().size()];
+//
+//		// compute positions list
+//		int length = 0;
+//		for (Match match : getMatches()) { // 1) get number of positions
+//			length += match.getLength();
+//		}
+//		int[] positions = new int[length];
+//		int iPosition = 0;
+//		for (Match match : getMatches()) { // 2) append positions
+//			int p_end = match.getEnd();
+//			for (int p = match.getStart() ; p < p_end ; p++)
+//				positions[iPosition] = p;
+//		}
+//
+//		// 0- create the R object
+//		this.symbol = prefixR + (nocorpus++);
+//		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
+//		rw.eval(symbol +" <- matrix(ncol="+colnames.length+", nrow="+positions.length+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+//
+//		for(int i = 0 ; i < props.size() ; i++) {
+//			Property prop = props.get(i);
+//			colnames[i] = prop.getName();
+//			// send positions to R
+//			int[] idx = CorpusManager.getCorpusManager().getCqiClient().cpos2Id(prop.getQualifiedName(), positions);
+//			rw.addVectorToWorkspace("tmp", idx); //$NON-NLS-1$
+//			//if (initialPosition > 0) rw.eval("tmp <- tmp - "+initialPosition);
+//			//System.out.println("lengths "+prop.getName()+" : idx="+idx.length+" mat "+positions.length);
+//			rw.eval(symbol+"[,"+(i+1)+"] <- tmp"); //$NON-NLS-1$ //$NON-NLS-2$
+//		}
+//
+//		//set matrix col names
+//		rw.addVectorToWorkspace("tmpcol", colnames); //$NON-NLS-1$
+//		rw.eval("colnames("+symbol+") <- tmpcol"); //$NON-NLS-1$ //$NON-NLS-2$
+//
+//		rw.eval(symbol+" <- list(data="+symbol+")"); //$NON-NLS-1$ //$NON-NLS-2$
+//
+//		// create lexicons
+//		for (Property prop : this.getProperties()) {
+//			Lexicon lex = this.getLexicon(prop);
+//			rw.addVectorToWorkspace("tmp", lex.getForms()); //$NON-NLS-1$
+//			rw.eval(symbol+"$lex$"+prop.getName()+" <- tmp"); //$NON-NLS-1$ //$NON-NLS-2$
+//		}
+//		
+//		StructuralUnit text_su = this.getStructuralUnit("text");
+//		if (text_su != null) {
+//			StructuralUnitProperty text_id = text_su.getProperty("id");
+//			if (text_id != null) {
+//				int[] textlimits = this.getTextStartLimits();
+//				rw.addVectorToWorkspace("text_limits", textlimits);
+//				if (initialPosition > 0) rw.eval("text_limits <- text_limits - "+initialPosition);
+//				rw.eval(symbol+"$structs$text$start <- text_limits"); //$NON-NLS-1$ //$NON-NLS-2$
+//				
+//				textlimits = this.getTextEndLimits();
+//				rw.addVectorToWorkspace("text_limits", textlimits);
+//				if (initialPosition > 0) rw.eval("text_limits <- text_limits - "+initialPosition);
+//				//System.out.println("lengths "+prop.getName()+" : idx="+idx.length+" mat "+positions.length);
+//				rw.eval(symbol+"$structs$text$end <- text_limits"); //$NON-NLS-1$ //$NON-NLS-2$
+//			}
+//		}
+//
+//		return symbol;
+//	}
+
+	/**
+	 * set the corpus charset name, to be able to print it well.
+	 *
+	 * @param corpusCharset the new charset
+	 */
+	public void setCharset(String corpusCharset) {
+		this.charset = corpusCharset;
+	}
+
+	/**
+	 * set the corpus language name, to be able to sort it well.
+	 *
+	 * @param corpusLanguage the new language
+	 */
+	public void setLanguage(String corpusLanguage) {
+		this.language = corpusLanguage;
+	}
+	
+	
+//	/**
+//	 * Stores the result of textometric computation in this corpus.
+//	 * 
+//	 * @param result
+//	 *            the result
+//	 */
+//	public void storeResult(int idx, Object result) {
+//		results.add(idx, result);
+//	}
+//	/**
+//	 * Stores the result of textometric computation in this corpus.
+//	 * 
+//	 * @param result
+//	 *            the result
+//	 */
+//	public void storeResult(Object result) {
+//		results.add(result);
+//	}
+	
+	@Override
+	public String getCQLLimitQuery() {
+		return cql_limit_query;
+	}
+
+	public ArrayList<ITXMResult> clearResults() {
+		ArrayList<ITXMResult> old = this.children;
+		this.children = new ArrayList<ITXMResult>();
+		return old;
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/StructuralUnitProperty.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/StructuralUnitProperty.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/StructuralUnitProperty.java	(revision 449)
@@ -0,0 +1,243 @@
+// 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: 2013-09-05 09:27:13 +0200 (jeu., 05 sept. 2013) $
+// $LastChangedRevision: 2529 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.searchengine.cqp.AbstractCqiClient;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.corpus.query.Query;
+import org.txm.utils.logger.Log;
+// TODO: Auto-generated Javadoc
+/**
+ * A Property on the structural units the corpus. Represents a
+ * <strong>type</strong>, not a the value for a specif ic unit.
+ * 
+ * @author Jean-Philippe Magué
+ */
+public class StructuralUnitProperty extends Property implements Comparable {
+
+	/** The values. */
+	List<String> values;
+
+	/** The strucutral unit. */
+	private StructuralUnit strucutralUnit;
+
+	/**
+	 * Instantiates a new structural unit property.
+	 * 
+	 * Not intended to be used directly. See
+	 *
+	 * @param structuralUnit the structural unit
+	 * @param name the name
+	 * @param corpus the corpus
+	 * {@link StructuralUnit#getProperty(String)}
+	 */
+	protected StructuralUnitProperty(StructuralUnit structuralUnit,
+			String name, Corpus corpus) {
+		super(name, corpus);
+		this.strucutralUnit = structuralUnit;
+	}
+
+	/**
+	 * Gets the structural unit on wich the property is defined.
+	 * 
+	 * @return the structural unit
+	 */
+	public StructuralUnit getStructuralUnit() {
+		return strucutralUnit;
+	}
+
+	/**
+	 * Gets the qualified name.
+	 * 
+	 * @return the qualified name
+	 */
+	@Override
+	public String getQualifiedName() {
+		return strucutralUnit.getQualifiedName() + "_" + this.getName(); //$NON-NLS-1$
+	}
+
+	/**
+	 * Gets the full name: struct_propname
+	 *
+	 * @return the full name
+	 */
+	public String getFullName() {
+		return strucutralUnit.getName() + "_" + this.getName(); //$NON-NLS-1$
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.searchengine.cqp.corpus.Property#toString()
+	 */
+	@Override
+	public String toString() {
+		return this.getName();
+	}
+
+	/**
+	 * Gets a list of all the values this structural property takes in the
+	 * subcorpus.
+	 *
+	 * @param subcorpus The subcorpus in which the search is restricted
+	 * @return a List of values
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public List<String> getValues(Corpus subcorpus) throws CqiClientException {
+		try {
+			AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient();
+			return cqiClient.getData(this, subcorpus);
+		} catch (Exception e) {
+			Log.severe(TXMCoreMessages.StructuralUnitProperty_0
+					+ this.getFullName()+" : "+e); //$NON-NLS-1$
+		}
+		return new ArrayList<String>();
+
+		/*
+		 * //if (values == null) { QueryResult tmp = subcorpus.query(new
+		 * Query("<"+this.getFullName()+">[]"), UUID.randomUUID().toString());
+		 * //$NON-NLS-1$ //$NON-NLS-2$ List<Match> matches = tmp.getMatches();
+		 * tmp.drop(); values = new ArrayList<String>(new
+		 * HashSet<String>(Match.getValuesForProperty(this,matches))); } return
+		 * new ArrayList<String>(values);
+		 */
+	}
+	
+	/**
+	 * Gets a list of all the values this structural property takes in the
+	 * subcorpus
+	 * 
+	 * return an abstract of values.
+	 *
+	 * @param subcorpus The subcorpus in which the search is restricted
+	 * @param number the number
+	 * @return a List of values
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public List<String> getValues(Corpus subcorpus, int number) throws CqiClientException {
+		try {
+			AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient();
+			return cqiClient.getData(this, number);
+		} catch (Exception e) {
+			Log.severe(TXMCoreMessages.StructuralUnitProperty_0
+					+ this.getFullName()+" : "+e); //$NON-NLS-1$
+		}
+		return new ArrayList<String>();
+
+		/*
+		 * //if (values == null) { QueryResult tmp = subcorpus.query(new
+		 * Query("<"+this.getFullName()+">[]"), UUID.randomUUID().toString());
+		 * //$NON-NLS-1$ //$NON-NLS-2$ List<Match> matches = tmp.getMatches();
+		 * tmp.drop(); values = new ArrayList<String>(new
+		 * HashSet<String>(Match.getValuesForProperty(this,matches))); } return
+		 * new ArrayList<String>(values);
+		 */
+	}
+
+	/**
+	 * Gets a list of all the values this structural property takes in the main
+	 * corpus.
+	 *
+	 * @return a List of values
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public List<String> getValues() throws CqiClientException {
+		return getValues(this.getCorpus());
+	}
+	
+	/**
+	 * Gets a list of all the values this structural property takes in the main
+	 * corpus.
+	 *
+	 * @return a List of values
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public List<String> getOrderedValues() throws CqiClientException {
+		List<String> values = getValues(this.getCorpus());
+		Collections.sort(values);
+		return values;
+	}
+	
+	/**
+	 * Gets a list of all the values this structural property takes in the main
+	 * corpus.
+	 *
+	 * @param corpus the corpus
+	 * @return a List of values
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public List<String> getOrderedValues(Corpus corpus) throws CqiClientException {
+		List<String> values = getValues(corpus);
+		Collections.sort(values);
+		return values;
+	}
+
+	/**
+	 * Equals.
+	 *
+	 * @param p the p
+	 * @return true, if successful
+	 */
+	public boolean equals(StructuralUnitProperty p) {
+		return super.equals(p) && this.strucutralUnit.equals(p.strucutralUnit);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.searchengine.cqp.corpus.Property#compareTo(java.lang.Object)
+	 */
+	@Override
+	public int compareTo(Object o) {
+		if (o instanceof StructuralUnitProperty)
+			return (this.getQualifiedName().compareTo(
+					((StructuralUnitProperty) o).getQualifiedName()));
+		return 0;
+	}
+
+	/**
+	 * Gets the number of values.
+	 *
+	 * @param corpus the corpus
+	 * @return the number of values in this corpus, -1 if an error occured
+	 */
+	public Integer getNumberOfValues(Corpus corpus) {
+		try {
+			QueryResult tmp = corpus.query(
+					new Query("<" + this.getFullName() + ">[]"), UUID.randomUUID().toString(), false); //$NON-NLS-1$ //$NON-NLS-2$
+			int ret = tmp.getNMatch();
+			tmp.drop();
+			return ret;
+		} catch (CqiClientException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} 
+		return -1;// error
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/package.html
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/package.html	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/package.html	(revision 449)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>Classes representing corpus and corpus-like data structures wrapping and abstracting cqp objects and functions.</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java	(revision 449)
@@ -0,0 +1,622 @@
+// 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: 2017-01-24 18:11:42 +0100 (Tue, 24 Jan 2017) $
+// $LastChangedRevision: 3400 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.txm.Toolbox;
+import org.txm.annotation.AnnotationManager;
+import org.txm.annotation.repository.KnowledgeRepository;
+import org.txm.annotation.repository.KnowledgeRepositoryManager;
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.functions.ProgressWatcher;
+import org.txm.objects.Base;
+import org.txm.objects.BaseParameters;
+import org.txm.objects.TxmObject;
+import org.txm.searchengine.cqp.AbstractCqiClient;
+import org.txm.searchengine.cqp.CQPEngine;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException;
+import org.txm.searchengine.cqp.corpus.query.Match;
+import org.txm.searchengine.cqp.corpus.query.Query;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
+import org.txm.utils.DeleteDir;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class MainCorpus for mirroring CQP corpora.
+ *
+ * @author jmague, mdecorde
+ */
+public class MainCorpus extends Corpus {
+	
+	AnnotationManager am;
+
+	private static final long serialVersionUID = 6776153557376588804L;
+
+	/**
+	 * Instantiates a new corpus. This constructor is not intended to be used
+	 * directly. Use {@link CorpusManager#getCorpus(String)}.
+	 * 
+	 * @param cqpId
+	 *            the cqp id
+	 * 
+	 * @throws InvalidCqpIdException
+	 *             the invalid cqp id exception
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	protected MainCorpus(String cqpId) throws InvalidCqpIdException,
+	CqiClientException {
+		super(cqpId);
+		this.motherMainCorpus = this;
+		this.name = cqpId;
+	}
+
+	/**
+	 * Check whether the ID is a valid CQP ID.
+	 * 
+	 * @param cqpId
+	 *            the cqp id
+	 * 
+	 * @return true, if cqpId is a valid CQP ID.
+	 * 
+	 * @throws InvalidCqpIdException
+	 *             the invalid cqp id exception
+	 */
+	@Override
+	public boolean checkCqpId(String cqpId) throws InvalidCqpIdException {
+		if (!cqpId.equals(cqpId.toUpperCase()))
+			throw new InvalidCqpIdException(cqpId + TXMCoreMessages.MainCorpus_0);
+		return true;
+	}
+	
+	public boolean equals(MainCorpus corpus) {
+		if (corpus == null) return false;
+		return this.getQualifiedCqpId().equals(corpus.getQualifiedCqpId());
+	}
+
+	/**
+	 * Export.
+	 *
+	 * @param exportzip the exportzip
+	 * @return true, if successful
+	 */
+	@Override
+	public boolean export(File exportzip, ProgressWatcher monitor)
+	{
+		if (this.getBase() != null)
+			return this.getBase().export(exportzip, monitor);
+		return false;
+	}
+	
+	/**
+	 * Export.
+	 *
+	 * @param exportzip the exportzip
+	 * @return true, if successful
+	 */
+	@Override
+	public boolean export(File exportzip)
+	{
+		return export(exportzip, null);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.txm.searchengine.cqp.corpus.CqpObject#getQualifiedCqpId()
+	 */
+	@Override
+	public String getQualifiedCqpId() {
+		return cqpId;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.txm.searchengine.cqp.corpus.Corpus#getSize()
+	 */
+	@Override
+	public int getSize() throws CqiClientException {
+		if (this.size == -1) {
+			try {
+				this.size = CorpusManager.getCorpusManager().getCqiClient()
+						.attributeSize(this.cqpId + ".word"); //$NON-NLS-1$
+			} catch (Exception e) {
+				throw new CqiClientException(e);
+			}
+		}
+		return this.size;
+	}
+
+	/**
+	 * Gets the properties available in this corpus.
+	 * 
+	 * @return the properties
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	@Override
+	public List<Property> getProperties() throws CqiClientException {
+		if (this.lexicalUnitsProperties != null)
+			return this.lexicalUnitsProperties;
+		String[] propertiesName;
+		CorpusManager cm = null;
+		AbstractCqiClient cc = null;
+		try {
+			cm = CorpusManager.getCorpusManager();
+			cc = cm.getCqiClient();
+
+			// if (cc != null)
+			// System.out.println("cqiclient OK");
+
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+		try {
+			// System.out.println(this.cqpId); // temp : toLowerCAse
+			propertiesName = cc.corpusPositionalAttributes(this.cqpId);
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+		List<Property> properties = new ArrayList<Property>(
+				propertiesName.length);
+		for (int i = 0; i < propertiesName.length; i++)
+			properties.add(new Property(propertiesName[i], this));
+		this.lexicalUnitsProperties = properties;
+		return properties;
+	}
+
+	/**
+	 * Gets the structural attributes available in this corpus.
+	 * 
+	 * @return the properties
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	@Override
+	public List<StructuralUnit> getStructuralUnits() throws CqiClientException {
+		if (this.structuralUnits != null)
+			return this.structuralUnits;
+
+		// get structures' name
+		Set<String> cqpNames;
+		try {
+			String[] names = CorpusManager.getCorpusManager().getCqiClient()
+					.corpusStructuralAttributes(this.cqpId);
+			cqpNames = new HashSet<String>(Arrays.asList(names));
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+		// What we call a structural unit is called a structural attribute by
+		// cqp and what we call
+		// an attribute of a strucutural unit has no corresponding concept in
+		// cqp :
+		// if a structural unit, say 's', has 2 attributes, say 'n' and
+		// 'length', the 2 attributes
+		// are stored by cqp as embedded structural units names 's_n' and
+		// 's_length' (see the cqp documentation)
+		// Here, we go through all the structural attribute known by cqp to
+		// decide which is a structural unit and which
+		// an attribute of a structural unit
+
+		Map<String, List<String>> attributes = new HashMap<String, List<String>>();
+
+		for (String name : cqpNames) {
+			if (!attributes.containsKey(name)) {
+				int _ = name.lastIndexOf("_"); //$NON-NLS-1$
+				if (_ == -1 || !cqpNames.contains(name.substring(0, _))) {
+					attributes.put(name, new ArrayList<String>());
+				} else {
+					String unitName = name.substring(0, _);
+					String attributeName = name.substring(_ + 1);
+					if (!attributes.containsKey(unitName)) {
+						attributes.put(unitName, new ArrayList<String>());
+					}
+					attributes.get(unitName).add(attributeName);
+				}
+			}
+		}
+
+		this.structuralUnits = new ArrayList<StructuralUnit>();
+		for (String strucuralUnit : attributes.keySet())
+			this.structuralUnits.add(new StructuralUnit(strucuralUnit,
+					attributes.get(strucuralUnit), this));
+
+		return this.structuralUnits;
+	}
+
+	/**
+	 * Gets the full name.
+	 * 
+	 * @return the full name
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public String getFullName() throws CqiClientException {
+		try {
+			return CorpusManager.getCorpusManager().getCqiClient()
+					.corpusFullName(this.cqpId);
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.txm.searchengine.cqp.corpus.Corpus#getProperty(java.lang.
+	 * String)
+	 */
+	@Override
+	public Property getProperty(String name) throws CqiClientException {
+		if (this.lexicalUnitsProperties == null)
+			getProperties();
+		for (Property property : this.lexicalUnitsProperties)
+			if (property.getName().equals(name))
+				return property;
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.txm.searchengine.cqp.corpus.Corpus#getStructuralUnit(java
+	 * .lang.String)
+	 */
+	@Override
+	public StructuralUnit getStructuralUnit(String name)
+			throws CqiClientException {
+		if (this.structuralUnits == null)
+			getStructuralUnits();
+		for (StructuralUnit unit : this.structuralUnits)
+			if (unit.getName().equals(name))
+				return unit;
+		return null;
+	}
+
+
+
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		return name;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.searchengine.cqp.corpus.Corpus#load()
+	 */
+	@Override
+	public boolean load() {
+		boolean ret = super.load();
+		return ret;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.objects.TxmObject#getParent()
+	 */
+	@Override
+	public TxmObject getParent() {
+		return (TxmObject) this.parent;
+	}
+
+	/**
+	 * Sets the parent.
+	 *
+	 * @param base the new parent
+	 */
+	public void setParent(Base base) {
+		this.parent = base;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.objects.TxmObject#delete()
+	 */
+	@Override
+	public boolean delete() {
+		closeAnnotationManager();
+		removeFromCWB();
+		Base b = this.getBase();
+		b.delete();
+		return super.delete();
+	}
+
+	/**
+	 * Removes the from cwb.
+	 *
+	 * @return true, if successful
+	 */
+	public boolean removeFromCWB() {
+		try {
+			if (CQPEngine.isInitialized()) {
+				this.dropAllSubcorpora();
+				this.dropAllPartitions();
+			}
+		} catch (CqiClientException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+		CorpusManager.deleteCorpus(this);
+
+		// delete binaries
+		File binaries = this.getBaseDirectory();
+		System.out.println(TXMCoreMessages.MainCorpus_2+binaries);
+		return DeleteDir.deleteDirectory(binaries);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.searchengine.cqp.corpus.Corpus#getBase()
+	 */
+	@Override
+	public Base getBase() {
+		return (Base) getParent();
+	}
+
+
+
+	/** The nbtext. */
+	int nbtext = -1;
+
+	/**
+	 * Gets the nb texts.
+	 *
+	 * @return the nb texts
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public int getNbTexts() throws CqiClientException
+	{
+		if (nbtext == -1) {
+			StructuralUnit text_su = this.getStructuralUnit("text"); //$NON-NLS-1$
+			StructuralUnitProperty text_id_sup = text_su.getProperty("id"); //$NON-NLS-1$
+
+			List<String> textids = text_id_sup.getValues();
+			nbtext = textids.size();
+		}
+		return nbtext;
+	}
+
+	/** The textids. */
+	HashMap<String, Integer> textids = null;
+	private int[] textEndLimits;
+
+	/**
+	 * Gets the texts ids.
+	 *
+	 * @return the texts ids
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public HashMap<String, Integer>  getTextsIds() throws IOException, CqiServerError, CqiClientException
+	{
+		if (textids == null)
+		{
+			textids = new HashMap<String, Integer>();
+			int nbtext = getNbTexts();
+			int[] structs = new int[nbtext];
+			for(int i = 0 ; i < nbtext ; i++)
+				structs[i] = i;
+
+			StructuralUnit text_su = this.getStructuralUnit("text"); //$NON-NLS-1$
+			StructuralUnitProperty text_id_sup = text_su.getProperty("id"); //$NON-NLS-1$
+
+			String[] ids = CorpusManager.getCorpusManager().getCqiClient().struc2Str(text_id_sup.getQualifiedName(), structs);
+			for(int i = 0 ; i < ids.length ; i++)
+			{
+				textids.put(ids[i], structs[i]);
+			}
+		}
+		return textids;
+	}
+
+	/**
+	 * Find text no.
+	 *
+	 * @param textid the textid
+	 * @return the int
+	 * @throws CqiClientException the cqi client exception
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	public int findTextNo(String textid) throws CqiClientException, IOException, CqiServerError
+	{
+		HashMap<String, Integer> idsmap = this.getTextsIds();
+		if (idsmap.containsKey(textid))
+			return idsmap.get(textid);
+		else
+			return -1;
+	}
+
+	/**
+	 * Gets the first position.
+	 *
+	 * @return the first position
+	 */
+	public int getFirstPosition() {
+		return 0;
+	}
+
+	/**
+	 * Return the CQP END positions of the main corpus texts
+	 */
+	@Override
+	public int[] getTextEndLimits() throws CqiClientException, IOException, CqiServerError, InvalidCqpIdException {
+		if (textEndLimits == null) {
+			String queryResultId = queryResultNamePrefix
+					+ UUID.randomUUID().toString();
+			CorpusManager.getCorpusManager().getCqiClient().cqpQuery(
+					this.getQualifiedCqpId(), queryResultId, "<text>[] expand to text"); //$NON-NLS-1$
+			QueryResult queryResult = new QueryResult(queryResultId, queryResultId, this,	new Query("<text>[] expand to text")); //$NON-NLS-1$
+			textEndLimits = queryResult.getEnds();
+		}
+		return textEndLimits;
+	}
+	
+	/**
+	 * Return the CQP START positions of the main corpus texts
+	 */
+	@Override
+	public int[] getTextStartLimits() throws CqiClientException, IOException, CqiServerError, InvalidCqpIdException {
+		if (textLimits == null) {
+			textLimits = getStartLimits("<text>[]");
+		}
+		return textLimits;
+	}
+	
+	/**
+	 * Return the CQP START positions of the result matches of the 'cql_limit' query 
+	 */
+	@Override
+	public int[] getStartLimits(String cql_limit) throws IOException, CqiServerError, InvalidCqpIdException, CqiClientException {
+		String queryResultId = queryResultNamePrefix + UUID.randomUUID().toString();
+		CorpusManager.getCorpusManager().getCqiClient().cqpQuery(
+				this.getQualifiedCqpId(), queryResultId, cql_limit); //$NON-NLS-1$
+		QueryResult queryResult = new QueryResult(queryResultId, queryResultId, this,	new Query(cql_limit));
+		
+		int[] rez =  queryResult.getStarts();
+		queryResult.drop();
+		return rez;
+	}
+
+	@Override
+	public List<Match> getMatches() {
+		List<Match> rez = new ArrayList<Match>();
+		try {
+			rez.add(new Match(0, this.getSize()));
+			return rez;
+		} catch (CqiClientException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+		return null;
+	}
+
+	public int getNMatch() {
+		return 1;
+	}
+
+
+	
+	public AnnotationManager getAnnotationManager() {
+		//return null;
+		if (am == null) {
+			if (this.getKnowledgeRepositoryNames().size() > 0)
+			am = new AnnotationManager(this);
+		}
+		return am;
+	}
+	
+	protected boolean modified = false;
+	public boolean isModified() { return modified; }
+	public void setIsModified(boolean b) { modified = b; }
+	public String getNameForCorporaView() {	
+		if (modified)
+			return getName()+"*";
+		else
+			return getName();
+	}
+	
+	public boolean needToSaveAnnotations() {
+		if (getAnnotationManager() != null)
+			return am.hasChanges();
+		else
+			return false;
+	}
+
+	public boolean canBeAnnotated() {
+		return getKnowledgeRepositoryNames().size() > 0;
+	}
+
+	/**
+	 * 
+	 * Lazy load KR
+	 * 
+	 * @param name KnowledgeRepository's name
+	 * @return may return null if the KnowledgeRepository does not exist
+	 */
+	public KnowledgeRepository getKnowledgeRepository(String name) {
+		return KnowledgeRepositoryManager.getKnowledgeRepository(name, this);
+		
+//		if (kr != null) return kr; // \o/
+//		
+//		BaseParameters params = this.getBase().getBaseParameters();
+//		HashMap<String, HashMap<String, ?>> conf = params.getKnowledgeRepository(name);
+//		
+//		if (conf == null) return null;
+//
+//		return KnowledgeRepositoryManager.createKnowledgeRepository(name, conf);
+	}
+
+	/**
+	 * 
+	 * @param name KnowledgeRepository's name
+	 * @return may return null if the KnowledgeRepository does not exist
+	 */
+	public List<String> getKnowledgeRepositoryNames() {
+		BaseParameters params = this.getBase().getBaseParameters();
+		return params.getKnowledgeRepositoryNames();
+	}
+
+	public void closeAnnotationManager() {
+		if (am != null) {
+			//System.out.println("  Closing AM...");
+			am.closeAll();
+		}
+	}
+
+
+	@Override
+	public String getDetails() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public void clean() {
+		// TODO Auto-generated method stub
+		
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Alignement.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Alignement.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Alignement.java	(revision 449)
@@ -0,0 +1,273 @@
+package org.txm.searchengine.cqp.corpus;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+import org.txm.Toolbox;
+import org.txm.objects.Edition;
+import org.txm.objects.Page;
+import org.txm.searchengine.cqp.CQPEngine;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException;
+import org.txm.searchengine.cqp.corpus.query.Match;
+import org.txm.searchengine.cqp.corpus.query.Query;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
+
+public class Alignement {
+	protected String from;
+	protected String to;
+	protected String struct;
+	protected int level;
+
+	public Alignement(String from , String to, String struct, int level)
+	{
+		this.from = from;
+		this.to = to;
+		this.struct = struct;
+		this.level = level;
+		if(level > 1)
+			this.struct = this.struct + level;
+	}
+
+	public Alignement(String from , String to)
+	{
+		this(from, to, "w", 1);
+	}
+
+	public Alignement(String from, String to, String struct)
+	{
+		this(from, to, struct, 1);
+	}
+
+	/**
+	 * 
+	 * @param wordid
+	 * @param txtid
+	 * @return the word id and text id of the [to] corpus.
+	 * @throws CqiClientException
+	 * @throws InvalidCqpIdException
+	 * @throws IOException
+	 * @throws CqiServerError
+	 */
+	public List<String> resolve(String wordid, String textid) throws CqiClientException, InvalidCqpIdException, IOException, CqiServerError
+	{
+		System.out.println("resolve "+wordid+" "+textid+" "+struct);
+		Corpus src = CorpusManager.getCorpusManager().getCorpus(from);
+		StructuralUnitProperty align_src = src.getStructuralUnit(struct).getProperty("align");
+		
+		Corpus dest = CorpusManager.getCorpusManager().getCorpus(to);
+		Property id_dest = dest.getProperty("id");
+		StructuralUnitProperty text_dest = dest.getStructuralUnit("text").getProperty("id");
+
+		if (struct.equals("w"))
+		{
+			QueryResult rez = src.query(new Query("[_.text_id=\""+textid+"\" & id=\""+wordid+"\"]"), "Align", false);
+			int[] position = {rez.getMatch(0).getStart()};
+			int[] struct_align_pos = CQPEngine.getCqiClient().cpos2Struc(align_src.getQualifiedName(), position);
+			String[] struct_align_str = CQPEngine.getCqiClient().struc2Str(align_src.getQualifiedName(), struct_align_pos);
+			if(struct_align_str.length > 0)
+			{
+				String aligned_struct = struct_align_str[0]; // the struct align value
+				// get the position of the first token of this struct
+				QueryResult rez2 = dest.query(new Query("<"+struct+"_align=\""+aligned_struct+"\">[]"), "Align", false);
+				int[] position2 = {rez2.getMatch(0).getStart()};
+				// get the id of this position
+				int[] struct_text_pos = CQPEngine.getCqiClient().cpos2Struc(text_dest.getQualifiedName(), position2);
+				String[] struct_text_str = CQPEngine.getCqiClient().struc2Str(text_dest.getQualifiedName(), struct_text_pos);
+				return Arrays.asList(wordid, struct_text_str[0]);
+			}
+			else
+			{
+				return null;
+			}
+		}
+		else
+		{
+			//get the position for the word id and the text
+			String query = "[_.text_id=\""+textid+"\" & id=\""+wordid+"\"]";
+			//System.out.println("query: "+query);
+			QueryResult rez = src.query(new Query(query), "Align", false);
+			//System.out.println(rez.getMatches());
+			int[] position = {rez.getMatch(0).getStart()};
+			//get the struct@align value for this position
+			int[] struct_align_pos = CQPEngine.getCqiClient().cpos2Struc(align_src.getQualifiedName(), position);
+			String[] struct_align_str = CQPEngine.getCqiClient().struc2Str(align_src.getQualifiedName(), struct_align_pos);
+			if(struct_align_str.length > 0)
+			{
+				String aligned_struct = struct_align_str[0]; // the struct align value
+				// get the position of the first token of this struct
+				query = "<"+struct+"_align=\""+aligned_struct+"\">[]";
+				QueryResult rez2 = dest.query(new Query(query), "Align", false);
+				int[] position2 = {rez2.getMatch(0).getStart()};
+				// get the id of this position
+				String[] ids = CQPEngine.getCqiClient().cpos2Str(id_dest.getQualifiedName(), position2);
+
+				if(ids.length > 0)
+				{
+					int[] struct_text_pos = CQPEngine.getCqiClient().cpos2Struc(text_dest.getQualifiedName(), position2);
+					String[] struct_text_str = CQPEngine.getCqiClient().struc2Str(text_dest.getQualifiedName(), struct_text_pos);
+					return Arrays.asList(ids[0], struct_text_str[0]);
+				}
+				else
+					return null;
+			}
+			else
+			{
+				return null;
+			}
+		}
+	}
+
+	public List<String> resolve(Page p) throws CqiClientException, InvalidCqpIdException, IOException, CqiServerError
+	{	
+		System.out.println("resolve "+p);
+		return resolve(p.getWordId(), p.getEdition().getText().getName());
+	}
+	
+	public List<String> resolve(Match match) throws IOException, CqiServerError, CqiClientException, InvalidCqpIdException
+	{
+		return resolve(match.getStart());
+	} 
+	
+	/**
+	 * resolve alignemnt by a position:
+	 * 1) get seg
+	 * 2) resolve seg
+	 * @param idx
+	 * @return
+	 * @throws IOException
+	 * @throws CqiServerError
+	 * @throws CqiClientException
+	 * @throws InvalidCqpIdException
+	 */
+	public List<String> resolve(int idx) throws IOException, CqiServerError, CqiClientException, InvalidCqpIdException
+	{
+		Corpus src = CorpusManager.getCorpusManager().getCorpus(from);
+		StructuralUnitProperty align_src = src.getStructuralUnit(struct).getProperty("align");
+		int[] position = {idx};
+		int[] struct_align_pos = CQPEngine.getCqiClient().cpos2Struc(align_src.getQualifiedName(), position);
+		String[] struct_align_str = CQPEngine.getCqiClient().struc2Str(align_src.getQualifiedName(), struct_align_pos);
+		if (struct_align_str.length > 0) {
+			return resolveSeg(struct_align_str[0]);
+		}
+		return null;
+	}
+
+
+	public List<String> resolveSeg(String seg_id) throws IOException, CqiServerError, CqiClientException, InvalidCqpIdException
+	{
+		System.out.println("resolve seg "+seg_id);
+		Corpus dest = CorpusManager.getCorpusManager().getCorpus(to);
+		String query = "<"+struct+"_align=\""+seg_id+"\">[]";
+		//System.out.println("query: "+query);
+		QueryResult rez = dest.query(new Query(query), "Align", false);
+		//System.out.println("rez: "+rez.getMatches());
+		int[] position = {rez.getMatch(0).getStart()};
+
+		Property id_dest = dest.getProperty("id");
+		String[] ids = CQPEngine.getCqiClient().cpos2Str(id_dest.getQualifiedName(), position);
+		String wordid = ids[0];
+
+		StructuralUnitProperty text_dest = dest.getStructuralUnit("text").getProperty("id");
+		int[] struct_text_pos = CQPEngine.getCqiClient().cpos2Struc(text_dest.getQualifiedName(), position);
+		String[] struct_text_str = CQPEngine.getCqiClient().struc2Str(text_dest.getQualifiedName(), struct_text_pos);
+		String textid = struct_text_str[0];
+		
+		return Arrays.asList(wordid, textid);
+	}
+
+	public Page getPage(String edition, String wordid, String txtid) throws CqiClientException, InvalidCqpIdException
+	{
+		System.out.println("get edition: from "+to+" : "+edition+" "+wordid+" "+txtid);
+		Corpus dest = CorpusManager.getCorpusManager().getCorpus(to);
+		Edition ed = dest.getText(txtid).getEdition(edition);
+		if(ed == null)
+			ed = dest.getText(txtid).getEdition("default");
+		
+		return ed.getPageForWordId(wordid);
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((from == null) ? 0 : from.hashCode());
+		result = prime * result + level;
+		result = prime * result + ((struct == null) ? 0 : struct.hashCode());
+		result = prime * result + ((to == null) ? 0 : to.hashCode());
+		return result;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		Alignement other = (Alignement) obj;
+		if (from == null) {
+			if (other.from != null)
+				return false;
+		} else if (!from.equals(other.from))
+			return false;
+		if (level != other.level)
+			return false;
+		if (struct == null) {
+			if (other.struct != null)
+				return false;
+		} else if (!struct.equals(other.struct))
+			return false;
+		if (to == null) {
+			if (other.to != null)
+				return false;
+		} else if (!to.equals(other.to))
+			return false;
+		return true;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		return "Alignement [from=" + from + ", to=" + to + ", struct=" + struct
+				+ ", level=" + level + "]";
+	}
+
+	/**
+	 * @return the from
+	 */
+	public String getFrom() {
+		return from;
+	}
+
+	/**
+	 * @return the to
+	 */
+	public String getTo() {
+		return to;
+	}
+
+	/**
+	 * @return the struct
+	 */
+	public String getStruct() {
+		return struct;
+	}
+
+	/**
+	 * @return the level
+	 */
+	public int getLevel() {
+		return level;
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Property.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Property.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Property.java	(revision 449)
@@ -0,0 +1,115 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus;
+
+// TODO: Auto-generated Javadoc
+/**
+ * A Property on the lexical units the corpus. Represents a
+ * <strong>type</strong>, not a the value for a specif ic unit.
+ * 
+ * @author Jean-Philippe Magué
+ */
+public class Property implements Comparable{
+
+	/** The name. */
+	private String name;
+
+	/** The corpus. */
+	private Corpus corpus;
+
+	/**
+	 * Instantiates a new property.
+	 * 
+	 * Not intended to be used directly. See {@link Corpus#getProperty(String)}
+	 * 
+	 * @param name
+	 *            the name
+	 * @param corpus
+	 *            the corpus
+	 */
+	protected Property(String name, Corpus corpus) {
+		this.name = name;
+		this.corpus = corpus;
+	}
+
+	/**
+	 * Gets the qualified name.
+	 * 
+	 * @return the qualified name
+	 */
+	public String getQualifiedName() {
+		return corpus.getCqpId() + "." + this.getName(); //$NON-NLS-1$
+	}
+
+	/**
+	 * Gets the name.
+	 * 
+	 * @return the name
+	 */
+	public String getName() {
+		return name;
+	}
+
+	/**
+	 * Gets the corpus over which the property is defined.
+	 * 
+	 * @return the name
+	 */
+	public Corpus getCorpus() {
+		return corpus;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		return name;
+	}
+
+	/**
+	 * Equals.
+	 *
+	 * @param p the p
+	 * @return true, if successful
+	 */
+	public boolean equals(Property p) {
+		return name.equals(p.getQualifiedName())
+				&& corpus.equals(p.getQualifiedName());
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Comparable#compareTo(java.lang.Object)
+	 */
+	@Override
+	public int compareTo(Object arg0) {
+		if (arg0 instanceof Property)
+			return this.name.compareTo(((Property)arg0).name);
+		return 0;
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/QueryResult.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/QueryResult.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/QueryResult.java	(revision 449)
@@ -0,0 +1,385 @@
+// 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: 2016-03-01 10:10:58 +0100 (Tue, 01 Mar 2016) $
+// $LastChangedRevision: 3133 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.searchengine.cqp.AbstractCqiClient;
+import org.txm.searchengine.cqp.NetCqiClient;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException;
+import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
+import org.txm.searchengine.cqp.corpus.query.Match;
+import org.txm.searchengine.cqp.corpus.query.Query;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The result of a CQP query on a corpus.
+ * 
+ * @author jmague
+ */
+public class QueryResult implements CqpObject {
+
+	/** The cqp id. */
+	protected String cqpId;
+
+	/** The name. */
+	protected String name;
+
+	/** The size. */
+	protected int size = -1;
+	int[] starts;
+	int[] ends;
+	int[] targets;
+
+	/** The mother main corpus. */
+	protected MainCorpus motherMainCorpus;
+
+	/* (non-Javadoc)
+	 * @see org.txm.searchengine.cqp.corpus.CqpObject#getCqpId()
+	 */
+	@Override
+	public String getCqpId() {
+		return cqpId;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.searchengine.cqp.corpus.CqpObject#getName()
+	 */
+	@Override
+	public String getName() {
+		return name;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.searchengine.cqp.corpus.CqpObject#getMotherMainCorpus()
+	 */
+	@Override
+	public MainCorpus getMainCorpus() {
+		return motherMainCorpus;
+	}
+
+	/** The queried corpus. */
+	private Corpus queriedCorpus;
+
+	/** The n match. */
+	private int nMatch = -1;
+
+	/** The query. */
+	private Query query;
+
+	/**
+	 * Instantiates a new query result.
+	 * 
+	 * Not intended to be used directly. See {@link Corpus#query(Query, String)}
+	 * 
+	 * @param cqpId
+	 *            the cqp id
+	 * @param name
+	 *            the name
+	 * @param queriedCorpus
+	 *            the queried corpus
+	 * @param query
+	 *            the query
+	 * 
+	 * @throws InvalidCqpIdException
+	 *             the invalid cqp id exception
+	 */
+	public QueryResult(String cqpId, String name, Corpus queriedCorpus,
+			Query query) throws InvalidCqpIdException {
+		// super(cqpId);
+		checkCqpId(cqpId);
+		this.cqpId = cqpId;
+		this.name = name;
+		this.queriedCorpus = queriedCorpus;
+		if (queriedCorpus instanceof Subcorpus) {
+			this.motherMainCorpus = ((Subcorpus) queriedCorpus)
+					.getMainCorpus();
+		} else {
+			this.motherMainCorpus = ((MainCorpus) queriedCorpus);
+		}
+		this.query = query;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.txm.searchengine.cqp.corpus.CqpObject#checkCqpId(java.lang
+	 * .String)
+	 */
+	@Override
+	public boolean checkCqpId(String cqpId) throws InvalidCqpIdException {
+		if (!AbstractCqiClient.checkSubcorpusId(cqpId))
+			throw new InvalidCqpIdException(cqpId + TXMCoreMessages.QueryResult_0);
+		return true;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.txm.searchengine.cqp.corpus.CqpObject#getQualifiedCqpId()
+	 */
+	@Override
+	public String getQualifiedCqpId() {
+		return motherMainCorpus.getCqpId() + ":" + this.cqpId; //$NON-NLS-1$
+	}
+
+	/**
+	 * Gets the queried corpus.
+	 * 
+	 * @return the queried corpus
+	 */
+	public Corpus getQueriedCorpus() {
+		return queriedCorpus;
+	}
+
+	/**
+	 * Gets the number of matches.
+	 * 
+	 * @return the number of matches
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public int getNMatch() throws CqiClientException {
+		//if (nMatch == -1) //
+			try {
+				nMatch = CorpusManager.getCorpusManager().getCqiClient()
+						.subCorpusSize(getQualifiedCqpId());
+			} catch (Exception e) {
+				return 0;
+			}
+		return nMatch;
+	}
+
+	/**
+	 * Retrieves some of the matches of a query
+	 * 
+	 * Not all the matches are returned, but only those between from and to. For
+	 * example, getMatches(0,9) returns the first 10 matches while
+	 * getMatches(0,getNMatches()) return them all.
+	 * 
+	 * @param from
+	 *            the from
+	 * @param to
+	 *            the to
+	 * 
+	 * @return the matches
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	/**
+	 * @return
+	 * @throws CqiClientException
+	 */
+	public int[] getStartMatches(int from, int to) throws CqiClientException {
+		int n = this.getNMatch();
+		if (to > n) to = n;
+		try {
+			return CorpusManager.getCorpusManager().getCqiClient()
+					.dumpSubCorpus(getQualifiedCqpId(),
+							NetCqiClient.CQI_CONST_FIELD_MATCH, from, to);
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+	}
+
+	/**
+	 * Retrieves some of the matches of a query
+	 * 
+	 * Not all the matches are returned, but only those between from and to. For
+	 * example, getMatches(0,9) returns the first 10 matches while
+	 * getMatches(0,getNMatches()) return them all.
+	 * 
+	 * @param from
+	 *            the from
+	 * @param to
+	 *            the to
+	 * 
+	 * @return the matches
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	/**
+	 * @return
+	 * @throws CqiClientException
+	 */
+	public List<Match> getMatches(int from, int to) throws CqiClientException {
+		int[] starts, ends;
+		List<Match> res = new ArrayList<Match>();
+		try {
+			starts = getStarts(from, to);
+			ends = CorpusManager.getCorpusManager().getCqiClient()
+					.dumpSubCorpus(getQualifiedCqpId(),
+							NetCqiClient.CQI_CONST_FIELD_MATCHEND, from, to);
+			targets = CorpusManager.getCorpusManager().getCqiClient()
+					.dumpSubCorpus(getQualifiedCqpId(),
+							NetCqiClient.CQI_CONST_FIELD_TARGET, from, to);
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+		for (int i = 0; i <= to - from; i++) {
+			res.add(new Match(starts[i], ends[i], targets[i]));
+		}
+		return res;
+	}
+	
+	
+
+	public int[] getEnds(int from, int to) throws UnexpectedAnswerException, IOException, CqiServerError
+	{
+		return CorpusManager.getCorpusManager().getCqiClient()
+					.dumpSubCorpus(getQualifiedCqpId(),
+							NetCqiClient.CQI_CONST_FIELD_MATCHEND, from, to);
+	}
+
+	public int[] getEnds() throws CqiClientException, IOException, CqiServerError {
+		int n = this.getNMatch();
+		if( n > 0)
+			return getEnds(0, n - 1);
+		else return new int[0];
+	}
+	
+	public int[] getStarts(int from, int to) throws UnexpectedAnswerException, IOException, CqiServerError
+	{
+		return CorpusManager.getCorpusManager().getCqiClient()
+					.dumpSubCorpus(getQualifiedCqpId(),
+							NetCqiClient.CQI_CONST_FIELD_MATCH, from, to);
+	}
+
+	public int[] getStarts() throws CqiClientException, IOException, CqiServerError {
+		int n = this.getNMatch();
+		if (n > 0)
+			return getStarts(0, n - 1);
+		else return new int[0];
+	}
+
+	/**
+	 * Gets all the matches.
+	 * 
+	 * WARNING: on win32 OS, this function may takes a long time if called with sockets
+	 * 
+	 * @return the matches
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public List<Match> getMatches() throws CqiClientException {
+		int n = this.getNMatch();
+		if( n > 0)
+			return getMatches(0, n - 1);
+		else return new ArrayList<Match>();
+	}
+
+	//	/**
+	//	 * Gets all the matches.
+	//	 * WARNING: on win32 OS, this function may takesQUETE a long time
+	//	 * 
+	//	 * @return the matches
+	//	 * 
+	//	 * @throws CqiClientException
+	//	 *             the cqi client exception
+	//	 */
+	//	public List<Match> getRandomMatches(float perc) throws CqiClientException {
+	//		
+	//		ArrayList<Match> allmatches = new ArrayList<Match>(getMatches(0, getNMatch() - 1));
+	//		ArrayList<Match> sub = new ArrayList<Match>();
+	//		int count = 0;
+	//		for(Match m : allmatches)
+	//		{
+	//			if(count >= size)
+	//				return sub;
+	//			count++;
+	//			if(Math.random() > perc)
+	//				sub.add(m);
+	//		}
+	//		return sub;
+	//	}
+
+	/**
+	 * Drops the query results. More specifically, it drops its CQP counterpart.
+	 * 
+	 * This method has to be called when a query result is no longer usefull.
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public void drop() throws CqiClientException {
+		try {
+			CorpusManager.getCorpusManager().getCqiClient().dropSubCorpus(this.getQualifiedCqpId());
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+	}
+	
+	@Override
+	public void finalize() {
+//		try { drop(); }
+//		catch(Exception e) { }
+	}
+
+	/**
+	 * Gets the query.
+	 * 
+	 * @return the query
+	 */
+	public Query getQuery() {
+		return query;
+	}
+
+	/**
+	 * get the Nth match
+	 * 
+	 * @param i
+	 * @return
+	 * @throws UnexpectedAnswerException
+	 * @throws IOException
+	 * @throws CqiServerError
+	 */
+	public Match getMatch(int i) throws UnexpectedAnswerException, IOException, CqiServerError {
+		int[] starts = CorpusManager.getCorpusManager().getCqiClient()
+				.dumpSubCorpus(getQualifiedCqpId(),
+						NetCqiClient.CQI_CONST_FIELD_MATCH, i, i);
+		int[] ends = CorpusManager.getCorpusManager().getCqiClient()
+				.dumpSubCorpus(getQualifiedCqpId(),
+						NetCqiClient.CQI_CONST_FIELD_MATCHEND, i, i);
+		return new Match(starts[i], ends[i]);
+	}
+	
+	public String toString() {
+		return this.getQualifiedCqpId();
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Subcorpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Subcorpus.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Subcorpus.java	(revision 449)
@@ -0,0 +1,551 @@
+// 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-12-01 16:28:17 +0100 (Tue, 01 Dec 2015) $
+// $LastChangedRevision: 3073 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.osgi.util.NLS;
+import org.txm.annotation.AnnotationManager;
+import org.txm.annotation.repository.KnowledgeRepository;
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.functions.selection.SelectionResult;
+import org.txm.objects.Base;
+import org.txm.objects.TxmObject;
+import org.txm.searchengine.cqp.AbstractCqiClient;
+import org.txm.searchengine.cqp.ICqiClient;
+import org.txm.searchengine.cqp.NetCqiClient;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException;
+import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
+import org.txm.searchengine.cqp.corpus.query.Match;
+import org.txm.searchengine.cqp.corpus.query.Query;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
+import org.txm.utils.logger.Log;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class Subcorpus.
+ * 
+ * @author jmague
+ */
+public class Subcorpus extends Corpus {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/** The mother subcorpus. */
+	protected Subcorpus motherSubcorpus;
+
+	/** The query. */
+	protected Query query;
+
+	private SelectionResult selectionResult;
+	protected QueryResult qresult;
+
+	
+	
+	/**
+	 * Instantiates a new subcorpus and add it as child result of the specified parent corpus.
+	 * @param cqpId
+	 * @param name
+	 * @param parent
+	 * @param query
+	 * @throws InvalidCqpIdException
+	 */
+	protected Subcorpus(String cqpId, String name, Corpus parent, Query query) throws InvalidCqpIdException {
+		this(cqpId, name, parent, query, true);
+	}
+	
+	/**
+	 * Instantiates a new subcorpus.
+	 * 
+	 * Not intended to be used directly.
+	 *
+	 * @param cqpId the cqp id
+	 * @param name the name
+	 * @param parent the parent
+	 * @param query the query
+	 * @throws InvalidCqpIdException the invalid cqp id exception
+	 * {@link Corpus#createSubcorpus(Query, String)}
+	 */
+	protected Subcorpus(String cqpId, String name, Corpus parent, Query query, boolean addToParent) throws InvalidCqpIdException {
+		super(cqpId);
+		
+		// FIXME: to validate
+		if(addToParent)	{
+			parent.addResult(this);
+		}
+		
+		this.query = query;
+		this.name = name;
+		if (parent instanceof Subcorpus) {
+			this.motherMainCorpus = ((Subcorpus) parent).motherMainCorpus;
+			this.motherSubcorpus = ((Subcorpus) parent);
+		} else {
+			this.motherMainCorpus = ((MainCorpus) parent);
+			this.motherSubcorpus = null;
+		}
+
+		this.qresult = new QueryResult(this.cqpId, this.name, parent, query);
+	}
+
+	/**
+	 * Gets the mother subcorpus.
+	 * 
+	 * @return the mother subcorpus
+	 */
+	public Subcorpus getMotherSubcorpus() {
+		return motherSubcorpus;
+	}
+
+	/**
+	 * Returns the number of occurrences in the subcorpus.
+	 * 
+	 * @return the size
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 * 
+	 * @see org.txm.searchengine.cqp.corpus.Corpus#getSize()
+	 */
+	@Override
+	public int getSize() throws CqiClientException {
+		Log.finest(TXMCoreMessages.bind(TXMCoreMessages.SUBCORPUS_SIZE, new Object[]{this.name, "N/A"}));
+		long start = System.currentTimeMillis();
+		if (this.size == -1) {
+			try {
+				AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient();
+				int nMatch = cqiClient.subCorpusSize(getQualifiedCqpId());
+				//System.out.println("n matchs: "+nMatch);
+				if (nMatch == 0) {
+					this.size = 0;
+				} else {
+					int[] match = cqiClient.dumpSubCorpus(getQualifiedCqpId(),
+							NetCqiClient.CQI_CONST_FIELD_MATCH, 0, nMatch - 1);
+					int[] matchend = cqiClient.dumpSubCorpus(getQualifiedCqpId(),
+							NetCqiClient.CQI_CONST_FIELD_MATCHEND, 0, nMatch - 1);
+					if (match.length != matchend.length)
+						throw new UnexpectedAnswerException();
+					this.size = 0;
+					
+					for (int i = 0; i < match.length; i++)
+						size += matchend[i] - match[i] + 1;
+				}
+			} catch (Exception e) {
+				throw new CqiClientException(e);
+			}
+		}
+		long end = System.currentTimeMillis();
+		Log.finest(NLS.bind(TXMCoreMessages.END_SUBCORPUS_SIZE, new Object[]{this.name, this.size, (end - start)})); //$NON-NLS-1$
+		return this.size;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.txm.searchengine.cqp.corpus.CqpObject#getQualifiedCqpId()
+	 */
+	@Override
+	public String getQualifiedCqpId() {
+		return motherMainCorpus.getCqpId() + ":" + this.cqpId; //$NON-NLS-1$
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.txm.searchengine.cqp.corpus.Corpus#getProperties()
+	 */
+	@Override
+	public List<Property> getProperties() throws CqiClientException {
+		return motherMainCorpus.getProperties();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.txm.searchengine.cqp.corpus.Corpus#getProperty(java.lang.
+	 * String)
+	 */
+	@Override
+	public Property getProperty(String name) throws CqiClientException {
+		return motherMainCorpus.getProperty(name);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.txm.searchengine.cqp.corpus.Corpus#getStructuralUnits()
+	 */
+	@Override
+	public List<StructuralUnit> getStructuralUnits() throws CqiClientException {
+		if (getParent() instanceof MainCorpus) {
+			this.structuralUnits = ((MainCorpus)getParent()).getStructuralUnits();
+		} else if (getParent() instanceof Subcorpus)
+			this.structuralUnits = ((Subcorpus)getParent()).getStructuralUnits();
+		else
+			return null;
+		return this.structuralUnits;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.txm.searchengine.cqp.corpus.Corpus#getStructuralUnit(java
+	 * .lang.String)
+	 */
+	@Override
+	public StructuralUnit getStructuralUnit(String name)
+			throws CqiClientException {
+		return motherMainCorpus.getStructuralUnit(name);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.txm.searchengine.cqp.corpus.CqpObject#checkCqpId(java.lang
+	 * .String)
+	 */
+	@Override
+	public boolean checkCqpId(String cqpId) throws InvalidCqpIdException {
+		if (!AbstractCqiClient.checkSubcorpusId(cqpId))
+			throw new InvalidCqpIdException(cqpId + TXMCoreMessages.Subcorpus_3);
+		return true;
+	}
+
+	// protected void finalize() throws Throwable {
+	// try {
+	// //
+	// CorpusManager.getCorpusManager().getCqiClient().dropSubCorpus(this.getQualifiedCqpId());
+	// //As finalize is run in a separate thread, we have problems of concurrent
+	// accesses to the cqi server if we drop the subcorpus here.
+	// //It as to be done manually
+	// } catch (Exception e) {
+	// Log.finest("Subcorpus failed to finalize", e);
+	// }
+	// finally {
+	// super.finalize();
+	// }
+	// }
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.txm.searchengine.cqp.corpus.Corpus#getLocale()
+	 */
+	@Override
+	public boolean load() {
+		if (getSelfElement() != null) {
+			this.query = new Query(getSelfElement().getAttribute("query")); //$NON-NLS-1$
+
+			NodeList subcorpusElems = getSelfElement().getElementsByTagName("subcorpus"); //$NON-NLS-1$
+			for (int i = 0 ; i < subcorpusElems.getLength() ; i++) {
+				Element subcorpusElem = (Element) subcorpusElems.item(i);
+				try {
+					Subcorpus subcorp = this.createSubcorpus(subcorpusElem);
+					subcorp.setSelfElement(subcorpusElem);
+					subcorp.load();
+				} catch (CqiClientException e) {
+					Log.warning(this.name + TXMCoreMessages.Corpus_12 + name
+							+ " : " + e); //$NON-NLS-1$
+				}
+			}
+
+			NodeList partitionElems = getSelfElement().getElementsByTagName("partition"); //$NON-NLS-1$
+			for (int i = 0 ; i < partitionElems.getLength() ; i++) {
+				Element partitionElem = (Element) partitionElems.item(i);
+				String name = partitionElem.getAttribute("name"); //$NON-NLS-1$
+				List<String> names = new ArrayList<String>();
+				List<String> queries = new ArrayList<String>();
+
+				NodeList partElems = partitionElem.getElementsByTagName("part"); //$NON-NLS-1$
+				for (int j = 0; j < partElems.getLength(); j++) {
+					Element part = (Element) partElems.item(j);
+					names.add(part.getAttribute("name")); //$NON-NLS-1$
+					queries.add(part.getAttribute("query")); //$NON-NLS-1$
+				}
+				try {
+					//System.out.println("Create Partition with corpus "+this+" : "+name+", queries "+queries+", names "+names);
+					Partition partition = this.createPartition(name, queries, names, true);
+					partition.load(partitionElem);
+				} catch (CqiClientException e) {
+					Log.warning(this.name + TXMCoreMessages.Corpus_19 + name
+							+ " : " + e); //$NON-NLS-1$
+					//c.getParentNode().removeChild(c);
+				}
+			}
+		}
+		initSelectionResult();
+		//System.out.println("Subcorpus.load: Selection of "+this+" = "+selectionResult);
+		//return super.load();
+		return true;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.objects.TxmObject#getParent()
+	 */
+	@Override
+	public TxmObject getParent() {
+		if (this.motherSubcorpus != null)
+			return this.motherSubcorpus;
+		else
+			return this.motherMainCorpus;
+	}
+
+	/**
+	 * Register to parent.
+	 *
+	 * @param subcorpusName the subcorpus name
+	 * @param query the query
+	 */
+	private void registerToParent(String subcorpusName, Query query) {
+		if (this.getSelfElement() == null && this.getParent() != null)
+			try {
+				Element parentElem = (Element) this.getParent().getSelfElement();
+				if (parentElem == null) return;
+				Document doc = parentElem.getOwnerDocument();
+				Element subcorpusElem = doc.createElement("subcorpus"); //$NON-NLS-1$
+				subcorpusElem.setAttribute("name", subcorpusName); //$NON-NLS-1$
+				subcorpusElem.setAttribute("desc", subcorpusName); //$NON-NLS-1$
+				if (query != null)
+					subcorpusElem.setAttribute("query", query.getQueryString()); //$NON-NLS-1$
+				Element corporaElem;
+				if (this.getParent() instanceof MainCorpus) {
+					NodeList corporaList = parentElem.getElementsByTagName("preBuild"); //$NON-NLS-1$
+					corporaElem = (Element) corporaList.item(0);
+				} else {
+					corporaElem = parentElem;
+				}
+				corporaElem.appendChild(subcorpusElem);
+				this.setSelfElement(subcorpusElem);
+			} catch (Exception e) {
+				System.out.println(TXMCoreMessages.Subcorpus_2+Log.toString(e));
+			}
+
+		this.load();
+	}
+
+	/**
+	 * Register to parent.
+	 */
+	public void registerToParent() {
+		registerToParent(this.name, this.query);
+	}
+
+	/**
+	 * Gets the query.
+	 *
+	 * @return the query
+	 */
+	public Query getQuery() {
+		return query;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.searchengine.cqp.corpus.Corpus#getBase()
+	 */
+	@Override
+	public Base getBase() {
+		TxmObject o = getParent();
+		if (o instanceof Base)
+			return (Base)o;
+		else if (o instanceof Corpus)
+			return ((Corpus)o).getBase();
+		else 	
+			return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		return this.getName();
+	}
+
+	public void setSelectionResult(SelectionResult selectionResult) {
+		this.selectionResult = selectionResult;
+		if (this.getSelfElement() != null) {
+			//remove old node if any
+			NodeList selectionList = getSelfElement().getElementsByTagName("selection"); //$NON-NLS-1$
+			for (int i = 0 ; i < selectionList.getLength() ; i++)
+				getSelfElement().removeChild(selectionList.item(i));
+
+			Document doc = this.getParent().getSelfElement().getOwnerDocument();
+			Element selectionElem = doc.createElement("selection"); // the selection element //$NON-NLS-1$
+			for (String txt : selectionResult) // the text ids
+			{
+				Element textElem = doc.createElement("selText"); //$NON-NLS-1$
+				textElem.setAttribute("id", txt); //$NON-NLS-1$
+				selectionElem.appendChild(textElem);
+			}
+			for (String crit : selectionResult.critera.keySet()) // the critera
+			{
+				ArrayList<String> values = selectionResult.critera.get(crit);
+				for (String value : values) {
+					Element criteraElem = doc.createElement("selCrit"); //$NON-NLS-1$
+					criteraElem.setAttribute("id", crit); //$NON-NLS-1$
+					criteraElem.setAttribute("value", value); //$NON-NLS-1$
+					selectionElem.appendChild(criteraElem);
+				}
+			}
+			getSelfElement().appendChild(selectionElem);// append selection elem to self
+		}
+	}
+
+	public SelectionResult initSelectionResult() {
+
+		if (getSelfElement() != null) {
+			selectionResult = new SelectionResult();
+			NodeList selectionList = getSelfElement().getElementsByTagName("selection"); //$NON-NLS-1$
+			for (int i = 0 ; i < selectionList.getLength() ;) {
+				Element selection = (Element) selectionList.item(i); // the selection element
+
+				NodeList textList = selection.getElementsByTagName("selText"); // get text ids //$NON-NLS-1$
+				for (int j = 0 ; j < textList.getLength() ; j++) {
+					Element text = (Element) textList.item(j);
+					selectionResult.add(text.getAttribute("id")); //$NON-NLS-1$
+				}
+
+				NodeList critList = selection.getElementsByTagName("selCrit"); // get the criteria //$NON-NLS-1$
+				for (int j = 0 ; j < critList.getLength() ; j++) {
+					Element crit = (Element) critList.item(j);
+					String name = crit.getAttribute("id"); // the name of the critera //$NON-NLS-1$
+					if (!selectionResult.critera.containsKey(name)) // create new list if new critera
+						selectionResult.critera.put(name, new ArrayList<String>());
+					selectionResult.critera.get(name).add(crit.getAttribute("value")); // add the value //$NON-NLS-1$
+				}
+				break; // process only one selection node
+			}
+		}
+		return selectionResult;
+	}
+
+	public SelectionResult getSelectionResult() {
+		return selectionResult;
+	}
+
+	@Override
+	public int[] getTextEndLimits() throws CqiClientException, IOException,
+	CqiServerError, InvalidCqpIdException {
+		return this.getMainCorpus().getTextEndLimits();
+	}
+	
+	@Override
+	public int[] getTextStartLimits() throws CqiClientException, IOException,
+	CqiServerError, InvalidCqpIdException {
+		return this.getMainCorpus().getTextStartLimits();
+	}
+
+	@Override
+	public List<Match> getMatches() {
+		try {
+			return qresult.getMatches();
+		} catch (CqiClientException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return new ArrayList<Match>();
+		}
+	}
+
+	public int getNMatch() {
+		try {
+			return qresult.getNMatch();
+		} catch (CqiClientException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return 0;
+		}
+	}
+	
+	@Override
+	public boolean delete() {
+		if (getSelfElement() != null) {
+			Node parent = getSelfElement().getParentNode();
+			if (parent != null) {
+				parent.removeChild(getSelfElement());
+			}
+		}
+		return super.delete();
+	}
+
+	@Override
+	public int[] getStartLimits(String sup) throws IOException,
+			CqiServerError, InvalidCqpIdException, CqiClientException {
+		return this.getMainCorpus().getStartLimits(sup);
+	}
+
+	@Override
+	public KnowledgeRepository getKnowledgeRepository(String name) {
+		return this.getMainCorpus().getKnowledgeRepository(name);
+	}
+
+	@Override
+	public List<String> getKnowledgeRepositoryNames() {
+		return this.getMainCorpus().getKnowledgeRepositoryNames();
+	}
+
+	@Override
+	public AnnotationManager getAnnotationManager() {
+		return this.getMainCorpus().getAnnotationManager();
+	}
+
+	@Override
+	public boolean canBeAnnotated() {
+		return this.getMainCorpus().canBeAnnotated();
+	}
+
+	@Override
+	public String getSimpleName() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public String getDetails() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public void clean() {
+		// TODO Auto-generated method stub
+		
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/Match.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/Match.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/Match.java	(revision 449)
@@ -0,0 +1,287 @@
+// 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: 2016-04-04 14:59:04 +0200 (Mon, 04 Apr 2016) $
+// $LastChangedRevision: 3188 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus.query;
+
+import groovy.lang.IntRange;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.txm.searchengine.cqp.AbstractCqiClient;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.corpus.CorpusManager;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
+
+// TODO: Auto-generated Javadoc
+/**
+ * A Match of a query on a corpus.
+ * 
+ * @author jmague, mdecorde
+ */
+public class Match implements Comparable<Match> {
+
+	/** The start. */
+	private int start;
+
+	/** The end. */
+	private int end;
+	
+	/** The target position */
+	private int target = -1;
+
+	/** The query result. */
+	//private QueryResult queryResult;
+
+	/**
+	 * Instantiates a new match.
+	 * 
+	 * @param queryResult
+	 *            the query result
+	 * @param start
+	 *            the cqp index of the start of the match
+	 * @param end
+	 *            the cqp index of the end of the match
+	 */
+	public Match(int start, int end) {
+		this.start = start;
+		this.end = end;
+		//this.queryResult = queryResult;
+	}
+
+	public Match(int start, int end, int target) {
+		this(start,end);
+		this.target = target;
+	}
+
+	/**
+	 * Gets the start.
+	 * 
+	 * @return the start
+	 */
+	public int getStart() {
+		return start;
+	}
+	
+	/**
+	 * Gets the start.
+	 * 
+	 * @return the start
+	 */
+	public int getTarget() {
+		return target;
+	}
+
+	/**
+	 * Gets the end.
+	 * 
+	 * @return the end
+	 */
+	public int getEnd() {
+		return end;
+	}
+	
+	public boolean contains(Match m) {
+		return (this.start <= m.start && m.end <= this.end);
+	}
+
+//	/**
+//	 * Gets the query result.
+//	 * 
+//	 * @return the query result
+//	 */
+//	public QueryResult getQueryResult() {
+//		return queryResult;
+//	}
+
+	/**
+	 * Gets the value for property for the first position of the match.
+	 * 
+	 * @param property
+	 *            the property
+	 * 
+	 * @return the value for property
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public String getValueForProperty(Property property)
+			throws CqiClientException {
+		List<Match> match = new ArrayList<Match>();
+		match.add(this);
+		return Match.getValuesForProperty(property, match).get(0);
+	}
+
+	/**
+	 * Gets the values for property for all the positions of the match.
+	 * 
+	 * @param property
+	 *            the property
+	 * 
+	 * @return the value for property
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public List<String> getValuesForProperty(Property property)
+			throws CqiClientException {
+		int[] positions = new int[this.end - this.start + 1];
+		for (int i = 0; i < this.end - this.start + 1; i++)
+			positions[i] = this.start + i;
+		return getValuesForProperty(property, positions);
+	}
+
+	/**
+	 * Gets the values for property.
+	 * 
+	 * @param property
+	 *            the property
+	 * @param matches
+	 *            the matches to get the values for
+	 * 
+	 * @return the values for property
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public static List<String> getValuesForProperty(Property property,
+			List<Match> matches) throws CqiClientException {
+		int[] starts = new int[matches.size()];
+		for (int i = 0; i < matches.size(); i++)
+			starts[i] = matches.get(i).start;
+		return getValuesForProperty(property, starts);
+	}
+
+	/**
+	 * Gets the values for property.
+	 * 
+	 * @param property
+	 *            the property
+	 * @param positions
+	 *            the positions to get the values for
+	 * 
+	 * @return the values for property
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public static List<String> getValuesForProperty(Property property,
+			int[] positions) throws CqiClientException {
+		AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient();
+		try {
+			if (property instanceof StructuralUnitProperty) {
+				int[] struc = cqiClient.cpos2Struc(property.getQualifiedName(),
+						positions);
+				return Arrays.asList(cqiClient.struc2Str(property
+						.getQualifiedName(), struc));
+			} else {
+				return Arrays.asList(cqiClient.cpos2Str(property
+						.getQualifiedName(), positions));
+			}
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Comparable#compareTo(java.lang.Object)
+	 */
+	@Override
+	public int compareTo(Match m) {
+
+		if (m == null)
+			return -1;
+		if (this.start < m.start)
+			return -1;
+		else if (this.start > m.start)
+			return 1;
+		else if (this.end < m.end)
+			return -1;
+		else
+			return 1;
+
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		return "<" + start + ", " + end + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+	}
+
+	/**
+	 * Gets the ids.
+	 *
+	 * @param property the property
+	 * @param positions the positions
+	 * @return the ids
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public int[] getIds(Property property, int[] positions)
+			throws CqiClientException {
+		AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient();
+
+		try {
+			if (property instanceof StructuralUnitProperty) {
+				int[] struc = cqiClient.cpos2Struc(property.getQualifiedName(),
+						positions);
+				return struc;
+			} else {
+				int[] ids = cqiClient.cpos2Id(property.getQualifiedName(),
+						positions);
+				return ids;
+			}
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+	}
+
+	/**
+	 * Size.
+	 *
+	 * @return the int
+	 */
+	public int size() {
+		return getEnd() - getStart() + 1;
+	}
+	
+	public int getLength() {
+		return (end - start);
+	}
+
+	public Collection<? extends Integer> getRange() {
+		return new IntRange(start, end);
+	}
+
+	public void setEnd(int p) {
+		this.end = p;
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/QueryPart.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/QueryPart.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/QueryPart.java	(revision 449)
@@ -0,0 +1,94 @@
+// 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-06-15 15:29:16 +0200 (Mon, 15 Jun 2015) $
+// $LastChangedRevision: 2989 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus.query;
+
+import org.txm.searchengine.cqp.corpus.StructuralUnit;
+import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
+
+import static org.txm.searchengine.cqp.corpus.query.CqpQueryConstant.*;
+
+// TODO: Auto-generated Javadoc
+/**
+ * A query that extract a part from a corpus.
+ * 
+ * @author Jean Philippe Magué
+ * @author sloiseau
+ */
+public class QueryPart extends Query {
+
+	/** The structure. */
+	private StructuralUnit structure;
+
+	/** The property. */
+	private StructuralUnitProperty property;
+
+	/** The value. */
+	private String value;
+
+	/**
+	 * Instantiates a new query part.
+	 * 
+	 * @param structure
+	 *            the structure
+	 * @param property
+	 *            the property
+	 * @param value
+	 *            the value
+	 */
+	public QueryPart(StructuralUnit structure, StructuralUnitProperty property,
+			String value) {
+		this.structure = structure;
+		this.property = property;
+		this.value = value;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.txm.searchengine.cqp.corpus.query.Query#getQueryString()
+	 */
+	/*
+	 * Produce a query such as: [_.struct_property="value"] expand to struct
+	 *  
+	 * OLD VERSION: /region[TEI_type,a]::a.TEI_type="value"
+	 */
+	@Override
+	public String getQueryString() {
+		String tag = structure.getName() + TAG_ATTRIBUTE_SEPARATOR + property.getName();
+		String label = "a"; //$NON-NLS-1$
+		StringBuffer query = new StringBuffer();
+		query.append(REGION_MACRO + START_MACRO_ARGS);
+		query.append(tag + MACRO_ARGS_SEPARATOR + label + END_MACRO_ARGS);
+		query.append(START_GLOBAL_CONSTRAINT + label + DOT + tag + EQUALS
+				+ START_DOUBLE_QUOTE + value + END_DOUBLE_QUOTE);
+		return query.toString();
+		
+		// another way to query parts less restrictif but missleading
+		//return String.format("[_.%s=\"%s\"] expand to %s", tag, value, structure.getName());
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/MatchUtils.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/MatchUtils.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/MatchUtils.java	(revision 449)
@@ -0,0 +1,28 @@
+package org.txm.searchengine.cqp.corpus.query;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MatchUtils {
+	/**
+	 * 
+	 * @param list the matches to cover
+	 * @param b the matches that covers
+	 * @return the indexes of 'b' matches that covers the 'a' matches
+	 */
+	public static ArrayList<Integer> matchesCoveredByB(List<Match> list, List<Match> b) {
+		int ai=0, bi=0;
+		ArrayList<Integer> result = new ArrayList<Integer>();
+
+		while (ai < list.size() && bi < b.size() ) {
+			if (b.get(bi).contains(list.get(ai))) { 
+				result.add(bi);
+				bi++; 
+			} else { 
+				ai++; 
+			} 
+		}
+
+		return result;
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/package.html
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/package.html	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/package.html	(revision 449)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>Classes representing a query, wrapping and hidding internal cqp query syntax.</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/Focus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/Focus.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/Focus.java	(revision 449)
@@ -0,0 +1,146 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus.query;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.searchengine.cqp.corpus.Property;
+
+// TODO: Auto-generated Javadoc
+/**
+ * A focus is a modality of an {@link Property}.
+ * 
+ * @author sloiseau
+ */
+public class Focus {
+
+	/** The analysis property. */
+	private final Property analysisProperty;
+
+	/** The modality. */
+	private final List<String> modality;
+
+	/**
+	 * Instantiates a new focus.
+	 * 
+	 * @param analysisProperty
+	 *            the analysis property
+	 * @param modality
+	 *            the modality
+	 */
+	public Focus(Property analysisProperty, String modality) {
+		// this(analysisProperty, new ArrayList<String>().add(modality));
+		super();
+		this.analysisProperty = analysisProperty;
+		this.modality = new ArrayList<String>();
+		this.modality.add(modality);
+		checkModalityList();
+	}
+
+	/**
+	 * Instantiates a new focus.
+	 * 
+	 * @param analysisProperty
+	 *            the analysis property
+	 * @param modality
+	 *            the modality
+	 */
+	public Focus(Property analysisProperty, List<String> modality) {
+		super();
+		this.analysisProperty = analysisProperty;
+		this.modality = modality;
+		checkModalityList();
+	}
+
+	/**
+	 * Check modality list.
+	 */
+	private void checkModalityList() {
+		for (String mod : modality) {
+			if (mod == null || mod.equals(""))throw new IllegalArgumentException(TXMCoreMessages.Focus_1); //$NON-NLS-1$
+		}
+	}
+
+	/**
+	 * Gets the analysis property.
+	 * 
+	 * @return the analysis property
+	 */
+	public Property getAnalysisProperty() {
+		return analysisProperty;
+	}
+
+	/**
+	 * Gets the modality.
+	 * 
+	 * @return the modality
+	 */
+	public List<String> getModality() {
+		return modality;
+	}
+
+	/**
+	 * Gets the query string.
+	 * 
+	 * @return the query string
+	 */
+	public String getQueryString() {
+		StringBuffer queryString = new StringBuffer();
+		queryString.append(CqpQueryConstant.START_ATTRIBUTE);
+		queryString.append(analysisProperty.getName());
+		queryString.append(CqpQueryConstant.EQUALS);
+		queryString.append(CqpQueryConstant.START_QUOTE);
+		if (modality.size() == 1) {
+			queryString.append(modality.get(0));
+		} else {
+			for (Iterator<String> iter = modality.iterator(); iter.hasNext();) {
+				String element = iter.next();
+				queryString.append(element);
+				if (iter.hasNext()) {
+					queryString.append(CqpQueryConstant.OR);
+				}
+			}
+		}
+		queryString.append(CqpQueryConstant.END_QUOTE);
+		queryString.append(CqpQueryConstant.END_ATTRIBUTE);
+		queryString.append(CqpQueryConstant.END_QUERY_EXPR);
+		return queryString.toString();
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		return getQueryString();
+	}
+
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/CqpQueryConstant.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/CqpQueryConstant.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/CqpQueryConstant.java	(revision 449)
@@ -0,0 +1,87 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus.query;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqpQueryConstant.
+ */
+public class CqpQueryConstant {
+
+	/** The Constant OR. */
+	public final static String OR = "|"; //$NON-NLS-1$
+	
+	/** The Constant AND. */
+	public final static String AND = "&"; //$NON-NLS-1$
+	
+	/** The Constant EQUALS. */
+	public final static String EQUALS = "="; //$NON-NLS-1$
+	
+	/** The Constant START_ATTRIBUTE. */
+	public final static String START_ATTRIBUTE = "["; //$NON-NLS-1$
+	
+	/** The Constant END_ATTRIBUTE. */
+	public final static String END_ATTRIBUTE = "]"; //$NON-NLS-1$
+	
+	/** The Constant END_QUERY_EXPR. */
+	public final static String END_QUERY_EXPR = ";"; //$NON-NLS-1$
+	
+	/** The Constant START_QUOTE. */
+	public final static String START_QUOTE = "'"; //$NON-NLS-1$
+	
+	/** The Constant END_QUOTE. */
+	public final static String END_QUOTE = "'"; //$NON-NLS-1$
+	
+	/** The Constant START_DOUBLE_QUOTE. */
+	public final static String START_DOUBLE_QUOTE = "\""; //$NON-NLS-1$
+	
+	/** The Constant END_DOUBLE_QUOTE. */
+	public final static String END_DOUBLE_QUOTE = "\""; //$NON-NLS-1$
+	
+	/** The Constant DOT. */
+	public final static String DOT = "."; //$NON-NLS-1$
+	
+	/** The Constant TAG_ATTRIBUTE_SEPARATOR. */
+	public final static String TAG_ATTRIBUTE_SEPARATOR = "_"; //$NON-NLS-1$
+	
+	/** The Constant REGION_MACRO. */
+	public final static String REGION_MACRO = "/region"; //$NON-NLS-1$
+	
+	/** The Constant START_MACRO_ARGS. */
+	public final static String START_MACRO_ARGS = "["; //$NON-NLS-1$
+	
+	/** The Constant END_MACRO_ARGS. */
+	public final static String END_MACRO_ARGS = "]"; //$NON-NLS-1$
+	
+	/** The Constant MACRO_ARGS_SEPARATOR. */
+	public final static String MACRO_ARGS_SEPARATOR = ","; //$NON-NLS-1$
+	
+	/** The Constant START_GLOBAL_CONSTRAINT. */
+	public final static String START_GLOBAL_CONSTRAINT = "::"; //$NON-NLS-1$
+
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/Query.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/Query.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/Query.java	(revision 449)
@@ -0,0 +1,320 @@
+// 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.cqp.corpus.query;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class Query.
+ * 
+ * @author sloiseau
+ * @author jpmague
+ * @author sheiden
+ */
+
+public class Query {
+
+	/** The Constant NoStrategy. */
+	private static final Integer NoStrategy = 0;
+	
+	/** The Constant JPMStrategy. */
+	private static final Integer JPMStrategy = 1;
+	
+	/** The Constant WLXStrategy. */
+	private static final Integer WLXStrategy = 2;
+	
+	/** The Constant ElectricStrategy. */
+	private static final Integer ElectricStrategy = 3;
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	@Override
+	public boolean equals(Object obj) {
+		if (!(obj instanceof Query))
+			return false;
+		return this.getQueryString().equals(((Query) obj).getQueryString());
+	}
+
+	/** The query string. */
+	private String queryString;
+
+	/**
+	 * Instantiates a new query.
+	 */
+	protected Query() {
+	}
+
+	/**
+	 * Instantiates a new query.
+	 * 
+	 * @param queryString
+	 *            the query string
+	 * 
+	 *            public Query(String queryString){
+	 *            this.queryString=queryString.trim(); }
+	 */
+	public Query(String queryString) {
+		this.queryString = queryString.trim();
+	}
+
+	/**
+	 * Gets the query string.
+	 * 
+	 * @return the query string
+	 */
+	public String getQueryString() {
+		return queryString;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		return queryString;
+	}
+
+	/**
+	 * Normalize white chars.
+	 *
+	 * @param str the str
+	 * @return the string with white chars normalized
+	 * @author sheiden
+	 */
+	public static String normalizeWhiteChars(String str) {
+
+		/*
+		 * - first normalize white chars : We don't know from where the query
+		 * comes from and how it was produced (pasted from a text editor after
+		 * having been double-clicked and copied, typed in the query input
+		 * field, etc.) The CQP syntax analyzer is sensible to white chars, so
+		 * we have to normalize what the user may have leaved inadvertently
+		 * because she may not see well the true query string (white chars are
+		 * invisible), and it is dif ficult to accept and manage a syntax error
+		 * when you can't "see" the source of the problem. That strategy decides
+		 * to interpret every white chars contiguous sequence as one space
+		 * character.
+		 * 
+		 * Please note that this may be compatible (or not) with other Search
+		 * Engines query scanners.
+		 * 
+		 * Please note also that this may be compatible (or not) with the
+		 * tokenization policy of a given corpus dealing with compound words.
+		 * That strategy is compatible with a policy which separates words in
+		 * compound words by one space character.
+		 * 
+		 * - then remove outer white chars : What is not seen should not be
+		 * there if no explicit expression deals with it from the user's point
+		 * of view. So white chars at the beginning or at the end of the query
+		 * are removed. Those characters often come from rapid copy/paste or
+		 * double-click/copy/paste (in a word processing software, the
+		 * double-click strategy can for example select the white chars on the
+		 * right of the selected strings to help the user move words around with
+		 * their delimiters).
+		 * 
+		 * That strategy may seem aggressive, but experience shows that this
+		 * little service helps silently users a lot and is rarely
+		 * inappropriate.
+		 * 
+		 * In case of doubt, the user should be able to switch to another
+		 * strategy.
+		 */
+
+		// normalize everything white to space
+		String str1 = str.replaceAll("\\s+", " "); //$NON-NLS-1$ //$NON-NLS-2$
+		// remove border whites
+		str1 = str1.replaceFirst("^ ", ""); //$NON-NLS-1$ //$NON-NLS-2$
+		str1 = str1.replaceFirst(" $", ""); //$NON-NLS-1$ //$NON-NLS-2$
+		return str1;
+	}
+
+	/**
+	 * Transforms a simplified query string into a proper CQP query string
+	 * 
+	 * Follows several different strategies to do that :
+	 * 
+	 * JPM Strategy : if the input query matches \w quote are added if the input
+	 * query matches \w*="\w*", square brackets are added if the input query
+	 * matches .\w=.\w (i.e. without quotes), quotes and square brackets are
+	 * added (i.e. -> [$1="$2"]) otherwise, the query is left as if 
+	 * 
+	 * Weblex Strategy : normalize white chars add double quotes if no double
+	 * quotes and no brackets
+	 * 
+	 * Electric Strategy : normalize white chars add double quote, equal,
+	 * brackets, etc. depending on the presence/absence of those chars in the
+	 * original query
+	 * 
+	 * No Strategy : do nothing
+	 * 
+	 * @param query
+	 *            The query string to fix
+	 * @return the fixed query string
+	 */
+	static public String fixQuery(String query) {
+
+		//if (query.startsWith("intersect ")) return query;
+
+		if ("\"".equals(query)) return "\"\\\"\""; //$NON-NLS-1$ //$NON-NLS-2$
+		
+		Integer QueryFixStrategy = WLXStrategy;
+
+		if (QueryFixStrategy == JPMStrategy) {
+
+			// query = abc -> put double quotes
+			Pattern simple = Pattern.compile("\\p{L}*"); //$NON-NLS-1$
+			if (simple.matcher(query).matches()) {
+				// System.out.println("match 1");
+				return '"' + query + '"'; //$NON-NLS-1$
+			}
+
+			// query = prop="abc" -> put square brackets
+			Pattern equalsWithQuotes = Pattern.compile("\\p{L}+=\"\\p{L}*\""); //$NON-NLS-1$
+			if (equalsWithQuotes.matcher(query).matches()) {
+				// System.out.println("match 2");
+				return '[' + query + ']';
+			}
+
+			// query = abc=def -> put brackets + equal sign + double quotes
+			Pattern equalsWithoutQuotes = Pattern
+					.compile("(\\p{L}*)=(\\p{L}*)"); //$NON-NLS-1$
+			Matcher matcher = equalsWithoutQuotes.matcher(query);
+			if (matcher.matches()) {
+				// System.out.println("match 2");
+				return '[' + matcher.group(1) + '=' + '"' + matcher.group(2)
+						+ '"' + ']';
+			}
+
+			// query doesn't start with ", ' and [ -> put double quotes
+			if (!query.startsWith("\"") && !query.startsWith("\'") && !query.startsWith("[")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			{
+				return '"' + query + '"'; //$NON-NLS-1$
+			}
+
+			// do nothing
+			return query;
+
+		} else if (QueryFixStrategy == WLXStrategy) {
+
+			query = normalizeWhiteChars(query);
+
+			// query contains double quotes
+			if (query.contains("\"")) { //$NON-NLS-1$
+				return query;
+			} else
+			// query contains brackets
+			if (query.contains("[") && query.contains("]")) { //$NON-NLS-1$ //$NON-NLS-2$
+				return query; // probably [] or [...]
+			} else {
+				return '"' + query + '"'; //$NON-NLS-1$
+			}
+		} else if (QueryFixStrategy == ElectricStrategy) {
+
+			// DON'T USE THAT STRATEGY : CODE NEEDS TO BE FIXED
+			query = normalizeWhiteChars(query);
+
+			if (query.contains("\"")) { //$NON-NLS-1$
+				if (query.contains("=")) { //$NON-NLS-1$
+					if (query.contains("[")) { //$NON-NLS-1$
+						return query;
+					} else {
+						return '[' + query + ']';
+					}
+				} else {
+					return query;
+				}
+			} else {
+				if (query.contains("=")) { //$NON-NLS-1$
+					return query.replaceAll("=([^= \"]+)", "=\"$1\""); //$NON-NLS-1$ //$NON-NLS-2$
+				} else {
+					return '"' + query + '"'; //$NON-NLS-1$
+				}
+			}
+		} else if (QueryFixStrategy == NoStrategy) {
+
+			// no strategy to apply : do nothing
+			return query;
+
+		} else {
+
+			// we shouldn't be there
+			// let silently return the query for the moment
+			return query;
+		}
+	}
+
+	/**
+	 * Equals.
+	 *
+	 * @param query the query
+	 * @return true, if successful
+	 */
+	public boolean equals(Query query) {
+		return this.getQueryString().equals(query.getQueryString());
+	}
+
+	/** espace char |"{()}+*. */
+	private static String chars = "^$<>|\\\"{()}?+*."; //$NON-NLS-1$
+	
+	/**
+	 * Adds the back slash.
+	 *
+	 * @param squery the squery
+	 * @return the string
+	 */
+	public static String addBackSlash(String squery) {
+		if ("\"".equals(squery)) return "\"\\\"\""; //$NON-NLS-1$ //$NON-NLS-2$
+		StringBuffer buff = new StringBuffer();
+		//for(char c : chars.)
+		for(int i = 0 ; i < squery.length() ; i++)
+		{
+			int j = chars.indexOf(squery.charAt(i));
+			//System.out.println(""+i+" : "+squery.charAt(i)+ " >> "+j);
+			
+			if ( j >= 0 )
+				buff.append("\\"+squery.charAt(i)); //$NON-NLS-1$
+			else
+				buff.append(squery.charAt(i));
+		}
+		return buff.toString();
+	}
+	
+	/**
+	 * The main method.
+	 *
+	 * @param args the arguments
+	 */
+	public static void main(String[] args)
+	{
+		String test = "^$sdf<>sdf|\\sdf\"{(sdf)}?+sdf*."; //$NON-NLS-1$
+		System.out.println(Query.addBackSlash(test));
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/QueryFocus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/QueryFocus.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/QueryFocus.java	(revision 449)
@@ -0,0 +1,56 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus.query;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class QueryFocus.
+ */
+public class QueryFocus extends Query {
+
+	/** The focus. */
+	private final Focus focus;
+
+	/**
+	 * Instantiates a new query focus.
+	 *
+	 * @param focus the focus
+	 */
+	public QueryFocus(Focus focus) {
+		this.focus = focus;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.searchengine.cqp.corpus.query.Query#getQueryString()
+	 */
+	@Override
+	public String getQueryString() {
+		return this.focus.getQueryString();
+	}
+
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/Occurrence.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/Occurrence.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/Occurrence.java	(revision 449)
@@ -0,0 +1,74 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus.query;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class Occurrence.
+ */
+public class Occurrence {
+	
+	/** The position. */
+	int position;
+	
+	/** The signature. */
+	int[] signature;
+	
+	/** The signsum. */
+	int signsum = 0;
+
+	/**
+	 * Instantiates a new occurrence.
+	 *
+	 * @param p the p
+	 * @param props the props
+	 */
+	public Occurrence(int p, int[] props) {
+		position = p;
+		signature = props;
+		for (int i = 0; i < signature.length; i++)
+			signsum += signature[i];
+	}
+
+	/**
+	 * Equals.
+	 *
+	 * @param o the o
+	 * @return true, if successful
+	 */
+	public boolean equals(Occurrence o) {
+		if (signature.length != o.signature.length)
+			return false;
+		if (signsum != o.signsum)
+			return false;
+		for (int i = 0; i < signature.length; i++)
+			if (signature[i] != o.signature[i])
+				return false;
+		return true;
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/PartitionFocus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/PartitionFocus.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/PartitionFocus.java	(revision 449)
@@ -0,0 +1,174 @@
+// 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: 2013-09-05 09:27:13 +0200 (jeu., 05 sept. 2013) $
+// $LastChangedRevision: 2529 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus.query;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.searchengine.cqp.corpus.Part;
+import org.txm.searchengine.cqp.corpus.Partition;
+import org.txm.utils.logger.Log;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Denote a part in a partition.
+ * 
+ * @author sloiseau
+ */
+public class PartitionFocus {
+
+	/** The analysis property. */
+	private final Partition partition;
+
+	/** The modality. */
+	private final List<String> modality;
+	
+	/** The focus index. */
+	private int[] focusIndex = null;
+
+	/**
+	 * Instantiates a new focus.
+	 *
+	 * @param partition the partition
+	 * @param modality the modality
+	 */
+	public PartitionFocus(Partition partition, String modality) {
+		// this(analysisProperty, new ArrayList<String>().add(modality));
+		super();
+		this.partition = partition;
+		this.modality = new ArrayList<String>();
+		this.modality.add(modality);
+		checkModalityList();
+	}
+
+	/**
+	 * Instantiates a new focus.
+	 *
+	 * @param partition the partition
+	 * @param modality the modality
+	 */
+	public PartitionFocus(Partition partition, List<String> modality) {
+		super();
+		this.partition = partition;
+		this.modality = modality;
+		checkModalityList();
+	}
+
+	/**
+	 * Check modality list.
+	 */
+	private void checkModalityList() {
+		List<String> partNames = partition.getPartNames();
+		for (String mod : modality) {
+			if (mod == null || mod.equals("")) { //$NON-NLS-1$
+				Log.finest(TXMCoreMessages.PartitionFocus_1);
+				throw new IllegalArgumentException(TXMCoreMessages.PartitionFocus_2);
+			}
+			if (!partNames.contains(mod)) {
+				Log.finest(TXMCoreMessages.PartitionFocus_3 + mod
+						+ " " + partNames); //$NON-NLS-1$
+				throw new IllegalArgumentException(TXMCoreMessages.PartitionFocus_4);
+			}
+		}
+	}
+
+	/**
+	 * Gets the focused parts.
+	 *
+	 * @return the focused parts
+	 */
+	public List<Part> getFocusedParts() {
+		List<Part> focused = new ArrayList<Part>(modality.size());
+		for (int i = 0; i < partition.getParts().size(); i++) {
+			if (modality.contains(partition.getParts().get(i))) {
+				focused.add(partition.getParts().get(i));
+			}
+		}
+		return focused;
+	}
+
+	/**
+	 * Gets the not focused parts.
+	 *
+	 * @return the not focused parts
+	 */
+	public List<Part> getNotFocusedParts() {
+		List<Part> notFocused = new ArrayList<Part>(modality.size());
+		for (int i = 0; i < partition.getParts().size(); i++) {
+			if (!modality.contains(partition.getParts().get(i))) {
+				notFocused.add(partition.getParts().get(i));
+			}
+		}
+		return notFocused;
+	}
+
+	/**
+	 * Gets the analysis property.
+	 * 
+	 * @return the analysis property
+	 */
+	public Partition getPartition() {
+		return partition;
+	}
+
+	/**
+	 * Gets the modality.
+	 * 
+	 * @return the modality
+	 */
+	public List<String> getModality() {
+		return modality;
+	}
+
+	/**
+	 * Gets the focus index.
+	 *
+	 * @return the focus index
+	 */
+	public int[] getFocusIndex() {
+		if (focusIndex == null)
+			computeFocusIndex();
+		return focusIndex;
+	}
+
+	/**
+	 * Compute focus index.
+	 */
+	private void computeFocusIndex() {
+		focusIndex = new int[modality.size()];
+		List<String> partNames = partition.getPartNames();
+		int y = 0;
+		for (int i = 0; i < modality.size(); i++) {
+			if (partNames.contains(modality.get(i))) {
+				focusIndex[y] = i;
+				y++;
+			}
+		}
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CorpusManager.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CorpusManager.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CorpusManager.java	(revision 449)
@@ -0,0 +1,228 @@
+// 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: 2016-08-30 09:45:56 +0200 (Tue, 30 Aug 2016) $
+// $LastChangedRevision: 3283 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.persistence.annotations.Structure;
+import org.txm.Toolbox;
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.searchengine.cqp.AbstractCqiClient;
+import org.txm.searchengine.cqp.CQPEngine;
+import org.txm.searchengine.cqp.NetCqiClient;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException;
+import org.txm.utils.logger.Log;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CorpusManager provide access through a CQi client to the corpora
+ * managed by CQP.
+ * 
+ * The corpus manager is a singleton, and before the instance can be acceded via
+ * {@link #getCorpusManager()} it has to configured with
+ * {@link #setCqiClient(NetCqiClient)}.
+ * 
+ * The corpus manager must be used to create instances of {@link MainCorpus}
+ * (with {@link #getCorpus(String)}), instances of {@link Partition} (with
+ * {@link #createPartition(AbstractCorpus, Structure, Property, List)}), and
+ * instances of {@link Subcorpus} (with
+ * {@link #query(AbstractCorpus, String, String)}).
+ * 
+ * @author Jean-Philippe Magué
+ */
+public class CorpusManager {
+
+	/** The cqi client. */
+	private static AbstractCqiClient cqiClient;
+
+	/** The singleton. */
+	private static CorpusManager corpusManager = null;
+
+	/** the corpora. */
+	private static List<MainCorpus> corpora = null;
+
+	/**
+	 * Instantiates a new corpus manager.
+	 */
+	private CorpusManager() {
+	}
+
+	/**
+	 * Sets the cqi client.
+	 * 
+	 * @param cqiClient
+	 *            the new cqi client
+	 */
+	public static void setCqiClient(AbstractCqiClient cqiClient) {
+		CorpusManager.cqiClient = cqiClient;
+	}
+
+	/**
+	 * Gets the corpus manager.
+	 * 
+	 * @return the corpus manager
+	 */
+	public static CorpusManager getCorpusManager() {
+		if (cqiClient == null)
+			throw new RuntimeException(TXMCoreMessages.CorpusManager_0);
+		if (corpusManager == null)
+			corpusManager = new CorpusManager();
+		return corpusManager;
+	}
+
+	/**
+	 * Clean.
+	 */
+	public static void clean() {
+		cqiClient = null;
+		corpora = null;
+		corpusManager = null;
+	}
+
+	/**
+	 * Clean corpora : empty the 'corpora' member.
+	 */
+	public static void cleanCorpora() {
+		corpora = null;
+	}
+
+	/**
+	 * Gets a corpus.
+	 *
+	 * @param corpusName the corpus name
+	 * @return the corpus
+	 * @throws CqiClientException the cqi client exception
+	 * @throws InvalidCqpIdException the invalid cqp id exception
+	 */
+	public MainCorpus getCorpus(String corpusName) throws CqiClientException,
+			InvalidCqpIdException {
+		// return new MainCorpus(corpusName);
+		if (corpora == null) {
+			// System.out.println("error corpora is null ");
+			this.getCorpora();
+		}
+
+		for (MainCorpus corpus : CorpusManager.corpora) {
+			if (corpus.getName().equals(corpusName)) {
+				// System.out.println("found corpus "+corpusName);
+				return corpus;
+			}
+		}
+		//System.out.println("create corpus "+corpusName);
+		MainCorpus c = new MainCorpus(corpusName);
+		//this.corpora.add(c);
+		// corpora.add(c);
+		return c;
+	}
+
+	/**
+	 * Checks for corpus.
+	 *
+	 * @param name the name
+	 * @return true, if successful
+	 */
+	public boolean hasCorpus(String name) {
+		if (corpora == null)
+			return false;
+		for (MainCorpus c : corpora)
+			if (name.equals(c.getName()))
+				return true;
+		return false;
+	}
+
+	/**
+	 * Gets a list of the corpora managed by CQP.
+	 * 
+	 * @return the corpora
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public List<MainCorpus> getCorpora() throws CqiClientException {
+		//System.out.println("get corpora");
+		if (corpora != null)
+			return corpora;
+
+		String[] corporaName;
+		try {
+			corporaName = cqiClient.listCorpora();
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+
+		corpora = new ArrayList<MainCorpus>(corporaName.length);
+		for (int i = 0; i < corporaName.length; i++) {
+			try {
+				corpora.add(this.getCorpus(corporaName[i]));
+			} catch (InvalidCqpIdException e) {
+				throw new CqiClientException(TXMCoreMessages.CorpusManager_1, e);
+			}
+		}
+		
+		for (Corpus corpus : corpora) {
+			try {
+				corpus.setCharset(cqiClient.corpusCharset(corpus.getCqpId()));
+				// TODO : implements cqiClient.corpusLanguage
+				// corpus.setLanguage(cqiClient.corpusLanguage(corpus.getCqpId()));
+			} catch (Exception e) {
+				org.txm.utils.logger.Log.printStackTrace(e);
+			}
+		}
+		// System.out.println("END creating corpora");
+		return corpora;
+	}
+
+	/**
+	 * Gets the cqi client.
+	 * 
+	 * @return the cqi client
+	 */
+	public AbstractCqiClient getCqiClient() {
+		return cqiClient;
+	}
+
+	/**
+	 * Delete corpus.
+	 *
+	 * @param corpus the corpus
+	 */
+	public static void deleteCorpus(MainCorpus corpus) {
+		if (corpora != null)
+			corpora.remove(corpus);
+		if (CQPEngine.isInitialized()) {
+			try {
+				CQPEngine.getCqiClient().dropCorpus(corpus.getName());
+			} catch (Exception e) {
+				Log.warning("Warning while removing corpus: Failed to drop corpus "+corpus);
+				Log.printStackTrace(e);
+			}
+		}
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Part.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Part.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Part.java	(revision 449)
@@ -0,0 +1,171 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus;
+
+import org.txm.objects.Base;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException;
+import org.txm.searchengine.cqp.corpus.query.Query;
+import org.w3c.dom.Element;
+
+// TODO: Auto-generated Javadoc
+/**
+ * A Part is related to a {@link Partition} and mirror a CQP subcorpus.
+ *
+ * @author jmague
+ */
+public class Part extends Subcorpus implements Comparable<Part>{
+
+	/** The partition. */
+	private Partition partition;
+
+	/** The number of texts composing this part. */
+	private int nTexts = -1;
+
+	/** The short name. */
+	private String shortName;
+
+	/**
+	 * Instantiates a new part.
+	 *
+	 * @param cqpId the cqp id
+	 * @param partitionName the full complex partition name
+	 * @param shortName the short name
+	 * @param partition the partition
+	 * @param query the query
+	 * @throws InvalidCqpIdException the invalid cqp id exception
+	 */
+	protected Part(String cqpId, String partitionName, String shortName,
+			Partition partition, Query query) throws InvalidCqpIdException {
+		super(cqpId, partitionName + "_" + shortName, partition.getCorpus(), query, false); //$NON-NLS-1$
+		this.shortName = shortName;
+		this.name = shortName;
+		this.partition = partition;
+	}
+
+	/**
+	 * Gets the partition.
+	 * 
+	 * @return the partition
+	 */
+	public Partition getPartition() {
+		return partition;
+	}
+
+	/**
+	 * Gets the number of texts in this part.
+	 * 
+	 * @return the n texts
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
+	 */
+	public int getNTexts() throws CqiClientException {
+		if (nTexts < 0)
+			try {
+				nTexts = CorpusManager.getCorpusManager().getCqiClient()
+						.subCorpusSize(getQualifiedCqpId());
+			} catch (Exception e) {
+				throw new CqiClientException(e);
+			}
+		return nTexts;
+	}
+
+	/**
+	 * Gets the short name.
+	 * 
+	 * @return the short name
+	 */
+	public String getShortName() {
+		return shortName;
+	}
+
+	/**
+	 * Sets the name.
+	 *
+	 * @param name the new name
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	/**
+	 * Load.
+	 *
+	 * @param elem the elem
+	 * @return true, if successful
+	 */
+	public boolean load(Element elem) {
+		this.setSelfElement(elem);
+		return load();
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.searchengine.cqp.corpus.Subcorpus#load()
+	 */
+	@Override
+	public boolean load() {
+		this.shortName = getSelfElement().getAttribute("shortname"); //$NON-NLS-1$
+		return super.load();
+	}
+
+	/**
+	 * Sets the short name.
+	 *
+	 * @param pshortname the new short name
+	 */
+	public void setShortName(String pshortname) {
+		this.shortName = pshortname;
+	}
+
+	/**
+	 * Sets the query.
+	 *
+	 * @param pquery the new query
+	 */
+	public void setQuery(String pquery) {
+		this.query = new Query(pquery);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.txm.searchengine.cqp.corpus.Subcorpus#getBase()
+	 */
+	@Override
+	public Base getBase() {
+		return this.partition.getCorpus().getBase();
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Comparable#compareTo(java.lang.Object)
+	 */
+	@Override
+	public int compareTo(Part o) {
+		return this.getName().compareTo(o.getName());
+	}
+
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/PropertyHashMap.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/PropertyHashMap.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/PropertyHashMap.java	(revision 449)
@@ -0,0 +1,84 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus;
+
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class PropertyHashMap.
+ *
+ * @param <E> the element type
+ */
+public class PropertyHashMap<E> extends HashMap<Property, E> {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = -6560650525642894582L;
+
+	/** The corpus. */
+	Corpus corpus;
+	
+	/** The clazz. */
+	Class<E> clazz;
+
+	/**
+	 * Instantiates a new property hash map.
+	 *
+	 * @param corpus the corpus
+	 * @param clazz the clazz
+	 */
+	public PropertyHashMap(Corpus corpus, Class<E> clazz) {
+		this.corpus = corpus;
+		this.clazz = clazz;
+	}
+
+	/**
+	 * Gets the.
+	 *
+	 * @param property the property
+	 * @return the e
+	 */
+	public E get(Property property) {
+		if (!this.containsKey(property)) {
+			//	
+			Object o = null;
+			for (Constructor<?> constructor : clazz.getConstructors()) {
+				try {
+					o = constructor.newInstance(corpus, property);
+					break;
+				} catch (Exception e) {
+				}
+			}
+			if (o == null)
+				return null;
+			this.put(property, (E) o);
+		}
+		return super.get(property);
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/StructuralUnit.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/StructuralUnit.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/StructuralUnit.java	(revision 449)
@@ -0,0 +1,154 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.corpus;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * A structural units of a corpus Represents a <strong>type</strong>, not a
+ * specif ic unit.
+ * 
+ * @author jmague
+ * 
+ */
+public class StructuralUnit implements Comparable {
+
+	/** The name. */
+	private String name;
+
+	/** The corpus. */
+	private Corpus corpus;
+
+	/** The properties. */
+	private List<StructuralUnitProperty> properties;
+
+	/**
+	 * Instantiates a new StrucutalUnit.
+	 *
+	 * @param name the name
+	 * @param properties the properties
+	 * @param corpus the corpus
+	 * @throws CqiClientException the cqi client exception
+	 */
+	protected StructuralUnit(String name, List<String> properties, Corpus corpus)
+			throws CqiClientException {
+		this.name = name;
+		this.corpus = corpus;
+		this.properties = new ArrayList<StructuralUnitProperty>();
+		for (String property : properties)
+			this.properties.add(new StructuralUnitProperty(this, property, corpus));
+	}
+
+	/**
+	 * Gets the qualified name.
+	 * 
+	 * @return the qualified name
+	 */
+	public String getQualifiedName() {
+		return corpus.getCqpId() + "." + this.getName(); //$NON-NLS-1$
+	}
+
+	/**
+	 * Gets the name.
+	 * 
+	 * @return the name
+	 */
+	public String getName() {
+		return name;
+	}
+
+	/**
+	 * Gets the properties defined on this type of structural unit.
+	 * 
+	 * @return the properties
+	 */
+	public List<StructuralUnitProperty> getProperties() {
+		return properties;
+	}
+
+	/**
+	 * Gets a property from its name.
+	 * 
+	 * @param name
+	 *            the name
+	 * 
+	 * @return the property
+	 */
+	public StructuralUnitProperty getProperty(String name) {
+		for (StructuralUnitProperty property : properties)
+			if (property.getName().equals(name))
+				return property;
+		return null;
+
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		return name;
+	}
+
+	/**
+	 * Equals.
+	 *
+	 * @param su the su
+	 * @return true, if successful
+	 */
+	public boolean equals(StructuralUnit su) {
+		return name.equals(su.name) && corpus.equals(su.corpus);
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Comparable#compareTo(java.lang.Object)
+	 */
+	@Override
+	public int compareTo(Object arg0) {
+		if (arg0 instanceof StructuralUnit)
+			return this.getQualifiedName().compareTo(
+					((StructuralUnit) arg0).getQualifiedName());
+		return 0;
+	}
+
+	/**
+	 * Gets the ordered properties.
+	 *
+	 * @return the ordered properties
+	 */
+	public List<StructuralUnitProperty> getOrderedProperties() {
+		List<StructuralUnitProperty> props = this.getProperties();
+		Collections.sort(props);
+		return props;
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ReferencePattern.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ReferencePattern.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ReferencePattern.java	(revision 449)
@@ -0,0 +1,149 @@
+// 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-10-22 09:15:18 +0200 (Thu, 22 Oct 2015) $
+// $LastChangedRevision: 3040 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
+
+// TODO: Auto-generated Javadoc
+/**
+ * how to display the references.
+ *
+ * @author mdecorde
+ */
+public class ReferencePattern implements Iterable<Property> {
+
+	/** The properties. */
+	private List<Property> properties = new ArrayList<Property>();
+
+	/**
+	 * Instantiates a new reference pattern.
+	 */
+	public ReferencePattern() {
+		properties = new ArrayList<Property>();
+	}
+
+	/**
+	 * Instantiates a new reference pattern.
+	 *
+	 * @param parameters the properties
+	 */
+	public ReferencePattern(Property prop) {
+		List<Property> properties = new ArrayList<Property>();
+		properties.add(prop);
+		this.properties = properties;
+	}
+	
+	/**
+	 * Instantiates a new reference pattern.
+	 *
+	 * @param parameters the properties
+	 */
+	public ReferencePattern(StructuralUnitProperty prop) {
+		List<Property> properties = new ArrayList<Property>();
+		properties.add(prop);
+		this.properties = properties;
+	}
+	
+	/**
+	 * Instantiates a new reference pattern.
+	 *
+	 * @param properties the properties
+	 */
+	public ReferencePattern(List<Property> properties) {
+		this.properties = properties;
+	}
+	
+	
+	/**
+	 * Adds the property.
+	 *
+	 * @param property the property
+	 * @return the reference pattern
+	 */
+	public ReferencePattern addProperty(Property property) {
+		this.properties.add(property);
+		return this;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<Property> iterator() {
+		return properties.iterator();
+	}
+
+	/**
+	 * Gets the properties.
+	 *
+	 * @return the properties
+	 */
+	public List<Property> getProperties() {
+		return properties;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		StringBuffer buffer = new StringBuffer();
+		for (Property property : properties) {
+			buffer.append(property.getName() + " "); //$NON-NLS-1$
+		}
+		return buffer.toString().trim();
+	}
+
+	/**
+	 * Gets the title.
+	 *
+	 * @return the title
+	 */
+	public String getTitle() {
+		String title = ""; //$NON-NLS-1$
+		for(Property p : this.properties)
+			if (p instanceof StructuralUnitProperty)
+			{
+				StructuralUnitProperty sp = (StructuralUnitProperty)p;
+				title += sp.getFullName()+", "; //$NON-NLS-1$
+			}
+			else
+				title += p.getName()+", "; //$NON-NLS-1$
+		if (title.length() == 0)
+			title = TXMCoreMessages.ReferencePattern_3;
+		else
+			title = title.substring(0, title.length()-2);
+		return title;
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/Reference.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/Reference.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/Reference.java	(revision 449)
@@ -0,0 +1,156 @@
+// 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: 2013-09-04 11:17:02 +0200 (mer., 04 sept. 2013) $
+// $LastChangedRevision: 2526 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.query.Match;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class Reference: 
+ * defines a pattern of word and/or structure properties
+ *
+ * @author mdecorde
+ */
+public class Reference {
+
+	/** The values. */
+	Map<Property, String> values;
+	
+	/** The reference pattern. */
+	private ReferencePattern referencePattern = new ReferencePattern();
+
+	/**
+	 * Instantiates a new reference.
+	 *
+	 * @param values the values
+	 * @param referencePattern the reference pattern
+	 */
+	public Reference(Map<Property, String> values, ReferencePattern referencePattern) {
+		this.values = values;
+		this.referencePattern = referencePattern;
+	}
+
+	/**
+	 * Instantiates a new reference.
+	 *
+	 * @param match the match
+	 * @param referencePattern the reference pattern
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public Reference(Match match, ReferencePattern referencePattern)
+			throws CqiClientException {
+		this.referencePattern = referencePattern;
+		this.values = new HashMap<Property, String>();
+		for (Property property : referencePattern)
+			values.put(property, match.getValueForProperty(property));
+	}
+
+	/**
+	 * Gets the reference pattern.
+	 *
+	 * @return the reference pattern
+	 */
+	public ReferencePattern getReferencePattern() {
+		return referencePattern;
+	}
+
+	/**
+	 * Gets the properties.
+	 *
+	 * @return the properties
+	 */
+	public List<Property> getProperties() {
+		return referencePattern.getProperties();
+	}
+
+	/**
+	 * Gets the value.
+	 *
+	 * @param property the property
+	 * @return the value
+	 */
+	public String getValue(Property property) {
+		return values.get(property);
+	}
+
+	/**
+	 * Checks if is oK.
+	 *
+	 * @return true, if is oK
+	 */
+	public boolean isOK() {
+		return (referencePattern != null && !values.isEmpty());
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+		if (values.isEmpty())
+			return ""; //$NON-NLS-1$
+		//Iterator<Entry<Property, String>> iter = values.entrySet().iterator();
+		//Entry<Property, String> entry = iter.next();
+		StringBuffer buffer = new StringBuffer(""); //$NON-NLS-1$
+		/*
+		 * 
+		 if (StructuralUnitProperty.class.isInstance(entry.getKey())) {
+			StructuralUnitProperty sProperty = (StructuralUnitProperty) entry.getKey();
+			//buffer.append(sProperty.getStructuralUnit() + "(" + entry.getKey().toString() + "):" + entry.getValue()); //$NON-NLS-1$ //$NON-NLS-2$
+			buffer.append(entry.getValue()); //$NON-NLS-1$ //$NON-NLS-2$
+		} else {
+			//buffer.append(entry.getKey().toString() + ":" + entry.getValue()); //$NON-NLS-1$
+			buffer.append(entry.getValue()); //$NON-NLS-1$
+		}
+
+		while (iter.hasNext()) {
+			entry = iter.next();
+			if (StructuralUnitProperty.class.isInstance(entry.getKey())) {
+				StructuralUnitProperty sProperty = (StructuralUnitProperty) entry.getKey();
+				//buffer.append(", " + sProperty.getStructuralUnit() + "(" + entry.getKey().toString() + "):" + entry.getValue()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+				buffer.append(", " +entry.getValue()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			} else {
+				//buffer.append(", " + entry.getKey().toString() + ":" + entry.getValue()); //$NON-NLS-1$ //$NON-NLS-2$
+				buffer.append(", " + entry.getValue()); //$NON-NLS-1$ //$NON-NLS-2$
+			}
+		}*/
+		for(Property p : this.getProperties())
+		{
+			buffer.append(values.get(p)+", "); //$NON-NLS-1$
+		}
+		if (buffer.length() > 0)
+			return buffer.substring(0, buffer.length()-2); 
+		else
+			return ""; //$NON-NLS-1$
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/AbstractCqiClient.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/AbstractCqiClient.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/AbstractCqiClient.java	(revision 449)
@@ -0,0 +1,780 @@
+// 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: 2012-03-01 08:14:11 +0100 (jeu., 01 mars 2012) $
+// $LastChangedRevision: 2134 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.UUID;
+import java.util.regex.Pattern;
+
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
+import org.txm.searchengine.cqp.corpus.Corpus;
+import org.txm.searchengine.cqp.corpus.CorpusManager;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.QueryResult;
+import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
+import org.txm.searchengine.cqp.corpus.query.Match;
+import org.txm.searchengine.cqp.corpus.query.Query;
+import org.txm.searchengine.cqp.serverException.CqiCqpErrorNoSuchCorpus;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
+import org.txm.utils.logger.Log;
+
+/**
+ * This class implements a Java Interface CQi client.
+ *
+ * @author mdecorde
+ */
+public abstract class AbstractCqiClient implements ICqiClient{
+
+	static Pattern pattern = Pattern.compile("\\p{Upper}(\\p{Upper}|\\p{Digit}|[_-])*"); //$NON-NLS-1$
+	static Pattern pattern2 = Pattern.compile("\\p{Upper}(\\p{Lower}|\\p{Digit}|[_-])*"); //$NON-NLS-1$
+	/**
+	 * Check wether <code>id</code> is a valid CQi for a corpus.
+	 *
+	 * @param id the id
+	 * @return true if <code>id</code> is in uppercase chararcters
+	 */
+	public static synchronized boolean checkCorpusId(String id) {
+		//System.out.println("Pattern: "+pattern+" test with "+id);
+		return pattern.matcher(id).matches();
+	}
+
+	/**
+	 * Check whether <code>id</code> is a valid CQi for a subcorpus.
+	 *
+	 * @param id the id
+	 * @return true if <code>id</code> is an uppercase character followed by
+	 * lowercase characters
+	 */
+	public static synchronized boolean checkSubcorpusId(String id) {
+		//System.out.println("Pattern: "+pattern+" test with "+id);
+		return pattern2.matcher(id).matches();
+	}
+	
+	String lastError;
+	public synchronized String getLastError(){	
+		if(lastError != null && lastError.length() > 0)
+			return lastError;
+		return TXMCoreMessages.AbstractCqiClient_2;
+	}
+	
+	public List<String> getSingleData(Property prop) throws IOException, CqiServerError, CqiClientException {
+		boolean isWordProperty = !(prop instanceof StructuralUnitProperty);
+		String qname = prop.getQualifiedName();
+		AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient();
+		
+		if (!isWordProperty) {
+			StructuralUnitProperty sprop = (StructuralUnitProperty) prop;
+			QueryResult qresult = prop.getCorpus().query(new Query("<"+sprop.getFullName()+">[] expand to "+sprop.getName()), "TMP", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			int[] strucs = this.cpos2Struc(qname, qresult.getStarts());
+			return Arrays.asList(cqiClient.struc2Str(qname, strucs));
+		} else {
+			int[] positions = {0,1,2,3};
+			return Arrays.asList(cqiClient.cpos2Str(qname,positions));
+		}
+	}
+	
+	public List<String> getSingleData(Property prop, int[] positions) throws UnexpectedAnswerException, IOException, CqiServerError {
+		boolean isWordProperty = !(prop instanceof StructuralUnitProperty);
+		String qname = prop.getQualifiedName();
+		AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient();
+		if (!isWordProperty) {
+			int[] strucs = cqiClient.cpos2Struc(qname, positions);
+			return Arrays.asList(cqiClient.struc2Str(qname, strucs));
+			
+		} else {
+			return Arrays.asList(cqiClient.cpos2Str(qname,positions));
+		}
+	}
+	
+	public List<List<String>> getData(Property prop, List<Integer> positions,
+			List<Integer> nWords) throws CqiClientException, IOException, CqiServerError {
+		
+		//System.out.println("START prop: "+prop);
+		//System.out.println("positions : "+positions);
+		//System.out.println("nwords    : "+nWords);
+		
+		List<List<String>> result = new ArrayList<List<String>>();
+		
+		// get all the positions needed, possible overlap
+		HashSet<Integer> allPositionsNeeded = new HashSet<Integer>();
+		for (int i = 0; i < positions.size(); i++) {
+			int n = nWords.get(i);
+			for (int j = 0; j < n; j++) {
+				allPositionsNeeded.add(positions.get(i) + j);
+			}
+		}
+		
+		// conversion from List<Integer> to int[]
+		int[] cpos = new int[allPositionsNeeded.size()];
+		int c = 0;
+		for (int i : allPositionsNeeded) cpos[c++] = i;
+		
+		// get values for positions
+		String[] values;
+		boolean isWordProperty = !(prop instanceof StructuralUnitProperty);
+		if (!isWordProperty) {
+			String qname = ((StructuralUnitProperty)prop).getQualifiedName();
+			int[] structs = this.cpos2Struc(qname, cpos);
+			values = this.struc2Str(qname, structs);
+		} else {
+			String qname = prop.getQualifiedName();
+			values = this.cpos2Str(qname, cpos);
+		}
+		
+		// sort results by position
+		TreeMap<Integer, String> map = new TreeMap<Integer, String>();
+		for (int i = 0 ; i < values.length ; i++) {
+			map.put(cpos[i], values[i]);
+		}
+		
+		// fill results
+		int start, end;
+		SortedMap<Integer, String> smap;
+		for (int i = 0 ; i < positions.size() ; i++) {
+			start = positions.get(i);
+			end = positions.get(i) + nWords.get(i);
+			if (start > end) {
+				Log.warning("Error: trying to get "+prop+" values from "+start+" to "+end);
+				result.add(new ArrayList<String>());
+			} else {
+				smap = map.subMap(start, end);
+				result.add(new ArrayList<String>(smap.values()));
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	 * Return lists of strings.
+	 *
+	 * @return the data
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public List<String> getData(StructuralUnitProperty property, Corpus corpus) throws CqiClientException {
+			QueryResult tmp = corpus.query(new Query("<" + property.getFullName() + ">[]"), UUID.randomUUID().toString(), false); //$NON-NLS-1$ //$NON-NLS-2$
+			List<Match> matches = tmp.getMatches();
+			tmp.drop();
+			ArrayList<String> ret =  new ArrayList<String>(new HashSet<String>(Match
+					.getValuesForProperty(property, matches)));
+			return ret;
+	}
+	
+	/**
+	 * Gets the data.
+	 *
+	 * @param number the number
+	 * @return return an abstract of values
+	 * @throws CqiClientException the cqi client exception
+	 */
+	public List<String> getData(StructuralUnitProperty prop, int number) throws CqiClientException {
+		
+			QueryResult tmp = prop.getCorpus()
+					.query(
+							new Query("<" + prop.getFullName() + ">[] expand to "+prop.getName()), UUID.randomUUID().toString(), false); //$NON-NLS-1$ //$NON-NLS-2$
+			if (number > tmp.getNMatch()) number = tmp.getNMatch();
+			List<Match> matches = tmp.getMatches(0, number);
+			tmp.drop();
+			return new ArrayList<String>(new HashSet<String>(Match
+					.getValuesForProperty(prop, matches)));
+			// System.out.println("Data "+property.getQualifiedName()+": "+data);
+		
+	}
+	
+	// CQI_ERROR_CONNECT_REFUSED
+	/**
+	 * Connect the client to a server.
+	 *
+	 * @param username the username
+	 * @param password the password
+	 * @return true, if successful
+	 */
+	@Override
+	public abstract boolean connect(String username, String password) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	// None
+	/**
+	 * Disconnect.
+	 * 
+	 * @return true, if successful
+	 */
+	@Override
+	public abstract boolean disconnect() throws UnexpectedAnswerException, CqiServerError, IOException;
+
+	// CQI_CTRL_LAST_GENERAL_ERROR
+	/**
+	 * return the last CQP error.
+	 *
+	 * @return the last error
+	 */
+	@Override
+	public abstract String getLastCqiError() throws UnexpectedAnswerException, IOException,	CqiServerError;
+
+	// CQI_CTRL_LAST_CQP_ERROR
+	/**
+	 * return the last CQP error.
+	 *
+	 * @return the last error
+	 */
+	@Override
+	public abstract String getLastCQPError() throws UnexpectedAnswerException, IOException,	CqiServerError;
+
+	// None
+	/**
+	 * Lists the corpora available on the server.
+	 *
+	 * @return the name of the corpora
+	 */
+	@Override
+	public abstract String[] listCorpora() throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	// None
+	/**
+	 * Gives the corpus charset.
+	 *
+	 * @param corpus the corpus
+	 * @return the name of the charset
+	 */
+	@Override
+	public abstract String corpusCharset(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	// None (not really implemented anyway)
+	/**
+	 * Gives the corpus properties.
+	 *
+	 * @param corpus the corpus
+	 * @return the properties
+	 */
+	@Override
+	public abstract String[] corpusProperties(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS
+	/**
+	 * Gives the corpus positional attributes.
+	 *
+	 * @param corpusID the corpus id
+	 * @return the name of the attributes
+	 */
+	@Override
+	public abstract String[] corpusPositionalAttributes(String corpusID) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS
+	/**
+	 * Gives the corpus structural attributes.
+	 *
+	 * @param corpus the corpus
+	 * @return the name of the attributes
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public abstract String[] corpusStructuralAttributes(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS, CQI_CL_ERROR_NO_SUCH_ATTRIBUTE,
+	// CQI_CL_ERROR_WRONG_ATTRIBUTE_TYPE
+	/**
+	 * Check wether a structural attribute has values.
+	 *
+	 * @param attribute the attribute
+	 * @return true, if it has values
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public abstract boolean corpusStructuralAttributeHasValues(String attribute) throws UnexpectedAnswerException, IOException,
+	CqiServerError;
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS
+	/**
+	 * Gives the corpus alignement attributes.
+	 *
+	 * @param corpus the corpus
+	 * @return the name of attributes
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public abstract String[] corpusAlignementAttributes(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS
+	/**
+	 * Gives the corpus full name.
+	 *
+	 * @param corpus the corpus
+	 * @return the full name
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public abstract String corpusFullName(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Gives the corpus info listed in the .INFO file.
+	 *
+	 * @param corpus the corpus
+	 * @return the info
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public abstract String[] corpusInfo(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Drop a corpus.
+	 * 
+	 * @param corpus
+	 *            the corpus
+	 */
+	@Override
+	public abstract void dropCorpus(String corpus) throws Exception;
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS, CQI_CL_ERROR_NO_SUCH_ATTRIBUTE,
+	// CQI_CL_ERROR_WRONG_ATTRIBUTE_TYPE, CQI_CL_ERROR_CORPUS_ACCESS
+	/**
+	 * Gives an attribute size (the number of token).
+	 *
+	 * @param attribute the attribute
+	 * @return the size
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public abstract int attributeSize(String attribute) throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	// CQI_CQP_ERROR_NO_SUCH_CORPUS, CQI_CL_ERROR_NO_SUCH_ATTRIBUTE,
+	// CQI_CL_ERROR_WRONG_ATTRIBUTE_TYPE, CQI_CL_ERROR_CORPUS_ACCESS
+	/**
+	 * Gives the lexicon size of an attribute.
+	 *
+	 * @param attribute the attribute
+	 * @return the int
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 * @returns the number of entries in the lexicon of a positional attribute
+	 */
+	@Override
+	public abstract int lexiconSize(String attribute) throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Drop attribute.
+	 *
+	 * @param attribute the attribute
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public abstract void dropAttribute(String attribute) throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Converts an array of attribute values to their ID.
+	 *
+	 * @param attribute the attribute
+	 * @param strings the values
+	 * @return the IDs
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public abstract int[] str2Id(String attribute, String[] strings) throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Converts an array of attribute ID to their values.
+	 *
+	 * @param attribute the attribute
+	 * @param ids the ids
+	 * @return the values
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public abstract String[] id2Str(String attribute, int[] ids) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Converts an array of attribute IDs to their frequency.
+	 *
+	 * @param attribute the attribute
+	 * @param ids the ids
+	 * @return the frequencies
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public abstract int[] id2Freq(String attribute, int[] ids) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Converts an array of position to their ID given an attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the positions
+	 * @return the IDs
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError Signals that the cqi server raised an error
+	 */
+	@Override
+	public abstract int[] cpos2Id(String attribute, int[] cpos) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Converts an array of position to their value given an attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the cpos
+	 * @return the values
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public abstract String[] cpos2Str(String attribute, int[] cpos) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Computes for each position of an array the Id of the enclosing structural
+	 * attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the positions
+	 * @return the IDs
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public abstract int[] cpos2Struc(String attribute, int[] cpos) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Computes for each position of an array the position of the left boundary
+	 * of the enclosing structural attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the cpos
+	 * @return the positions of the left boundaries
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public abstract int[] cpos2LBound(String attribute, int[] cpos) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Computes for each position of an array the position of the right boundary
+	 * of the enclosing structural attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the cpos
+	 * @return the positions of the right boundaries
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public abstract int[] cpos2RBound(String attribute, int[] cpos) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Computes for each position of an array the Id of the enclosing alignment
+	 * attribute.
+	 *
+	 * @param attribute the attribute
+	 * @param cpos the cpos
+	 * @return the int[]
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public abstract int[] cpos2Alg(String attribute, int[] cpos) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Retrieves annotated string values of structure regions in <strucs>; "" if
+	 * out of range.
+	 *
+	 * @param attribute the attribute
+	 * @param strucs the strucs
+	 * @return the string[]
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public abstract String[] struc2Str(String attribute, int[] strucs) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Retrieves all corpus positions where the given token occurs.
+	 *
+	 * @param attribute the attribute
+	 * @param id the id
+	 * @return the position
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public abstract int[] id2Cpos(String attribute, int id) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Retrieves all corpus positions where one of the tokens in <id_list>
+	 * occurs; the returned list is sorted as a whole, not per token id.
+	 *
+	 * @param attribute the attribute
+	 * @param ids the ids
+	 * @return the positions
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public abstract int[] idList2Cpos(String attribute, int[] ids) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Retrieves the lexicon IDs of all tokens that match <regex>; the returned
+	 * list may be empty (size 0).
+	 *
+	 * @param attribute the attribute
+	 * @param regex the regex
+	 * @return the IDs
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public abstract int[] regex2Id(String attribute, String regex) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Retrieves the start and end corpus positions of structure region <struc>.
+	 *
+	 * @param attribute the attribute
+	 * @param struc the struc
+	 * @return an array of size 2 containing the start and end positions
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public abstract int[] struc2Cpos(String attribute, int struc) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Retrieves start and end corpus positions of an alignement region in the
+	 * source and target corpora<struc>.
+	 *
+	 * @param attribute the attribute
+	 * @param struc the struc
+	 * @return an array of size 4 containing (src_start, src_end, target_start,
+	 * target_end)
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public abstract int[] alg2Cpos(String attribute, int struc) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Runs a CQP query.
+	 *
+	 * @param motherCorpus the mother corpus
+	 * @param subcorpus the subcorpus
+	 * @param query the query
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError the cqi server error
+	 */
+	@Override
+	public abstract void cqpQuery(String motherCorpus, String subcorpus, String query) throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Lists all the subcorpora of a corpus.
+	 *
+	 * @param corpus the corpus
+	 * @return the name of the subcorpora
+	 * @throws UnexpectedAnswerException Signals that the data read on the socket is unexpected
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 * @throws CqiCqpErrorNoSuchCorpus the cqi cqp error no such corpus
+	 */
+	@Override
+	public abstract String[] listSubcorpora(String corpus) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	/**
+	 * Gives the size of a subcorpus .
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * 
+	 * @return the size
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	@Override
+	public abstract int subCorpusSize(String subcorpus) throws IOException,
+	UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Checks wether a subcorpus has a field.
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * @param field
+	 *            the field
+	 * 
+	 * @return true, if the subcorpus has the field
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	@Override
+	public abstract boolean subCorpusHasField(String subcorpus, byte field) throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Dumps the values of <field> for match ranges <first> .. <last> in
+	 * <subcorpus>. <field> is one of the CQI_CONST_FIELD_* constants.
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * @param field
+	 *            the field
+	 * @param first
+	 *            the first
+	 * @param last
+	 *            the last
+	 * 
+	 * @return the values
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	@Override
+	public abstract int[] dumpSubCorpus(String subcorpus, byte field, int first, int last) throws IOException, UnexpectedAnswerException,
+	CqiServerError;
+
+	/**
+	 * Drops a subcorpus.
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	@Override
+	public abstract void dropSubCorpus(String subcorpus) throws IOException,
+	UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Returns <n> (id, frequency) pairs flattened into a list of size 2*<n> NB:
+	 * pairs are sorted by frequency desc.
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * @param cutoff
+	 *            the cutoff
+	 * @param field
+	 *            the field : one of CQI_CONST_FIELD_MATCH,
+	 *            CQI_CONST_FIELD_TARGET, CQI_CONST_FIELD_KEYWORD
+	 * @param attribute
+	 *            the attribute
+	 * 
+	 * @return the int[][]
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	@Override
+	public abstract int[][] fdist1(String subcorpus, int cutoff,
+			byte field, String attribute) throws IOException,
+			UnexpectedAnswerException, CqiServerError;
+
+	/**
+	 * Returns <n> (id1, id2, frequency) pairs flattened into a list of size
+	 * 3*<n> NB: triples are sorted by frequency desc. .
+	 * 
+	 * @param subcorpus
+	 *            the subcorpus
+	 * @param cutoff
+	 *            the cutoff
+	 * @param field1
+	 *            the field1
+	 * @param attribute1
+	 *            the attribute1
+	 * @param field2
+	 *            the field2
+	 * @param attribute2
+	 *            the attribute2
+	 * 
+	 * @return the int[]
+	 * 
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws UnexpectedAnswerException
+	 *             Signals that the data read on the socket is unexpected
+	 * @throws CqiServerError
+	 *             the cqi server error
+	 */
+	@Override
+	public abstract int[][] fdist2(String subcorpus, int cutoff,
+			byte field1, String attribute1, byte field2, String attribute2) throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	@Override
+	public abstract boolean reconnect() ;
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/ServerNotFoundException.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/ServerNotFoundException.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/ServerNotFoundException.java	(revision 449)
@@ -0,0 +1,75 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.clientExceptions;
+
+import java.io.IOException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Thrown to indicates that client do not find the server.
+ *
+ * @author Jean-Philippe Magué
+ */
+public class ServerNotFoundException extends CqiClientException {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Instantiates a new server not found exception.
+	 * 
+	 * @param string
+	 *            the message
+	 * @param e
+	 *            the cause
+	 */
+	public ServerNotFoundException(String string, IOException e) {
+		super(string, e);
+	}
+
+	/**
+	 * Instantiates a new server not found exception.
+	 * 
+	 * @param string
+	 *            the message
+	 */
+	public ServerNotFoundException(String string) {
+		super(string);
+	}
+
+	/**
+	 * Instantiates a new server not found exception.
+	 * 
+	 * @param e
+	 *            the cause
+	 */
+	public ServerNotFoundException(Throwable e) {
+		super(e);
+	}
+
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/UnexpectedAnswerException.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/UnexpectedAnswerException.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/UnexpectedAnswerException.java	(revision 449)
@@ -0,0 +1,80 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.clientExceptions;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Thrown to indicates that client recieved unexpected data from the server.
+ *
+ * @author Jean-Philippe Magué
+ */
+public class UnexpectedAnswerException extends CqiClientException {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Instantiates a new unexpected answer exception.
+	 */
+	public UnexpectedAnswerException() {
+		super();
+	}
+
+	/**
+	 * Instantiates a new unexpected answer exception.
+	 * 
+	 * @param arg0
+	 *            the message
+	 */
+	public UnexpectedAnswerException(String arg0) {
+		super(arg0);
+	}
+
+	/**
+	 * Instantiates a new unexpected answer exception.
+	 * 
+	 * @param arg0
+	 *            the cause
+	 */
+	public UnexpectedAnswerException(Throwable arg0) {
+		super(arg0);
+	}
+
+	/**
+	 * Instantiates a new unexpected answer exception.
+	 * 
+	 * @param arg0
+	 *            the message
+	 * @param arg1
+	 *            the cause
+	 */
+	public UnexpectedAnswerException(String arg0, Throwable arg1) {
+		super(arg0, arg1);
+	}
+
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/InvalidCqpIdException.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/InvalidCqpIdException.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/InvalidCqpIdException.java	(revision 449)
@@ -0,0 +1,77 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.clientExceptions;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class InvalidCqpIdException.
+ */
+public class InvalidCqpIdException extends Exception {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Instantiates a new invalid cqp id exception.
+	 */
+	public InvalidCqpIdException() {
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Instantiates a new invalid cqp id exception.
+	 *
+	 * @param arg0 the arg0
+	 */
+	public InvalidCqpIdException(String arg0) {
+		super(arg0);
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Instantiates a new invalid cqp id exception.
+	 *
+	 * @param arg0 the arg0
+	 */
+	public InvalidCqpIdException(Throwable arg0) {
+		super(arg0);
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Instantiates a new invalid cqp id exception.
+	 *
+	 * @param arg0 the arg0
+	 * @param arg1 the arg1
+	 */
+	public InvalidCqpIdException(String arg0, Throwable arg1) {
+		super(arg0, arg1);
+		// TODO Auto-generated constructor stub
+	}
+
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/CqiClientException.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/CqiClientException.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/CqiClientException.java	(revision 449)
@@ -0,0 +1,94 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.clientExceptions;
+
+import org.txm.Toolbox;
+import org.txm.searchengine.cqp.CQPEngine;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Base class for the Exception raised by the CQi client itself (i.e. not
+ * recieved from the CQi server)
+ * 
+ * @author Jean-Philippe Magué
+ */
+public class CqiClientException extends Exception {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Instantiates a new cqi client exception.
+	 * 
+	 * @param message
+	 *            the message
+	 */
+	public CqiClientException(String message) {
+		super(message);
+	}
+
+	static int counter = 0;
+	/**
+	 * Instantiates a new cqi client exception.
+	 * 
+	 * @param cause
+	 *            the cause
+	 */
+	public CqiClientException(Throwable cause) {
+		super(cause);
+		if(cause instanceof java.net.SocketException){
+			if (counter++ < 5) {
+				//if(!CQPEngine.getCqiClient().reconnect()) CQPEngine.restart();
+			}
+		}
+	}
+
+	/**
+	 * Instantiates a new cqi client exception.
+	 * 
+	 * @param message
+	 *            the message
+	 * @param cause
+	 *            the cause
+	 */
+	public CqiClientException(String message, Throwable cause) {
+		super(message, cause);
+		if (cause instanceof java.net.SocketException)
+		{
+			//if(!CQPEngine.getCqiClient().reconnect()) CQPEngine.restart();
+		}
+	}
+
+	/**
+	 * Instantiates a new cqi client exception.
+	 */
+	public CqiClientException() {
+		super();
+	}
+
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/package.html
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/package.html	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/package.html	(revision 449)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>Exception during communication between the cqp server and the cqp client.</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/clientExceptions/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/MemCqiServer.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/MemCqiServer.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/MemCqiServer.java	(revision 449)
@@ -0,0 +1,1098 @@
+// 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: 2011-12-14 10:52:18 +0100 (mer., 14 déc. 2011) $
+// $LastChangedRevision: 2080 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.lang.reflect.Field;
+import java.util.Arrays;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+import org.txm.Toolbox;
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.core.preferences.TBXPreferences;
+import org.txm.searchengine.cqp.clientExceptions.ServerNotFoundException;
+import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
+import org.txm.searchengine.cqp.serverException.CqiCqpErrorNoSuchCorpus;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
+import org.txm.utils.ExecTimer;
+import org.txm.utils.logger.Log;
+
+// TODO: Auto-generated Javadoc
+/**
+ * This class aims at handling a CQi server process. It is not a CQi server per
+ * se.
+ * 
+ * @author Jean-Philippe Magué
+ */
+public class MemCqiServer extends AbstractCqiServer {
+
+	/**
+	 * Instantiates a new CQi server.
+	 * 
+	 * @param pathToExecutable
+	 *            the path to the executable
+	 * @param pathToRegistry
+	 *            the path to the registry
+	 * @param pathToInitFile
+	 *            the path to the init file
+	 * 
+	 * @throws ServerNotFoundException
+	 *             the server not found exception
+	 */
+	public MemCqiServer(String pathToExecutable, String pathToRegistry,
+			String pathToInitFile) throws ServerNotFoundException {
+		this(pathToExecutable, pathToRegistry, pathToInitFile, ""); //$NON-NLS-1$
+	}
+
+	/**
+	 ** Instantiates a new CQi server.
+	 * 
+	 * @param pathToExecutable
+	 *            the path to the executable
+	 * @param pathToRegistry
+	 *            the path to the registry
+	 * @param pathToInitFile
+	 *            the path to the init file
+	 * @param additionalOptions
+	 *            the additional command line options
+	 * 
+	 * @throws ServerNotFoundException
+	 *             the server not found exception
+	 */
+	public MemCqiServer(String pathToExecutable, String pathToRegistry,
+			String pathToInitFile, String additionalOptions)
+					throws ServerNotFoundException {
+
+	}
+
+	/** The path to executable. */
+	String pathToExecutable;
+
+	/** The path to registry. */
+	String pathToRegistry;
+
+	/** The path to init file. */
+	String pathToInitFile;
+
+	/** The additional options. */
+	String additionalOptions;
+
+	/** The monitor output. */
+	boolean monitorOutput;
+
+	/** The cmd line. */
+	static String[] cmdLine;
+	public boolean debug = false;
+
+	public void setDebug(boolean val)
+	{
+		debug = val;
+	}
+
+	public native int getErrorCode();
+
+
+	/**
+	 * Instantiates a new cqi server.
+	 *
+	 * @param pathToExecutable the path to executable
+	 * @param pathToRegistry the path to registry
+	 * @param pathToInitFile the path to init file
+	 * @param additionalOptions the additional options
+	 * @param monitorOutput the monitor output
+	 * @throws Exception 
+	 */
+	public MemCqiServer(String pathToExecutable, String pathToRegistry,
+			String pathToInitFile, String additionalOptions,
+			boolean monitorOutput) throws Exception {
+
+		this.pathToExecutable = pathToExecutable;
+		this.pathToRegistry = pathToRegistry;
+		this.pathToInitFile = pathToInitFile;
+		this.additionalOptions = additionalOptions;
+		this.monitorOutput = monitorOutput;
+
+		if (!isLoaded) {
+			
+			Field LIBRARIES = ClassLoader.class.getDeclaredField("loadedLibraryNames");
+			LIBRARIES.setAccessible(true);
+			
+			try {
+				String path = System.getProperty("java.library.path");
+				String libpath = System.getProperty("path.separator")+Toolbox.getParam(TBXPreferences.CQI_SERVER_PATH_TO_CQPLIB);
+				if (!path.contains(libpath)) {
+					path += libpath;
+				}
+				System.setProperty("java.library.path", path);
+				//System.out.println("Current java.library.path "+System.getProperty("java.library.path"));
+
+				// this is a hack to force the JVM to reload java.library.path
+				Field fieldSysPath = ClassLoader.class.getDeclaredField( "sys_paths" );
+				fieldSysPath.setAccessible( true );
+				fieldSysPath.set( null, null );
+				
+				System.loadLibrary("cqpjni");
+				Log.info("cqpjni loaded from dirs "+path);
+				isLoaded = true;
+
+			} catch (Throwable e) {
+				System.err.println("Failed to load CQP lib with exception: "+e);
+				System.err.println("Looking for Cqi libs in : "+System.getProperty("java.library.path")); 
+				System.err.println("Current directory: "+new File(".").getAbsolutePath());
+				throw new Exception(e);
+			}
+		}
+	}
+
+	/**
+	 * Gets the last cmd line.
+	 *
+	 * @return the last cmd line
+	 */
+
+	public String getLastCmdLine() {
+		return StringUtils.join(cmdLine, " "); //$NON-NLS-1$
+	}
+
+	/**
+	 * Start.
+	 *
+	 * @return true, if successful
+	 */
+	public Boolean start() {
+		String[] cmd = { pathToExecutable, "-I", pathToInitFile, "-r", pathToRegistry }; //$NON-NLS-1$ //$NON-NLS-2$
+		cmdLine = (String[]) ArrayUtils.addAll(cmd, additionalOptions.trim().split(" ")); //$NON-NLS-1$
+		Log.info("Starting NullSearchEngineServer: "+Arrays.toString(cmdLine)+" ... ");
+
+		//try {
+			isLoaded = start(cmdLine);
+			//System.out.println("IS LOADED: "+isLoaded);
+			if (isLoaded) {
+				System.out.println(TXMCoreMessages.CqiClient_34);
+			} else {
+				System.out.println("Failed to start SearchEngine in memory mode.");
+			}
+			return isLoaded;
+//		} catch(Exception e) {
+//			System.out.println("Failed to start MemCqiServer: "+e+ " (error code: "+getErrorCode()+")");
+//			return false;
+//		}
+	}
+
+	/**
+	 * Convert stream to string.
+	 *
+	 * @param is the is
+	 * @return the string
+	 */
+
+	public String convertStreamToString(InputStream is) {
+		BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+		StringBuilder sb = new StringBuilder();
+		String line = null;
+		try {
+			while ((line = reader.readLine()) != null) {
+				sb.append(line);
+			}
+		} catch (IOException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} finally {
+			try {
+				is.close();
+			} catch (IOException e) {
+				org.txm.utils.logger.Log.printStackTrace(e);
+			}
+		}
+
+		return sb.toString();
+	}
+
+	/**
+	 * Checks if the server is running.
+	 * 
+	 * @return true, if is running
+	 */
+
+	public Boolean isRunning() {
+		return isLoaded;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#finalize()
+	 */
+	protected void finalize() throws Throwable {
+
+	}
+
+	/**
+	 * Gets the error stream.
+	 *
+	 * @return the error stream
+	 */
+
+	public InputStream getErrorStream() {
+		return null;
+	}
+
+	/**
+	 * Gets the input stream.
+	 *
+	 * @return the input stream
+	 */
+
+	public InputStream getInputStream() {
+		return new InputStream() {
+			public int read() throws IOException {
+				return 0;
+			}
+		};
+	}
+
+	/**
+	 * Gets the output stream.
+	 *
+	 * @return the output stream
+	 */
+
+	public OutputStream getOutputStream() {
+		return new OutputStream() {
+			public void write(int arg0) throws IOException {
+			}
+		};
+	}
+
+	static Boolean isLoaded = false;
+
+	public native Boolean start(String[] args);
+
+	public native Boolean stop();
+
+	public native int[] alg2Cpos(String arg0, int arg1) throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	public native Integer attributeSize(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError ;
+
+	public boolean connect(String arg0, String arg1) { return true;} ;
+
+	public native String[] corpusAlignementAttributes(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native String corpusCharset(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native String corpusFullName(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native String[] corpusInfo(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native String[] corpusPositionalAttributes(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native String[] corpusProperties(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native Boolean corpusStructuralAttributeHasValues(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native String[] corpusStructuralAttributes(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native int[] cpos2Alg(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native int[] cpos2Id(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native int[] cpos2LBound(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native int[] cpos2RBound(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native String[] cpos2Str(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native int[] cpos2Struc(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native Boolean cqpQuery(String arg0, String arg1, String arg2)
+			throws IOException, UnexpectedAnswerException, CqiServerError ;
+
+	public native Boolean query(String arg0)
+			throws IOException, UnexpectedAnswerException, CqiServerError ;
+
+	public Boolean disconnect() { return true; };
+
+	public native Boolean dropAttribute(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError ;
+
+	public native Boolean dropCorpus(String arg0) throws Exception ;
+
+	public native Boolean dropSubCorpus(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError ;
+
+	public native int[] dumpSubCorpus(String arg0, byte arg1, int arg2, int arg3)
+			throws IOException, UnexpectedAnswerException, CqiServerError ;
+
+	public int[][] fdist1(String arg0, int arg1, byte arg2, String arg3)
+			throws IOException, UnexpectedAnswerException, CqiServerError {
+		int[] all = nfdist1(arg0, arg1, arg2, arg3);
+		if (all == null) {
+			return new int[0][0];
+		}
+		int[][] freqs = new int[all.length / 2][2];
+		int c = 0;
+		for (int i = 0 ; i < freqs.length ;i++) {
+			freqs[i][0] = all[c++];
+			freqs[i][1] = all[c++];
+		}
+		return freqs;
+
+	}
+
+	public native int[] nfdist1(String arg0, int arg1, byte arg2, String arg3)
+			throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	public int[][] fdist2(String arg0, int arg1, byte arg2, String arg3,
+			byte arg4, String arg5) throws IOException,
+			UnexpectedAnswerException, CqiServerError {
+		int[] all = nfdist2(arg0, arg1, arg2, arg3, arg4, arg5);
+		if (all == null) {
+			return new int[0][0];
+		}
+		int[][] freqs = new int[all.length / 2][3];
+		int c = 0;
+		for (int i = 0 ; i < freqs.length ; i++) {
+			freqs[i][0] = all[c++];
+			freqs[i][1] = all[c++];
+			freqs[i][2] = all[c++];
+		}
+		return freqs;
+	}
+
+	public native int[] nfdist2(String arg0, int arg1, byte arg2, String arg3,
+			byte arg4, String arg5) throws IOException, UnexpectedAnswerException, CqiServerError;
+
+	public native String getLastCQPError() ;
+
+	public native String getLastCqiError() throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	public native int[] id2Cpos(String arg0, int arg1) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native int[] id2Freq(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native String[] id2Str(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native int[] idList2Cpos(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native Integer lexiconSize(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError ;
+
+	public native String[] listCorpora() throws UnexpectedAnswerException, IOException, CqiServerError;
+
+	public native String[] listSubcorpora(String arg0) throws UnexpectedAnswerException, IOException, CqiCqpErrorNoSuchCorpus ;
+
+	public Boolean reconnect() { return true; } ;
+
+	public native int[] regex2Id(String arg0, String arg1) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native int[] str2Id(String arg0, String[] arg1) throws IOException, UnexpectedAnswerException, CqiServerError ;
+
+	public native int[] struc2Cpos(String arg0, int arg1) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native String[] struc2Str(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError ;
+
+	public native Boolean subCorpusHasField(String arg0, byte arg1) throws IOException, UnexpectedAnswerException, CqiServerError ;
+
+	public native Integer subCorpusSize(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError ;
+
+	/**
+	 * @param args
+	 * @throws Exception 
+	 */
+	public static void main(String[] args) throws Exception {
+		String pathToExecutable = "/home/mdecorde/workspace37/CWB-lib/src/cqp/";
+		String cqpserverPathToExecutable = "/home/mdecorde/workspace37/CWB-lib/src/cqp/cqpserver";
+		String pathToRegistry = "/home/mdecorde/TXM/registry";
+		String pathToInitFile = "/usr/lib/TXM/cwb/cqpserver.init";
+
+		String corpus = "DISCOURS";
+		String subcorpusname = "SUB";
+		String subcorpusid = corpus+":"+subcorpusname;
+		String query = "[word=\"j.*\"]";
+		String regex = "j.*";
+		String pattribute1 = corpus+".word";
+		String pattribute2 = corpus+".frpos";
+		String pattribute3 = corpus+".frlemma";
+		String sattribute1 = corpus+".text_id";
+		String sattribute2 = corpus+".p_id";
+		String sattribute3 = corpus+".s_id";
+
+		String align_attr = "p_id";
+
+		int[] cpos = {0,10000,2,3,4,5,6,7,8,9,10};
+		//	int id = 1;
+		int[] ids = {0,1,2,3,4,5,6,7,8,9,10};
+		String[] strings = {"je", "jamais"};
+		int[] strucpos = {0, 1, 2, 3 , 4};
+
+		Toolbox.setParam(TBXPreferences.CQI_SERVER_PATH_TO_CQPLIB, pathToExecutable);
+
+		MemCqiServer server = new MemCqiServer(pathToExecutable, pathToRegistry, pathToInitFile, " -b 10000000 -d OFF", false);
+		if (server.start()) System.out.println("Mem Server ok");
+		MemCqiClient client = new MemCqiClient(server);
+		if (client.connect("anonymous", "")) System.out.println("Mem Client ok");
+
+		NetCqiServer netServer = new NetCqiServer(cqpserverPathToExecutable, pathToRegistry, pathToInitFile, "", false);
+		if (netServer.start()) System.out.println("Net Server ok");
+		NetCqiClient netClient = new NetCqiClient("127.0.0.1", 4877);
+		if (netClient.connect("anonymous", "")) System.out.println("Net Client ok");
+
+		ExecTimer.start();
+
+		try {
+			System.out.println("client.alg2Cpos(sattribute, struct_id) : "+Arrays.toString(client.alg2Cpos(sattribute1, 0)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.alg2Cpos(sattribute, struct_id) : "+Arrays.toString(netClient.alg2Cpos(sattribute1, 0)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.attributeSize(sattribute1) : "+client.attributeSize(sattribute1));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.attributeSize(sattribute1) : "+netClient.attributeSize(sattribute1));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+
+		try {
+			System.out.println("client.attributeSize(sattribute2) : "+client.attributeSize(sattribute2));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.attributeSize(sattribute2) : "+netClient.attributeSize(sattribute2));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+
+		try {
+			System.out.println("client.attributeSize(sattribute3) : "+client.attributeSize(sattribute3));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.attributeSize(sattribute3) : "+netClient.attributeSize(sattribute3));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+
+		try {
+			System.out.println("client.corpusAlignementAttributes(corpus) : "+Arrays.toString(client.corpusAlignementAttributes(corpus)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.corpusAlignementAttributes(corpus) : "+Arrays.toString(netClient.corpusAlignementAttributes(corpus)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.corpusCharset(corpus) : "+client.corpusCharset(corpus));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.corpusCharset(corpus) : "+netClient.corpusCharset(corpus));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+
+		try {
+			System.out.println("client.corpusFullName(corpus) : "+client.corpusFullName(corpus));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.corpusFullName(corpus) : "+netClient.corpusFullName(corpus));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.corpusInfo(corpus) : "+client.corpusInfo(corpus));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.corpusInfo(corpus) : "+netClient.corpusInfo(corpus));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+
+		try {
+			System.out.println("client.corpusPositionalAttributes(corpus) : "+Arrays.toString(client.corpusPositionalAttributes(corpus)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.corpusPositionalAttributes(corpus) : "+Arrays.toString(netClient.corpusPositionalAttributes(corpus)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+
+		try {
+			System.out.println("client.corpusProperties(corpus) : "+Arrays.toString(client.corpusProperties(corpus)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.corpusProperties(corpus) : "+Arrays.toString(netClient.corpusProperties(corpus)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+
+		try {
+			System.out.println("client.corpusStructuralAttributeHasValues(sattribute1) : "+client.corpusStructuralAttributeHasValues(sattribute1));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.corpusStructuralAttributeHasValues(sattribute1) : "+netClient.corpusStructuralAttributeHasValues(sattribute1));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.corpusStructuralAttributeHasValues(sattribute2) : "+client.corpusStructuralAttributeHasValues(sattribute2));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.corpusStructuralAttributeHasValues(sattribute2) : "+netClient.corpusStructuralAttributeHasValues(sattribute2));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.corpusStructuralAttributeHasValues(sattribute3) : "+client.corpusStructuralAttributeHasValues(sattribute3));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.corpusStructuralAttributeHasValues(sattribute3) : "+netClient.corpusStructuralAttributeHasValues(sattribute3));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.corpusStructuralAttributes(corpus) : "+Arrays.toString(client.corpusStructuralAttributes(corpus)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.corpusStructuralAttributes(corpus) : "+Arrays.toString(netClient.corpusStructuralAttributes(corpus)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2Alg(align_attr, cpos) : "+Arrays.toString(client.cpos2Alg(align_attr, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2Alg(align_attr, cpos) : "+Arrays.toString(netClient.cpos2Alg(align_attr, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2Id(pattribute1, cpos) : "+Arrays.toString(client.cpos2Id(pattribute1, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2Id(pattribute1, cpos) : "+Arrays.toString(netClient.cpos2Id(pattribute1, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2Id(pattribute2, cpos) : "+Arrays.toString(client.cpos2Id(pattribute2, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2Id(pattribute2, cpos) : "+Arrays.toString(netClient.cpos2Id(pattribute2, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2Id(pattribute3, cpos) : "+Arrays.toString(client.cpos2Id(pattribute3, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2Id(pattribute3, cpos) : "+Arrays.toString(netClient.cpos2Id(pattribute3, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2LBound(sattribute1, cpos) : "+Arrays.toString(client.cpos2LBound(sattribute1, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2LBound(sattribute1, cpos) : "+Arrays.toString(netClient.cpos2LBound(sattribute1, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2LBound(sattribute2, cpos) : "+Arrays.toString(client.cpos2LBound(sattribute2, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2LBound(sattribute2, cpos) : "+Arrays.toString(netClient.cpos2LBound(sattribute2, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2LBound(sattribute3, cpos) : "+Arrays.toString(client.cpos2LBound(sattribute3, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2LBound(sattribute3, cpos) : "+Arrays.toString(netClient.cpos2LBound(sattribute3, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2RBound(sattribute1, cpos) : "+Arrays.toString(client.cpos2RBound(sattribute1, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2RBound(sattribute1, cpos) : "+Arrays.toString(netClient.cpos2RBound(sattribute1, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2RBound(sattribute2, cpos) : "+Arrays.toString(client.cpos2RBound(sattribute2, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2RBound(sattribute2, cpos) : "+Arrays.toString(netClient.cpos2RBound(sattribute2, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2RBound(sattribute3, cpos) : "+Arrays.toString(client.cpos2RBound(sattribute3, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2RBound(sattribute3, cpos) : "+Arrays.toString(netClient.cpos2RBound(sattribute3, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2Str(pattribute1, cpos) : "+Arrays.toString(client.cpos2Str(pattribute1, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2Str(pattribute1, cpos) : "+Arrays.toString(netClient.cpos2Str(pattribute1, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2Str(pattribute2, cpos) : "+Arrays.toString(client.cpos2Str(pattribute2, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2Str(pattribute2, cpos) : "+Arrays.toString(netClient.cpos2Str(pattribute2, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2Str(pattribute3, cpos) : "+Arrays.toString(client.cpos2Str(pattribute3, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2Str(pattribute3, cpos) : "+Arrays.toString(netClient.cpos2Str(pattribute3, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2Struc(sattribute1, cpos) : "+Arrays.toString(client.cpos2Struc(sattribute1, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2Struc(sattribute1, cpos) : "+Arrays.toString(netClient.cpos2Struc(sattribute1, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2Struc(sattribute2, cpos) : "+Arrays.toString(client.cpos2Struc(sattribute2, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2Struc(sattribute2, cpos) : "+Arrays.toString(netClient.cpos2Struc(sattribute2, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cpos2Struc(sattribute3, cpos) : "+Arrays.toString(client.cpos2Struc(sattribute3, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cpos2Struc(sattribute3, cpos) : "+Arrays.toString(netClient.cpos2Struc(sattribute3, cpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.cqpQuery(corpus, subcorpus, query)");client.cqpQuery(corpus, subcorpusname, query);
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.cqpQuery(corpus, subcorpus, query)");netClient.cqpQuery(corpus, subcorpusname, query);
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.dropAttribute(pattribute1)");client.dropAttribute(pattribute1);
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.dropAttribute(pattribute1)");netClient.dropAttribute(pattribute1);
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.dropAttribute(pattribute2)");client.dropAttribute(pattribute2);
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.dropAttribute(pattribute2)");netClient.dropAttribute(pattribute2);
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.dropAttribute(pattribute3)");client.dropAttribute(pattribute3);
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.dropAttribute(pattribute3)");netClient.dropAttribute(pattribute3);
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.dropCorpus(corpus)");client.dropCorpus(corpus);
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.dropCorpus(corpus)");netClient.dropCorpus(corpus);
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.dumpSubCorpus(subcorpus, CQI_CONST_FIELD_MATCH, 1, 2) : "+Arrays.toString(client.dumpSubCorpus(subcorpusid, NetCqiClient.CQI_CONST_FIELD_MATCH, 1, 10)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.dumpSubCorpus(subcorpus, CQI_CONST_FIELD_MATCH, 1, 2) : "+Arrays.toString(netClient.dumpSubCorpus(subcorpusid, NetCqiClient.CQI_CONST_FIELD_MATCH, 1, 10)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.dumpSubCorpus(subcorpus, CQI_CONST_FIELD_MATCHEND, 1, 2) : "+Arrays.toString(client.dumpSubCorpus(subcorpusid, NetCqiClient.CQI_CONST_FIELD_MATCHEND, 1, 10)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.dumpSubCorpus(subcorpus, CQI_CONST_FIELD_MATCHEND, 1, 2) : "+Arrays.toString(netClient.dumpSubCorpus(subcorpusid, NetCqiClient.CQI_CONST_FIELD_MATCHEND, 1, 10)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		//		try {
+		//			System.out.println("client.fdist1(arg0, arg1, arg2, arg3) : "+client.fdist1(arg0, arg1, arg2, arg3));
+		//		} catch(Exception e) { System.out.println("Exception : "+e);}
+		//		try {
+		//			System.out.println("netClient.fdist1(arg0, arg1, arg2, arg3) : "+netClient.fdist1(arg0, arg1, arg2, arg3));
+		//		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		//		try {
+		//			System.out.println("//client.fdist2(arg0, arg1, arg2, arg3, arg4, arg5) : "+client.fdist2(arg0, arg1, arg2, arg3, arg4, arg5));
+		//		} catch(Exception e) { System.out.println("Exception : "+e);}
+		//		try {
+		//			System.out.println("//netClient.fdist2(arg0, arg1, arg2, arg3, arg4, arg5) : "+netClient.fdist2(arg0, arg1, arg2, arg3, arg4, arg5));
+		//		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.getLastCqiError() : "+client.getLastCqiError());
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.getLastCqiError() : "+netClient.getLastCqiError());
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.getLastCQPError() : "+client.getLastCQPError());
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.getLastCQPError() : "+netClient.getLastCQPError());
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.id2Cpos(pattribute1, 0) : "+Arrays.toString(client.id2Cpos(pattribute1, 0)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.id2Cpos(pattribute1, 0) : "+Arrays.toString(netClient.id2Cpos(pattribute1, 0)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.id2Cpos(pattribute2, 0) : "+Arrays.toString(client.id2Cpos(pattribute2, 0)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.id2Cpos(pattribute2, 0) : "+Arrays.toString(netClient.id2Cpos(pattribute2, 0)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.id2Cpos(pattribute3, 0) : "+Arrays.toString(client.id2Cpos(pattribute3, 0)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.id2Cpos(pattribute3, 0) : "+Arrays.toString(netClient.id2Cpos(pattribute3, 0)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.id2Cpos(pattribute1, 1) : "+Arrays.toString(client.id2Cpos(pattribute1, 1)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.id2Cpos(pattribute1, 1) : "+Arrays.toString(netClient.id2Cpos(pattribute1, 1)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.id2Cpos(pattribute2, 1) : "+Arrays.toString(client.id2Cpos(pattribute2, 1)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.id2Cpos(pattribute2, 1) : "+Arrays.toString(netClient.id2Cpos(pattribute2, 1)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.id2Cpos(pattribute3, 1) : "+Arrays.toString(client.id2Cpos(pattribute3, 1)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.id2Cpos(pattribute3, 1) : "+Arrays.toString(netClient.id2Cpos(pattribute3, 1)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.id2Cpos(pattribute1, 2) : "+Arrays.toString(client.id2Cpos(pattribute1, 2)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.id2Cpos(pattribute1, 2) : "+Arrays.toString(netClient.id2Cpos(pattribute1, 2)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.id2Cpos(pattribute2, 2) : "+Arrays.toString(client.id2Cpos(pattribute2, 2)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.id2Cpos(pattribute2, 2) : "+Arrays.toString(netClient.id2Cpos(pattribute2, 2)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.id2Cpos(pattribute3, 2) : "+Arrays.toString(client.id2Cpos(pattribute3, 2)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.id2Cpos(pattribute3, 2) : "+Arrays.toString(netClient.id2Cpos(pattribute3, 2)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.id2Freq(pattribute1, ids) : "+Arrays.toString(client.id2Freq(pattribute1, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.id2Freq(pattribute1, ids) : "+Arrays.toString(netClient.id2Freq(pattribute1, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.id2Freq(pattribute2, ids) : "+Arrays.toString(client.id2Freq(pattribute2, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.id2Freq(pattribute2, ids) : "+Arrays.toString(netClient.id2Freq(pattribute2, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.id2Freq(pattribute3, ids) : "+Arrays.toString(client.id2Freq(pattribute3, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.id2Freq(pattribute3, ids) : "+Arrays.toString(netClient.id2Freq(pattribute3, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.id2Str(pattribute1, ids) : "+Arrays.toString(client.id2Str(pattribute1, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.id2Str(pattribute1, ids) : "+Arrays.toString(netClient.id2Str(pattribute1, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.id2Str(pattribute2, ids) : "+Arrays.toString(client.id2Str(pattribute2, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.id2Str(pattribute2, ids) : "+Arrays.toString(netClient.id2Str(pattribute2, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.id2Str(pattribute3, ids) : "+Arrays.toString(client.id2Str(pattribute3, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.id2Str(pattribute3, ids) : "+Arrays.toString(netClient.id2Str(pattribute3, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.idList2Cpos(pattribute1, ids) : "+Arrays.toString(client.idList2Cpos(pattribute1, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.idList2Cpos(pattribute1, ids) : "+Arrays.toString(netClient.idList2Cpos(pattribute1, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.idList2Cpos(pattribute2, ids) : "+Arrays.toString(client.idList2Cpos(pattribute2, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.idList2Cpos(pattribute2, ids) : "+Arrays.toString(netClient.idList2Cpos(pattribute2, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.idList2Cpos(pattribute3, ids) : "+Arrays.toString(client.idList2Cpos(pattribute3, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.idList2Cpos(pattribute3, ids) : "+Arrays.toString(netClient.idList2Cpos(pattribute3, ids)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.lexiconSize(pattribute1) : "+client.lexiconSize(pattribute1));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.lexiconSize(pattribute1) : "+netClient.lexiconSize(pattribute1));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.lexiconSize(pattribute2) : "+client.lexiconSize(pattribute2));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.lexiconSize(pattribute2) : "+netClient.lexiconSize(pattribute2));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.lexiconSize(pattribute3) : "+client.lexiconSize(pattribute3));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.lexiconSize(pattribute3) : "+netClient.lexiconSize(pattribute3));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.listCorpora() : "+Arrays.toString(client.listCorpora()));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.listCorpora() : "+Arrays.toString(netClient.listCorpora()));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.listSubcorpora(corpus) : "+Arrays.toString(client.listSubcorpora(corpus)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.listSubcorpora(corpus) : "+Arrays.toString(netClient.listSubcorpora(corpus)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.regex2Id(pattribute1, regex) : "+Arrays.toString(client.regex2Id(pattribute1, regex)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.regex2Id(pattribute1, regex) : "+Arrays.toString(netClient.regex2Id(pattribute1, regex)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.regex2Id(pattribute2, regex) : "+Arrays.toString(client.regex2Id(pattribute2, regex)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.regex2Id(pattribute2, regex) : "+Arrays.toString(netClient.regex2Id(pattribute2, regex)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.regex2Id(pattribute3, regex) : "+Arrays.toString(client.regex2Id(pattribute3, regex)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.regex2Id(pattribute3, regex) : "+Arrays.toString(netClient.regex2Id(pattribute3, regex)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.str2Id(pattribute1, strings) : "+Arrays.toString(client.str2Id(pattribute1, strings)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.str2Id(pattribute1, strings) : "+Arrays.toString(netClient.str2Id(pattribute1, strings)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.str2Id(pattribute2, strings) : "+Arrays.toString(client.str2Id(pattribute2, strings)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.str2Id(pattribute2, strings) : "+Arrays.toString(netClient.str2Id(pattribute2, strings)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.str2Id(pattribute3, strings) : "+Arrays.toString(client.str2Id(pattribute3, strings)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.str2Id(pattribute3, strings) : "+Arrays.toString(netClient.str2Id(pattribute3, strings)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.struc2Cpos(sattribute1, 0) : "+Arrays.toString(client.struc2Cpos(sattribute1, 0)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.struc2Cpos(sattribute1, 0) : "+Arrays.toString(netClient.struc2Cpos(sattribute1, 0)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.struc2Cpos(sattribute2, 0) : "+Arrays.toString(client.struc2Cpos(sattribute2, 0)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.struc2Cpos(sattribute2, 0) : "+Arrays.toString(netClient.struc2Cpos(sattribute2, 0)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.struc2Cpos(sattribute3, 0) : "+Arrays.toString(client.struc2Cpos(sattribute3, 0)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.struc2Cpos(sattribute3, 0) : "+Arrays.toString(netClient.struc2Cpos(sattribute3, 0)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.struc2Cpos(sattribute1, 1) : "+Arrays.toString(client.struc2Cpos(sattribute1, 1)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.struc2Cpos(sattribute1, 1) : "+Arrays.toString(netClient.struc2Cpos(sattribute1, 1)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.struc2Cpos(sattribute2, 1) : "+Arrays.toString(client.struc2Cpos(sattribute2, 1)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.struc2Cpos(sattribute2, 1) : "+Arrays.toString(netClient.struc2Cpos(sattribute2, 1)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.struc2Cpos(sattribute3, 1) : "+Arrays.toString(client.struc2Cpos(sattribute3, 1)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.struc2Cpos(sattribute3, 1) : "+Arrays.toString(netClient.struc2Cpos(sattribute3, 1)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.struc2Cpos(sattribute1, 2) : "+Arrays.toString(client.struc2Cpos(sattribute1, 2)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.struc2Cpos(sattribute1, 2) : "+Arrays.toString(netClient.struc2Cpos(sattribute1, 2)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.struc2Cpos(sattribute2, 2) : "+Arrays.toString(client.struc2Cpos(sattribute2, 2)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.struc2Cpos(sattribute2, 2) : "+Arrays.toString(netClient.struc2Cpos(sattribute2, 2)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.struc2Cpos(sattribute3, 2) : "+Arrays.toString(client.struc2Cpos(sattribute3, 2)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.struc2Cpos(sattribute3, 2) : "+Arrays.toString(netClient.struc2Cpos(sattribute3, 2)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.struc2Cpos(sattribute1, 3) : "+Arrays.toString(client.struc2Cpos(sattribute1, 3)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.struc2Cpos(sattribute1, 3) : "+Arrays.toString(netClient.struc2Cpos(sattribute1, 3)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.struc2Cpos(sattribute2, 3) : "+Arrays.toString(client.struc2Cpos(sattribute2, 3)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.struc2Cpos(sattribute2, 3) : "+Arrays.toString(netClient.struc2Cpos(sattribute2, 3)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.struc2Cpos(sattribute3, 3) : "+Arrays.toString(client.struc2Cpos(sattribute3, 3)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.struc2Cpos(sattribute3, 3) : "+Arrays.toString(netClient.struc2Cpos(sattribute3, 3)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.struc2Str(sattribute1, strucpos) : "+Arrays.toString(client.struc2Str(sattribute1, strucpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.struc2Str(sattribute1, strucpos) : "+Arrays.toString(netClient.struc2Str(sattribute1, strucpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.struc2Str(sattribute2, strucpos) : "+Arrays.toString(client.struc2Str(sattribute2, strucpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.struc2Str(sattribute2, strucpos) : "+Arrays.toString(netClient.struc2Str(sattribute2, strucpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.struc2Str(sattribute3, strucpos) : "+Arrays.toString(client.struc2Str(sattribute3, strucpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.struc2Str(sattribute3, strucpos) : "+Arrays.toString(netClient.struc2Str(sattribute3, strucpos)));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.subCorpusHasField(subcorpus, (byte)0) : "+client.subCorpusHasField(subcorpusid, (byte)0));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.subCorpusHasField(subcorpus, (byte)0) : "+netClient.subCorpusHasField(subcorpusid, (byte)0));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.subCorpusSize(subcorpus) : "+client.subCorpusSize(subcorpusid));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.subCorpusSize(subcorpus) : "+netClient.subCorpusSize(subcorpusid));
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		try {
+			System.out.println("client.dropSubCorpus(subcorpus)"); client.dropSubCorpus(subcorpusid);
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+		try {
+			System.out.println("netClient.dropSubCorpus(subcorpus)"); netClient.dropSubCorpus(subcorpusid);
+		} catch(Exception e) { System.out.println("Exception : "+e);}
+
+		System.out.println("TIME: "+ExecTimer.stop());
+		System.out.println("STOP MEM CLIENT "+client.disconnect());
+		System.out.println("STOP MEM SERVER "+server.stop());
+		System.out.println("STOP NET CLIENT "+netClient.disconnect());
+		System.out.println("STOP NET SERVER "+netServer.stop());
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpError.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpError.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpError.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiCqpError.
+ */
+public class CqiCqpError extends CqiServerError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiCqpError(){super();}
+	public CqiCqpError(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiErrorGeneralError.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiErrorGeneralError.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiErrorGeneralError.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiErrorGeneralError.
+ */
+public class CqiErrorGeneralError extends CqiServerError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiErrorGeneralError(){super();}
+	public CqiErrorGeneralError(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorOutOfRange.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorOutOfRange.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorOutOfRange.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiClErrorOutOfRange.
+ */
+public class CqiClErrorOutOfRange extends CqiClError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiClErrorOutOfRange(){super();}
+	public CqiClErrorOutOfRange(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorRegex.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorRegex.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorRegex.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiClErrorRegex.
+ */
+public class CqiClErrorRegex extends CqiClError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiClErrorRegex(){super();}
+	public CqiClErrorRegex(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpErrorSyntax.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpErrorSyntax.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpErrorSyntax.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2011-05-09 14:58:28 +0200 (lun., 09 mai 2011) $
+// $LastChangedRevision: 1839 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiCqpErrorErrorGeneral.
+ */
+public class CqiCqpErrorSyntax extends CqiCqpError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiCqpErrorSyntax(){super();}
+	public CqiCqpErrorSyntax(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorInternal.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorInternal.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorInternal.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiClErrorInternal.
+ */
+public class CqiClErrorInternal extends CqiClError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiClErrorInternal(){super();}
+	public CqiClErrorInternal(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpErrorErrorGeneral.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpErrorErrorGeneral.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpErrorErrorGeneral.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiCqpErrorErrorGeneral.
+ */
+public class CqiCqpErrorErrorGeneral extends CqiCqpError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiCqpErrorErrorGeneral(){super();}
+	public CqiCqpErrorErrorGeneral(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClError.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClError.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClError.java	(revision 449)
@@ -0,0 +1,43 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The base class for all exceptions wrapping a CL based error sent by the CQi
+ * server.
+ *
+ * @author Jean-Philippe Magué
+ */
+public class CqiClError extends CqiServerError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiClError(){super();}
+	public CqiClError(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpErrorInvalidField.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpErrorInvalidField.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpErrorInvalidField.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiCqpErrorInvalidField.
+ */
+public class CqiCqpErrorInvalidField extends CqiCqpError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiCqpErrorInvalidField(){super();}
+	public CqiCqpErrorInvalidField(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpErrorNoSuchCorpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpErrorNoSuchCorpus.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpErrorNoSuchCorpus.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiCqpErrorNoSuchCorpus.
+ */
+public class CqiCqpErrorNoSuchCorpus extends CqiCqpError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiCqpErrorNoSuchCorpus(){super();}
+	public CqiCqpErrorNoSuchCorpus(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiErrorSyntaxError.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiErrorSyntaxError.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiErrorSyntaxError.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiErrorSyntaxError.
+ */
+public class CqiErrorSyntaxError extends CqiServerError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiErrorSyntaxError(){super();}
+	public CqiErrorSyntaxError(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorWrongAttributeType.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorWrongAttributeType.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorWrongAttributeType.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiClErrorWrongAttributeType.
+ */
+public class CqiClErrorWrongAttributeType extends CqiClError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiClErrorWrongAttributeType(){super();}
+	public CqiClErrorWrongAttributeType(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorNoSuchAttribute.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorNoSuchAttribute.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorNoSuchAttribute.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiClErrorNoSuchAttribute.
+ */
+public class CqiClErrorNoSuchAttribute extends CqiClError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiClErrorNoSuchAttribute() {super();}
+	public CqiClErrorNoSuchAttribute(String msg) {super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorOutOfMemory.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorOutOfMemory.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorOutOfMemory.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiClErrorOutOfMemory.
+ */
+public class CqiClErrorOutOfMemory extends CqiClError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiClErrorOutOfMemory(){super();}
+	public CqiClErrorOutOfMemory(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiServerError.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiServerError.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiServerError.java	(revision 449)
@@ -0,0 +1,42 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The base class for all exceptions wrapping an error sent by teh CQi server.
+ *
+ * @author Jean-Philippe Magué
+ */
+public class CqiServerError extends Exception {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiServerError(){super();}
+	public CqiServerError(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiErrorUserAbort.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiErrorUserAbort.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiErrorUserAbort.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiErrorUserAbort.
+ */
+public class CqiErrorUserAbort extends CqiServerError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiErrorUserAbort(){super();}
+	public CqiErrorUserAbort(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/package.html
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/package.html	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/package.html	(revision 449)
@@ -0,0 +1,5 @@
+<html>
+<body>
+<p>Exceptions due to pure internal cqp server unexpected behaviour.</p>
+</body>
+</html>
\ No newline at end of file

Property changes on: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiErrorConnectRefused.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiErrorConnectRefused.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiErrorConnectRefused.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiErrorConnectRefused.
+ */
+public class CqiErrorConnectRefused extends CqiServerError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiErrorConnectRefused(){super();}
+	public CqiErrorConnectRefused(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorCorpusAccess.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorCorpusAccess.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiClErrorCorpusAccess.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiClErrorCorpusAccess.
+ */
+public class CqiClErrorCorpusAccess extends CqiClError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiClErrorCorpusAccess(){super();}
+	public CqiClErrorCorpusAccess(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpErrorOutOfRange.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpErrorOutOfRange.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/serverException/CqiCqpErrorOutOfRange.java	(revision 449)
@@ -0,0 +1,40 @@
+// 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: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
+// $LastChangedRevision: 2386 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp.serverException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CqiCqpErrorOutOfRange.
+ */
+public class CqiCqpErrorOutOfRange extends CqiCqpError {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 1L;
+	public CqiCqpErrorOutOfRange(){super();}
+	public CqiCqpErrorOutOfRange(String msg){super(msg);}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CQPEngine.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CQPEngine.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CQPEngine.java	(revision 449)
@@ -0,0 +1,390 @@
+package org.txm.searchengine.cqp;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.txm.EngineType;
+import org.txm.Toolbox;
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.core.preferences.TBXPreferences;
+import org.txm.core.preferences.TXMPreferences;
+import org.txm.importer.cwb.PatchCwbRegistry;
+import org.txm.objects.Base;
+import org.txm.searchengine.core.SearchEngine;
+import org.txm.searchengine.core.SearchEngines;
+import org.txm.searchengine.cqp.clientExceptions.ServerNotFoundException;
+import org.txm.searchengine.cqp.corpus.CorpusManager;
+import org.txm.searchengine.cqp.corpus.MainCorpus;
+import org.txm.utils.OSDetector;
+import org.txm.utils.Sh;
+import org.txm.utils.logger.Log;
+import org.w3c.dom.Element;
+
+public class CQPEngine extends SearchEngine {
+
+	/**
+	 * initialization state
+	 */
+	boolean state = false;
+	boolean useNetCQi = false;
+	
+	@Override
+	public String getName() {
+		return "CQP";
+	}
+	
+	/**
+	 * Starts the corpus engine if not remove then launch cqpserver.
+	 *
+	 * @return true, if successful
+	 */
+	public boolean start() {
+
+		boolean cqiserverok = false;
+		
+		useNetCQi = Boolean.parseBoolean(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_NETWORK_MODE));
+
+		Log.warning("Killing CQP and RServe process if any");
+		killSearchEngine();
+
+		
+		boolean remote = Boolean.parseBoolean(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_IS_REMOTE));
+		state = false;
+		// test if must-have properties for CWB are set
+
+		String exec_path = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PATH_TO_EXECUTABLE);
+		String reg_path = ""; // new way that concats registry of loaded corpus
+		String path_separator = System.getProperty("path.separator");
+		for (Base b : Toolbox.workspace.getProject("default").getBases()) {
+			File binDir = b.getBaseDirectory();
+			File registryDir = new File(binDir, "registry");
+			reg_path += path_separator + registryDir.getAbsolutePath();
+			File[] files = registryDir.listFiles();
+			if (files != null)
+				for (File registryFile : files) {
+					if (registryFile.isHidden()) continue;
+					if (registryFile.isDirectory()) continue;
+
+					File dataDirectory = new File(binDir, "data/"+registryFile.getName().toUpperCase());
+					if (!dataDirectory.exists())dataDirectory = new File(binDir, "data"); // eventual old corpus
+					try {
+						PatchCwbRegistry.patch(registryFile, dataDirectory);
+					} catch (IOException e) {
+						System.out.println("Error while updating registry file "+registryFile+": "+e);
+						Log.printStackTrace(e);
+						return false;
+					}
+				}
+		}
+		if (reg_path.length() > 0) reg_path = reg_path.substring(path_separator.length()); // remove first path_separator
+		//System.out.println("REGPATH="+reg_path);
+		String init_path = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PATH_TO_INIT_FILE);
+
+
+		if (!remote) {
+			if (exec_path == null
+					|| reg_path == null
+					|| init_path == null) {
+				Log.severe(TXMCoreMessages.Toolbox_1); 
+			} else {
+				if (!useNetCQi) {
+					try {
+						cqiServer = new MemCqiServer(exec_path,
+								reg_path, 
+								init_path, 
+								TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_ADDITIONAL_OPTIONS)
+								+ " -P " + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PORT), //$NON-NLS-1$
+								Boolean.parseBoolean(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_MONITOR_OUTPUT)));
+					} catch (Exception e) {
+						// TODO Auto-generated catch block
+						org.txm.utils.logger.Log.printStackTrace(e);
+					}
+				} else {
+					cqiServer = new NetCqiServer(exec_path,
+							reg_path, 
+							init_path, 
+							TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_ADDITIONAL_OPTIONS)
+							+ " -P " + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PORT), //$NON-NLS-1$
+							Boolean.parseBoolean(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_MONITOR_OUTPUT)));
+				}
+				if (cqiServer != null)
+					cqiserverok = cqiServer.start();
+			}
+		}
+
+		// create cqi client
+		try {
+			if (cqiserverok) {
+				if (!useNetCQi) {
+					try {
+						cqiClient = new MemCqiClient((MemCqiServer) cqiServer);
+					} catch(Exception e) {
+						Log.severe(TXMCoreMessages.Toolbox_28+e);
+						cqiserverok = false;
+					}
+				} else {
+					int port = Integer.parseInt(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PORT));
+					String host = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_HOST);
+					cqiClient = new NetCqiClient(host, port);
+				}
+			}
+		} catch (NumberFormatException e1) {
+			Log.severe(TXMCoreMessages.Toolbox_wrong_port + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PORT)); 
+		} catch (ServerNotFoundException e1) {
+			Log.severe(TXMCoreMessages.Error_CONNECTION_FAILED + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_HOST) + TXMCoreMessages.Toolbox_27 + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PORT)); 
+		}
+
+		// try connecting to the CWB server
+		try {
+			if (cqiserverok) {
+				String login = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_LOGIN);
+				String password = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PASSWORD);
+				state = cqiClient.connect(login, password);
+			}
+		} catch (Exception e1) {
+			Log.severe(Log.toString(e1));
+		}
+
+		if (state == false) {
+			System.out.println(TXMCoreMessages.Toolbox_29); 
+			System.out.println(TXMCoreMessages.Toolbox_30 + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_LOGIN) 
+					+ " " + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PASSWORD) 
+					+ TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_HOST) 
+					+ " " + Integer.parseInt(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PORT))); //$NON-NLS-1$ //$NON-NLS-2$
+			if (cqiServer != null)
+				System.out.println(TXMCoreMessages.Toolbox_33 + cqiServer.getLastCmdLine());
+		} else {
+			if (cqiServer == null || cqiServer instanceof NetCqiServer)
+				System.out.println(TXMCoreMessages.Toolbox_connected_to_corpus_sever); 
+		}
+
+		CorpusManager.setCqiClient(cqiClient);
+
+		// wait for CQPSERVER TO BE READY
+		int scount = 0;
+		try {
+			CorpusManager.getCorpusManager().getCorpora();
+			do {
+				Thread.sleep(100);
+				CorpusManager.cleanCorpora();// to be sure to call cqpserver
+				CorpusManager.getCorpusManager().getCorpora();
+				scount++;
+				if (scount >= 10) {
+					Log.warning(TXMCoreMessages.Toolbox_17); 
+					break;
+				}
+			} while (CorpusManager.getCorpusManager().getCorpora().size() == 0);
+		} catch (Exception e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			Log.severe(TXMCoreMessages.Toolbox_18 + e);
+		} 
+		
+		if (Toolbox.workspace == null) {
+			System.out.println("Can't start CQP with workspace not ready.");
+			return false;
+		}
+
+		// initialize pre-configured subcorpus and partition of corpus registered in the default.xml workspace file
+		for (Base b : Toolbox.workspace.getProject("default").getBases()) {
+			if (!loadCQPCorpora(b)) {
+				System.out.println("Fail to load CQP corpora of corpus "+b.getName());
+			}
+		}
+
+		return state;
+	}
+	
+	public boolean loadCQPCorpora(Base base) {
+		//System.out.println("Load corpus from params: "+params.corpora);
+		for (String corpusname : base.getBaseParameters().corpora.keySet()) {
+			Element c = base.getBaseParameters().corpora.get(corpusname);
+			try {
+				MainCorpus corp = CorpusManager.getCorpusManager().getCorpus(corpusname);
+				corp.setSelfElement(c);
+				corp.setParent(base);
+				corp.load(); // don't load corpus right now, wait for the search engine to be ready
+				base.addResult(corp);
+				if (!corp.getMetadatas().containsKey("lang")) { //$NON-NLS-1$
+					corp.setAttribute("lang", c.getAttribute("lang")); //$NON-NLS-1$ //$NON-NLS-2$
+				}
+			} catch (Exception e) {
+				System.out.println(e.getLocalizedMessage());
+				org.txm.utils.logger.Log.printStackTrace(e);
+				return false;
+			}
+		}
+		return true;
+	}
+
+	@Override
+	public boolean initialize() {
+		// all initialization done in the start method because we need CQP executable/lib to restart from the beginning
+		return true;
+	}
+
+	/** The CQI server. */
+	private static AbstractCqiServer cqiServer;
+
+	/** The CQI client. */
+	private static AbstractCqiClient cqiClient;
+
+	/**
+	 * Sets the CQI server.
+	 *
+	 * @param cqiServer the new cqi server
+	 */
+	public static void setCqiServer(AbstractCqiServer cqiServer) {
+		CQPEngine.cqiServer = cqiServer;
+	}
+
+	/**
+	 * Gets the cqi client.
+	 *
+	 * @return the cqi client
+	 */
+	public static AbstractCqiClient getCqiClient() {
+		return cqiClient;
+	}
+
+	/**
+	 * Sets the cqi client.
+	 *
+	 * @param cqiClient the new cqi client
+	 */
+	public static void setCqiClient(NetCqiClient cqiClient) {
+		CQPEngine.cqiClient = cqiClient;
+	}
+
+	/**
+	 * Gets the CQI server.
+	 *
+	 * @return the CQI server
+	 */
+	public static AbstractCqiServer getCqiServer() {
+		return cqiServer;
+	}
+
+	/**
+	 * Shut the toolbox searchengine down.
+	 */
+	public boolean stop() {
+		try {
+			if (cqiClient instanceof MemCqiClient) {
+				try  {
+					for (MainCorpus corpus : CorpusManager.getCorpusManager().getCorpora()) {
+						corpus.closeAnnotationManager();
+					}
+				} catch(Exception e) {}
+				for (String name : ((MemCqiClient)cqiClient).listCorpora()) {
+					((MemCqiClient)cqiClient).dropCorpus(name);
+				}
+			}
+			cqiClient.disconnect();
+			cqiServer.stop();
+
+			CorpusManager.clean();
+			if (cqiServer instanceof NetCqiServer)
+				killSearchEngine();
+
+			state = false;
+		} catch (Exception e) {
+			Log.severe("Error while closing CQP: "+e.getLocalizedMessage());
+			return false;
+		}
+		return true;
+	}
+	
+	/**
+	 * kill cqpserver process.
+	 */
+	private static void killSearchEngine() {
+		if ("false".equals(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_IS_REMOTE))) //$NON-NLS-1$
+			// Windows OS
+			if (OSDetector.isFamilyWindows()) {
+				try {
+					Process p = Runtime.getRuntime().exec(
+							"taskkill /IM cqpserver.exe /F"); //$NON-NLS-1$
+					p.waitFor();
+					p = Runtime.getRuntime().exec("taskkill /IM cqpserver.exe /F"); //$NON-NLS-1$
+					p.waitFor();
+				} catch (IOException e) {
+					Log.severe(TXMCoreMessages.Toolbox_31+Log.toString(e));
+					System.out.println(TXMCoreMessages.Toolbox_31+Log.toString(e));
+					try {
+						Process p = Runtime.getRuntime().exec(
+								"tskill cqpserver.exe"); //$NON-NLS-1$
+						p.waitFor();
+						p = Runtime.getRuntime().exec("tskill cqpserver.exe"); //$NON-NLS-1$
+						p.waitFor();
+					} catch (IOException e2) {
+						Log.severe(TXMCoreMessages.Toolbox_34+Log.toString(e2));
+						System.out.println(TXMCoreMessages.Toolbox_34+Log.toString(e2));
+					} catch (InterruptedException e3) {
+						Log.severe(Log.toString(e3));
+						System.out.println(Log.toString(e3));
+					}
+				} catch (InterruptedException e) {
+					Log.severe("Error while closing CQP: "+e.getLocalizedMessage());
+					System.out.println(Log.toString(e));
+				}
+				;
+			}
+		// Mac, Linux
+			else {
+				String cmd = TXMCoreMessages.Toolbox_37 + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PORT) + TXMCoreMessages.Toolbox_38;
+				try {
+					//Process p = Runtime.getRuntime().exec("killall -9 cqpserver"); //$NON-NLS-1$
+					// System.out.println("kill `ps aux | grep cqpserver | awk '/-P "
+					// + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, CQI_SERVER_PORT) + "/ {print $2}'`");
+					// String[] args =
+					// {"kill","`ps aux | grep cqpserver | awk '/-P " +
+					// TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, CQI_SERVER_PORT) + "/ {print $2}'`"};
+					// System.out.println("before Sh constructor");
+					Sh sh = new Sh(""); //$NON-NLS-1$
+					// System.out.println("after Sh constructor");
+					// System.out.println("EXECUTE SH : "+"kill `ps aux | grep cqpserver | awk '/-P "
+					// + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, CQI_SERVER_PORT) + "/ {print $2}'`");
+					sh.setIsc(cmd);
+					sh.sh();
+					// Runtime.getRuntime().exec("sh kill `ps aux | grep cqpserver | awk '/-P "
+					// + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, CQI_SERVER_PORT) + "/ {print $2}'`");
+
+				} catch (Exception e) {
+					Log.severe(TXMCoreMessages.Toolbox_39+cmd+TXMCoreMessages.Toolbox_40+Log.toString(e));
+					System.out.println(TXMCoreMessages.Toolbox_39+cmd+TXMCoreMessages.Toolbox_40+Log.toString(e));
+					org.txm.utils.logger.Log.printStackTrace(e);
+				}
+			}
+	}
+
+	/**
+	 * Restart the toolbox's searchengine.
+	 *
+	 * @return true, if successful
+	 */
+	public boolean restart() {
+		try {
+			boolean ret = stop();
+			Thread.sleep(10);
+			ret = ret && start();
+			return ret;
+		} catch (Exception e) {
+			Log.severe("Error while restarting CQP: "+e.getLocalizedMessage());
+		}
+		return false;
+	}
+	
+	/**
+	 * test if searchEngine is initialized.
+	 *
+	 * @return true, if is initialized
+	 */
+	public static boolean isInitialized() {
+		return Toolbox.getEngineManager(EngineType.SEARCH).getEngine("CQP").getState();
+	}
+
+	@Override
+	public boolean getState() {
+		return state;
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/MemCqiClient.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/MemCqiClient.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/MemCqiClient.java	(revision 449)
@@ -0,0 +1,586 @@
+package org.txm.searchengine.cqp;
+
+import java.io.IOException;
+
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
+import org.txm.searchengine.cqp.serverException.CqiClErrorCorpusAccess;
+import org.txm.searchengine.cqp.serverException.CqiClErrorInternal;
+import org.txm.searchengine.cqp.serverException.CqiClErrorNoSuchAttribute;
+import org.txm.searchengine.cqp.serverException.CqiClErrorOutOfMemory;
+import org.txm.searchengine.cqp.serverException.CqiClErrorOutOfRange;
+import org.txm.searchengine.cqp.serverException.CqiClErrorRegex;
+import org.txm.searchengine.cqp.serverException.CqiClErrorWrongAttributeType;
+import org.txm.searchengine.cqp.serverException.CqiCqpErrorErrorGeneral;
+import org.txm.searchengine.cqp.serverException.CqiCqpErrorInvalidField;
+import org.txm.searchengine.cqp.serverException.CqiCqpErrorNoSuchCorpus;
+import org.txm.searchengine.cqp.serverException.CqiCqpErrorOutOfRange;
+import org.txm.searchengine.cqp.serverException.CqiCqpErrorSyntax;
+import org.txm.searchengine.cqp.serverException.CqiErrorConnectRefused;
+import org.txm.searchengine.cqp.serverException.CqiErrorGeneralError;
+import org.txm.searchengine.cqp.serverException.CqiErrorSyntaxError;
+import org.txm.searchengine.cqp.serverException.CqiErrorUserAbort;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
+import org.txm.utils.logger.Log;
+
+/**
+ * @author mdecorde
+ * Declares all the natives methods
+ */
+public class MemCqiClient extends AbstractCqiClient {
+
+	MemCqiServer server;
+
+	public MemCqiClient(MemCqiServer server) throws Exception {
+		super();
+		this.server= server;
+	}
+
+	public boolean start(String[] args) {
+		return true;
+	}
+
+	public void stop() {
+		server.stop();
+	}
+
+	public static final byte[] intToByteArray(int value) {
+		return new byte[] {
+				(byte)(value >>> 24),
+				(byte)(value >>> 16),
+				(byte)(value >>> 8),
+				(byte)value};
+	}
+
+
+	public byte[] throwExceptionFromCqi(int error) throws CqiServerError, UnexpectedAnswerException, IOException {
+		byte[] ret = intToByteArray(error);
+		
+		byte b = ret[2];
+		byte b2 = ret[3];
+		//System.out.println("bytes: "+ret[0]+" "+ret[1]+" "+ret[2]+" "+ret[3]);
+		//System.out.println("b1 "+b+ " b2 "+b2);
+		Log.finest(TXMCoreMessages.bind(TXMCoreMessages.READ_BYTE_FROM_CQI_SERVER, b));
+		switch (b) {
+		case 0x00:// cf cqi.h:29
+			return CQI_PADDING;
+		case 0x01:// cf cqi.h:37
+			Log.finest(TXMCoreMessages.bind(TXMCoreMessages.READ_BYTE_FROM_CQI_SERVER, b));
+			switch (b2) {
+			case 0x01:// cf cqi.h:39
+				return CQI_STATUS_OK;
+			case 0x02:// cf cqi.h:40
+				return CQI_STATUS_CONNECT_OK;
+			case 0x03:// cf cqi.h:41
+				return CQI_STATUS_BYE_OK;
+			case 0x04:// cf cqi.h:42
+				return CQI_STATUS_PING_OK;
+			default:
+				throw new CqiErrorGeneralError(TXMCoreMessages.MemCqiClient_3+b+TXMCoreMessages.MemCqiClient_9+b2); //$NON-NLS-2$
+			}
+		case 0x02:// cf cqi.h:45
+			Log.finest(TXMCoreMessages.bind(TXMCoreMessages.READ_BYTE_FROM_CQI_SERVER, b));
+
+			lastError = TXMCoreMessages.MemCqiClient_0+" CQI_ERROR ("+b+")";
+
+			switch (b2) {
+			case 0x01:// cf cqi.h:39
+				throw new CqiErrorGeneralError();
+			case 0x02:// cf cqi.h:40
+				throw new CqiErrorConnectRefused();
+			case 0x03:// cf cqi.h:41
+				throw new CqiErrorUserAbort();
+			case 0x04:// cf cqi.h:42
+				throw new CqiErrorSyntaxError();
+			default:
+				throw new CqiErrorGeneralError(TXMCoreMessages.MemCqiClient_5+b+TXMCoreMessages.MemCqiClient_9+b2); //$NON-NLS-2$
+			}
+		case 0x03:// cf cqi.h:53
+			Log.finest(TXMCoreMessages.bind(TXMCoreMessages.READ_BYTE_FROM_CQI_SERVER, b));
+			switch (b2) {
+			case 0x01:// cf cqi.h:39
+				return CQI_DATA_BYTE;
+			case 0x02:// cf cqi.h:40
+				return CQI_DATA_BOOL;
+			case 0x03:// cf cqi.h:41
+				return CQI_DATA_INT;
+			case 0x04:// cf cqi.h:42
+				return CQI_DATA_STRING;
+			case 0x05:// cf cqi.h:42
+				return CQI_DATA_BYTE_LIST;
+			case 0x06:// cf cqi.h:42
+				return CQI_DATA_BOOL_LIST;
+			case 0x07:// cf cqi.h:42
+				return CQI_DATA_INT_LIST;
+			case 0x08:// cf cqi.h:42
+				return CQI_DATA_STRING_LIST;
+			case 0x09:// cf cqi.h:42
+				return CQI_DATA_INT_INT;
+			case 0x0A:// cf cqi.h:42
+				return CQI_DATA_INT_INT_INT_INT;
+			case 0x0B:// cf cqi.h:42
+				return CQI_DATA_INT_TABLE;
+			default:
+				throw new CqiErrorGeneralError(TXMCoreMessages.MemCqiClient_7+b+TXMCoreMessages.MemCqiClient_9+b2); //$NON-NLS-2$
+			}
+		case 0x04:// cf cqi.h:67
+
+			lastError = TXMCoreMessages.MemCqiClient_1+"CL_ERROR ("+b+")";
+			Log.finest(TXMCoreMessages.bind(TXMCoreMessages.READ_BYTE_FROM_CQI_SERVER, b));
+			switch (b2) {
+			case 0x01:// cf cqi.h:39
+				lastError += ": NoSuchAttribute error";
+				throw new CqiClErrorNoSuchAttribute();
+			case 0x02:// cf cqi.h:40
+				lastError += ": WrongAttributeType error";
+				throw new CqiClErrorWrongAttributeType();
+			case 0x03:// cf cqi.h:41
+				lastError += ": OutOfRange error";
+				throw new CqiClErrorOutOfRange();
+			case 0x04:// cf cqi.h:42
+				lastError = this.getLastCqiError();
+				throw new CqiClErrorRegex();
+			case 0x05:// cf cqi.h:42
+				lastError += ": CorpusAccess error";
+				throw new CqiClErrorCorpusAccess();
+			case 0x06:// cf cqi.h:42
+				lastError += ": OutOfMemory error";
+				throw new CqiClErrorOutOfMemory();
+			case 0x07:// cf cqi.h:42
+				lastError += ": Internal error";
+				throw new CqiClErrorInternal();
+			default:
+				lastError += ": Unknown error";
+				throw new CqiErrorGeneralError(TXMCoreMessages.MemCqiClient_3+b+TXMCoreMessages.MemCqiClient_9+b2);
+			}
+
+		case 0x05:// cf cqi.h:94
+
+			lastError = TXMCoreMessages.MemCqiClient_2+"CQI_CQP_ERROR ("+b+")";
+			Log.finest(TXMCoreMessages.bind(TXMCoreMessages.READ_BYTE_FROM_CQI_SERVER, b));
+			switch (b2) {
+			case 0x01:// cf cqi.h:39
+				lastError += ": General error";
+				throw new CqiCqpErrorErrorGeneral();
+			case 0x02:// cf cqi.h:40
+				lastError += ": NoSuchCorpus error";
+				throw new CqiCqpErrorNoSuchCorpus();
+			case 0x03:// cf cqi.h:41
+				lastError += ": InvalidField error";
+				throw new CqiCqpErrorInvalidField();
+			case 0x04:// cf cqi.h:42
+				lastError += ": OutOfRange error";
+				throw new CqiCqpErrorOutOfRange();
+			case 0x05:// cf cqi.h:44
+				lastError = getLastCQPError();
+				throw new CqiCqpErrorSyntax();
+			default:
+				throw new CqiErrorGeneralError(TXMCoreMessages.MemCqiClient_3+b+TXMCoreMessages.MemCqiClient_9+b2);
+			}
+		default:
+			throw new CqiErrorGeneralError(TXMCoreMessages.MemCqiClient_10+b+TXMCoreMessages.MemCqiClient_9+b2);
+		}
+		//return null;
+	}
+
+	@Override
+	public int[] alg2Cpos(String arg0, int arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
+		int[] rez = server.alg2Cpos(arg0, arg1);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public int attributeSize(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError {
+		Integer ret = server.attributeSize(arg0);
+		if (ret == null || ret == -1) {
+			throwExceptionFromCqi(server.getErrorCode());
+			// throw exception
+		}
+		return ret;
+	}
+
+	@Override
+	public boolean connect(String arg0, String arg1) { return server.isLoaded;} ;
+
+	@Override
+	public String[] corpusAlignementAttributes(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
+		String[] rez = server.corpusAlignementAttributes(arg0);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public String corpusCharset(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
+		String rez = server.corpusCharset(arg0);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public String corpusFullName(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
+		String rez = server.corpusFullName(arg0);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public String[] corpusInfo(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
+		throw new UnsupportedOperationException();
+		/*String[] rez = server.corpusInfo(arg0);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+		 */
+	}
+
+	@Override
+	public String[] corpusPositionalAttributes(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
+		String[] rez = server.corpusPositionalAttributes(arg0);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public String[] corpusProperties(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
+		String[] rez = server.corpusProperties(arg0);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public boolean corpusStructuralAttributeHasValues(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
+		Boolean rez = server.corpusStructuralAttributeHasValues(arg0);
+		if (rez == null || !rez) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public String[] corpusStructuralAttributes(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
+		String[] rez = server.corpusStructuralAttributes(arg0);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public int[] cpos2Alg(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
+		int[] rez = server.cpos2Alg(arg0, arg1);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public int[] cpos2Id(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
+		int[] rez = server.cpos2Id(arg0, arg1);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public int[] cpos2LBound(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
+		int[] rez = server.cpos2LBound(arg0, arg1);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public int[] cpos2RBound(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
+		int[] rez = server.cpos2RBound(arg0, arg1);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public String[] cpos2Str(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
+		String[] rez = server.cpos2Str(arg0, arg1);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public int[] cpos2Struc(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
+		int[] rez = server.cpos2Struc(arg0, arg1);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public void cqpQuery(String arg0, String arg1, String arg2)
+			throws IOException, UnexpectedAnswerException, CqiServerError {
+		Boolean ret = server.cqpQuery(arg0, arg1, arg2);
+		//System.out.println("CQPSERVER return: "+ret);
+		if(ret == null || !ret) {
+			int e = server.getErrorCode();
+			//System.out.println("throw exception with cqp error code: "+e);
+			throwExceptionFromCqi(e);
+		}
+	}
+
+	public void query(String arg0)
+			throws IOException, UnexpectedAnswerException, CqiServerError {
+		Boolean ret = server.query(arg0);
+		if(ret == null || !ret) {
+			System.out.println(TXMCoreMessages.MemCqiClient_11);
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+	}
+
+	@Override
+	public boolean disconnect() { return true; };
+
+	@Override
+	public void dropAttribute(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError {
+		throw new UnsupportedOperationException();
+		//		Boolean ret = server.dropAttribute(arg0);
+		//		if(ret == null || !ret) {
+		//			throwExceptionFromCqi(server.getErrorCode());
+		//		}
+	}
+
+	@Override
+	public void dropCorpus(String arg0) throws Exception {
+		Boolean ret = server.dropCorpus(arg0);
+		if(ret == null || !ret) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+	}
+
+	@Override
+	public void dropSubCorpus(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError {
+		Boolean ret = server.dropSubCorpus(arg0);
+		if (ret == null || !ret) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+	}
+
+	@Override
+	public int[] dumpSubCorpus(String arg0, byte arg1, int arg2, int arg3)
+			throws IOException, UnexpectedAnswerException, CqiServerError {
+		int[] rez = server.dumpSubCorpus(arg0, arg1, arg2, arg3);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public int[][] fdist1(String arg0, int arg1, byte arg2, String arg3)
+			throws IOException, UnexpectedAnswerException, CqiServerError {
+		int[] all = nfdist1(arg0, arg1, arg2, arg3);
+		if (all == null) {
+			return new int[0][0];
+		}
+		int[][] freqs = new int[all.length / 2][2];
+		int c = 0;
+		for (int i = 0 ; i < freqs.length ;i++) {
+			freqs[i][0] = all[c++];
+			freqs[i][1] = all[c++];
+		}
+		return freqs;
+
+	}
+
+	public int[] nfdist1(String arg0, int arg1, byte arg2, String arg3)
+			throws IOException, UnexpectedAnswerException, CqiServerError {
+		int[] rez = server.nfdist1(arg0, arg1, arg2, arg3);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public int[][] fdist2(String arg0, int arg1, byte arg2, String arg3,
+			byte arg4, String arg5) throws IOException,
+			UnexpectedAnswerException, CqiServerError {
+		int[] all = nfdist2(arg0, arg1, arg2, arg3, arg4, arg5);
+		if (all == null) {
+			return new int[0][0];
+		}
+		int[][] freqs = new int[all.length / 2][3];
+		int c = 0;
+		for (int i = 0 ; i < freqs.length ;i++) {
+			freqs[i][0] = all[c++];
+			freqs[i][1] = all[c++];
+			freqs[i][2] = all[c++];
+		}
+		return freqs;
+	}
+
+	public int[] nfdist2(String arg0, int arg1, byte arg2, String arg3,
+			byte arg4, String arg5) throws IOException, UnexpectedAnswerException, CqiServerError {
+		int[] rez = server.nfdist2(arg0, arg1, arg2, arg3, arg4, arg5);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public String getLastCQPError() throws UnexpectedAnswerException, IOException,	CqiServerError {
+		String rez = server.getLastCQPError();
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public String getLastCqiError() throws UnexpectedAnswerException, IOException, CqiServerError {
+		String rez = server.getLastCqiError();
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public int[] id2Cpos(String arg0, int arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
+		int[] rez = server.id2Cpos(arg0, arg1);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public int[] id2Freq(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
+		int[] rez = server.id2Freq(arg0, arg1);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public String[] id2Str(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
+		String[] rez = server.id2Str(arg0, arg1);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public int[] idList2Cpos(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
+		int[] rez = server.idList2Cpos(arg0, arg1);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public int lexiconSize(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError {
+		Integer rez = server.lexiconSize(arg0);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public String[] listCorpora() throws UnexpectedAnswerException, IOException, CqiServerError {
+		String[] rez = server.listCorpora();
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public String[] listSubcorpora(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
+		String[] rez = server.listSubcorpora(arg0);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public boolean reconnect() { return true; } ;
+
+	@Override
+	public int[] regex2Id(String arg0, String arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
+		int[] rez = server.regex2Id(arg0, arg1);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public int[] str2Id(String arg0, String[] arg1) throws IOException, UnexpectedAnswerException, CqiServerError {
+		int[] rez = server.str2Id(arg0, arg1);
+		if (rez == null) {
+			//System.out.println("error: "+server.getErrorCode());
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public int[] struc2Cpos(String arg0, int arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
+		int[] rez = server.struc2Cpos(arg0, arg1);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public String[] struc2Str(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
+		String[] rez = server.struc2Str(arg0, arg1);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public boolean subCorpusHasField(String arg0, byte arg1) throws IOException, UnexpectedAnswerException, CqiServerError {
+		Boolean rez = server.subCorpusHasField(arg0, arg1);
+		if (rez == null || !rez) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+
+	@Override
+	public int subCorpusSize(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError {
+		Integer rez = server.subCorpusSize(arg0);
+		if (rez == null) {
+			throwExceptionFromCqi(server.getErrorCode());
+		}
+		return rez;
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/NetCqiServer.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/NetCqiServer.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/NetCqiServer.java	(revision 449)
@@ -0,0 +1,351 @@
+// 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: 2013-09-05 09:27:13 +0200 (jeu., 05 sept. 2013) $
+// $LastChangedRevision: 2529 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.searchengine.cqp.clientExceptions.ServerNotFoundException;
+import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
+import org.txm.utils.logger.Log;
+
+// TODO: Auto-generated Javadoc
+/**
+ * This class aims at handling a CQi server process. It is not a CQi server per
+ * se.
+ * 
+ * @author Jean-Philippe Magué
+ */
+public class NetCqiServer extends AbstractCqiServer {
+
+	/** The cmd line. */
+	String[] cmdLine;
+
+	/**
+	 * Gets the last cmd line.
+	 *
+	 * @return the last cmd line
+	 */
+	@Override
+	public String getLastCmdLine() {
+		return StringUtils.join(cmdLine, " "); //$NON-NLS-1$
+	}
+
+	/** The additional options. */
+	String additionalOptions;
+
+	public boolean debug = false;
+	
+	/** The monitor output. */
+	boolean monitorOutput;
+	
+	/** The path to executable. */
+	String pathToExecutable;
+	
+	/** The path to init file. */
+	String pathToInitFile;
+	
+	/** The path to registry. */
+	String pathToRegistry;
+
+	/** The process. */
+	private Process process;
+	/**
+	 * Instantiates a new CQi server.
+	 * 
+	 * @param pathToExecutable
+	 *            the path to the executable
+	 * @param pathToRegistry
+	 *            the path to the registry
+	 * @param pathToInitFile
+	 *            the path to the init file
+	 * 
+	 * @throws ServerNotFoundException
+	 *             the server not found exception
+	 */
+	public NetCqiServer(String pathToExecutable, String pathToRegistry,
+			String pathToInitFile) throws ServerNotFoundException {
+		this(pathToExecutable, pathToRegistry, pathToInitFile, ""); //$NON-NLS-1$
+	}
+	/**
+	 ** Instantiates a new CQi server.
+	 * 
+	 * @param pathToExecutable
+	 *            the path to the executable
+	 * @param pathToRegistry
+	 *            the path to the registry
+	 * @param pathToInitFile
+	 *            the path to the init file
+	 * @param additionalOptions
+	 *            the additional command line options
+	 * 
+	 * @throws ServerNotFoundException
+	 *             the server not found exception
+	 */
+	public NetCqiServer(String pathToExecutable, String pathToRegistry,
+			String pathToInitFile, String additionalOptions)
+			throws ServerNotFoundException {
+		this(pathToExecutable, pathToRegistry, pathToInitFile,
+				additionalOptions, false);
+	}
+
+	/**
+	 * Instantiates a new cqi server.
+	 *
+	 * @param pathToExecutable the path to executable
+	 * @param pathToRegistry the path to registry
+	 * @param pathToInitFile the path to init file
+	 * @param additionalOptions the additional options
+	 * @param monitorOutput the monitor output
+	 */
+	public NetCqiServer(String pathToExecutable, String pathToRegistry,
+			String pathToInitFile, String additionalOptions,
+			boolean monitorOutput) {
+
+		this.pathToExecutable = pathToExecutable;
+		this.pathToRegistry = pathToRegistry;
+		this.pathToInitFile = pathToInitFile;
+		this.additionalOptions = additionalOptions;
+		this.monitorOutput = monitorOutput;
+	}
+
+	/**
+	 * Convert stream to string.
+	 *
+	 * @param is the is
+	 * @return the string
+	 */
+	@Override
+	public String convertStreamToString(InputStream is) {
+		BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+		StringBuilder sb = new StringBuilder();
+
+		String line = null;
+		try {
+			while ((line = reader.readLine()) != null) {
+				sb.append(line);
+			}
+		} catch (IOException e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} finally {
+			try {
+				is.close();
+			} catch (IOException e) {
+				org.txm.utils.logger.Log.printStackTrace(e);
+			}
+		}
+
+		return sb.toString();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#finalize()
+	 */
+	@Override
+	protected void finalize() throws Throwable {
+		try {
+			this.stop();
+		} finally {
+			super.finalize();
+		}
+	}
+	
+	/**
+	 * Gets the error stream.
+	 *
+	 * @return the error stream
+	 */
+	@Override
+	public InputStream getErrorStream() {
+		return process.getErrorStream();
+	}
+
+	/**
+	 * Gets the input stream.
+	 *
+	 * @return the input stream
+	 */
+	@Override
+	public InputStream getInputStream() {
+		return process.getInputStream();
+	}
+
+	/**
+	 * Gets the output stream.
+	 *
+	 * @return the output stream
+	 */
+	@Override
+	public OutputStream getOutputStream() {
+		return process.getOutputStream();
+	}
+
+	/**
+	 * Checks if the server is running.
+	 * 
+	 * @return true, if is running
+	 */
+	@Override
+	public Boolean isRunning() {
+		try {
+			this.process.exitValue();// this throws an
+										// IllegalThreadStateException if te
+										// process is running
+			// The IllegalThreadStateException has not been thrown, the process
+			// is not running.
+			return false;
+		} catch (IllegalThreadStateException e) {
+			// The IllegalThreadStateException has been thrown, all good.
+			return true;
+		}
+	}
+
+	@Override
+	public void setDebug(boolean val)
+	{
+		debug = val;
+	}
+
+	/**
+	 * Start.
+	 *
+	 * @return true, if successful
+	 */
+	@Override
+	public Boolean start() {
+		String[] cmd = { pathToExecutable, "-I", pathToInitFile, "-r", pathToRegistry }; //$NON-NLS-1$ //$NON-NLS-2$
+		cmdLine = (String[]) ArrayUtils.addAll(cmd, additionalOptions.trim().split(" ")); //$NON-NLS-1$
+		
+		try {
+//			System.out.println(Messages.bind(Messages.STARTING_SERVER,
+//					StringUtils.join(cmdLine, " "))); //$NON-NLS-1$
+			ProcessBuilder processBuilder = new ProcessBuilder(cmdLine);
+			processBuilder.redirectErrorStream(true);
+			this.process = processBuilder.start();
+			
+			final InputStream stdout = this.process.getInputStream();
+			final InputStream stderr = this.process.getErrorStream();
+			
+			Thread t1 = new Thread(){
+				  @Override
+				public void run()
+				  {InputStreamReader isr = new InputStreamReader(stdout);
+					  BufferedReader br = new BufferedReader(isr);
+						String line = null;
+						try {
+							while ((line = br.readLine()) != null) {
+								if(debug)
+									System.out.println(TXMCoreMessages.NetCqiServer_0+line);
+							}
+						} catch (IOException e) {
+							// TODO Auto-generated catch block
+							Log.warning(Log.toString(e));
+						}
+				  }
+			};
+			t1.start();
+			
+			Thread t2 = new Thread(){
+				  @Override
+				public void run()
+				  {
+					  InputStreamReader isr = new InputStreamReader(stderr);
+					  BufferedReader br = new BufferedReader(isr);
+						String line = null;
+						try {
+							while ((line = br.readLine()) != null) {
+								if(debug)
+									System.out.println(TXMCoreMessages.NetCqiServer_1+line);
+							}
+						} catch (IOException e) {
+							// TODO Auto-generated catch block
+							org.txm.utils.logger.Log.printStackTrace(e);
+						}
+				  }
+			};
+			t2.start();
+
+			return isRunning();
+		} catch (IOException e) {
+			// System.err.println("CQP server failed to start with the following command line: "
+			// + StringUtils.join(cmd, " "));
+		}
+		return false;
+	}
+
+	/**
+	 * Stop the server.
+	 */
+	@Override
+	public Boolean stop() {
+		Log.finest(TXMCoreMessages.STOPING_SERVER);
+
+		try {
+			process.destroy();
+			process.waitFor();			
+		} catch (Exception e) {
+			Log.finest(Log.toString(e));
+			return false;
+		}
+		Log.finest(TXMCoreMessages.SERVER_STOPED);
+		return true;
+	}
+
+	public static void main(String args[]) {
+		try {
+			NetCqiServer server = new NetCqiServer("C:\\Program files\\TXM\\cwb\\bin\\cqpserver", "C:\\Documents and Settings\\mdecorde\\TXM\\registry", "C:\\Program files\\TXM\\cwb\\cqpserver.init", "-b 1000000 -d OFF -P 4877"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+			System.out.println(server.start());
+			
+			
+			NetCqiClient client = new NetCqiClient("localhost", 4877); //$NON-NLS-1$
+			System.out.println(client.connect("", "")); //$NON-NLS-1$ //$NON-NLS-2$
+			server.stop();
+		} catch (ServerNotFoundException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} catch (UnexpectedAnswerException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		} catch (CqiServerError e) {
+			// TODO Auto-generated catch block
+			org.txm.utils.logger.Log.printStackTrace(e);
+		}
+	}
+}

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

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ICqiServer.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ICqiServer.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ICqiServer.java	(revision 449)
@@ -0,0 +1,90 @@
+// 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: 2011-12-14 10:52:18 +0100 (mer., 14 déc. 2011) $
+// $LastChangedRevision: 2080 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.searchengine.cqp;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+// TODO: Auto-generated Javadoc
+/**
+ * This class aims at handling a CQi server process. It is not a CQi server per
+ * se.
+ * 
+ * @author Jean-Philippe Magué
+ */
+public interface ICqiServer {
+
+	public void setDebug(boolean val);
+
+	/**
+	 * Start.
+	 *
+	 * @return true, if successful
+	 */
+	public Boolean start();
+
+	/**
+	 * Convert stream to string.
+	 *
+	 * @param is the is
+	 * @return the string
+	 */
+	public String convertStreamToString(InputStream is);
+
+	/**
+	 * Stop the server.
+	 */
+	public Boolean stop();
+
+	/**
+	 * Checks if the server is running.
+	 * 
+	 * @return true, if is running
+	 */
+	public Boolean isRunning();
+
+	/**
+	 * Gets the error stream.
+	 *
+	 * @return the error stream
+	 */
+	public InputStream getErrorStream();
+
+	/**
+	 * Gets the input stream.
+	 *
+	 * @return the input stream
+	 */
+	public InputStream getInputStream();
+	/**
+	 * Gets the output stream.
+	 *
+	 * @return the output stream
+	 */
+	public OutputStream getOutputStream();
+}

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

