Author: tchemit Date: 2011-11-22 12:29:24 +0100 (Tue, 22 Nov 2011) New Revision: 2230 Url: http://nuiton.org/repositories/revision/nuiton-utils/2230 Log: Evolution #1818: Introduce a csv importexport library (nuiton-csv) Added: trunk/nuiton-csv/ trunk/nuiton-csv/LICENSE.txt trunk/nuiton-csv/README.txt trunk/nuiton-csv/changelog.txt trunk/nuiton-csv/pom.xml trunk/nuiton-csv/src/ trunk/nuiton-csv/src/main/ trunk/nuiton-csv/src/main/java/ trunk/nuiton-csv/src/main/java/org/ trunk/nuiton-csv/src/main/java/org/nuiton/ trunk/nuiton-csv/src/main/java/org/nuiton/util/ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Column.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Common.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Export.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ExportModel.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ExportableColumn.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Import.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportExportModel.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportModel.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportableColumn.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportableExportableColumn.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ModelBuilder.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValidationResult.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueFormatter.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueGetter.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueGetterSetter.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueParser.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueParserFormatter.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueSetter.java trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/package-info.java trunk/nuiton-csv/src/main/java/org/nuiton/utils/ trunk/nuiton-csv/src/main/java/org/nuiton/utils/csv/ trunk/nuiton-csv/src/main/resources/ trunk/nuiton-csv/src/main/resources/i18n/ trunk/nuiton-csv/src/main/resources/i18n/nuiton-csv_en_GB.properties trunk/nuiton-csv/src/main/resources/i18n/nuiton-csv_es_ES.properties trunk/nuiton-csv/src/main/resources/i18n/nuiton-csv_fr_FR.properties trunk/nuiton-csv/src/test/ trunk/nuiton-csv/src/test/java/ trunk/nuiton-csv/src/test/java/org/ trunk/nuiton-csv/src/test/java/org/nuiton/ trunk/nuiton-csv/src/test/java/org/nuiton/utils/ trunk/nuiton-csv/src/test/java/org/nuiton/utils/csv/ trunk/nuiton-csv/src/test/resources/ Modified: trunk/pom.xml Property changes on: trunk/nuiton-csv ___________________________________________________________________ Added: svn:ignore + target *.ipr *.iml *.iws .classpath .settings .project *.log Added: trunk/nuiton-csv/LICENSE.txt =================================================================== --- trunk/nuiton-csv/LICENSE.txt (rev 0) +++ trunk/nuiton-csv/LICENSE.txt 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,166 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. + Property changes on: trunk/nuiton-csv/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Property changes on: trunk/nuiton-csv/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Property changes on: trunk/nuiton-csv/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/pom.xml =================================================================== --- trunk/nuiton-csv/pom.xml (rev 0) +++ trunk/nuiton-csv/pom.xml 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,183 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Nuiton Utils :: Nuiton Csv + %% + Copyright (C) 2004 - 2010 CodeLutin, Tony Chemit + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program 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 Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + + <parent> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils-parent</artifactId> + <version>2.4-SNAPSHOT</version> + </parent> + + <artifactId>nuiton-csv</artifactId> + + <dependencies> + + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>nuiton-utils</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + </dependency> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + + <dependency> + <groupId>commons-beanutils</groupId> + <artifactId>commons-beanutils</artifactId> + </dependency> + + <dependency> + <groupId>net.sourceforge.javacsv</groupId> + <artifactId>javacsv</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton.i18n</groupId> + <artifactId>nuiton-i18n</artifactId> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>provided</scope> + </dependency> + + </dependencies> + + + <!-- ************************************************************* --> + <!-- *** Project Information ************************************* --> + <!-- ************************************************************* --> + + <name>Nuiton Utils :: Nuiton Csv</name> + <description>Library of usefull classes to import export csv.</description> + <inceptionYear>2011</inceptionYear> + + <!-- ************************************************************* --> + <!-- *** Build Settings ****************************************** --> + <!-- ************************************************************* --> + + <properties> + + <!-- extra files to include in release --> + <redmine.releaseFiles>${redmine.libReleaseFiles}</redmine.releaseFiles> + + </properties> + + <build> + + <plugins> + + <!-- plugin i18n --> + <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>maven-i18n-plugin</artifactId> + <configuration> + <silent>true</silent> + <bundles>fr_FR,en_GB,es_ES</bundles> + </configuration> + <executions> + <execution> + <goals> + <goal>parserJava</goal> + <goal>gen</goal> + </goals> + </execution> + </executions> + </plugin> + + </plugins> + + </build> + + <!-- ************************************************************* --> + <!-- *** Build Environment ************************************** --> + <!-- ************************************************************* --> + + <profiles> + <!-- create assemblies at release time --> + <profile> + <id>assembly-profile</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + <build> + <defaultGoal>package</defaultGoal> + <plugins> + + <!-- launch in a release the assembly automaticly --> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>create-assemblies</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + <configuration> + <attach>false</attach> + <descriptorRefs> + <descriptorRef>deps</descriptorRef> + <descriptorRef>full</descriptorRef> + </descriptorRefs> + </configuration> + </plugin> + + </plugins> + + </build> + </profile> + + </profiles> + +</project> Property changes on: trunk/nuiton-csv/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Column.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Column.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Column.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,182 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +import java.text.ParseException; + +/** + * TODO + * + * @author bleny <leny@codelutin.com> + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + */ +public class Column<E, T> implements ImportableExportableColumn<E, T> { + + public static <E, T> Column<E, T> newExportableColumn(String headerName, + ValueGetter<E, T> valueGetter, + ValueFormatter<T> valueFormatter, + boolean ignored) { + return new Column<E, T>(headerName, + valueGetter, + valueFormatter, + null, + null, + ignored + ); + } + + public static <E, T> Column<E, T> newImportableColumn(String headerName, + ValueParser<T> valueParser, + ValueSetter<E, T> valueSetter, + boolean ignored) { + return new Column<E, T>(headerName, + null, + null, + valueParser, + valueSetter, + ignored + ); + } + + public static <E, T> Column<E, T> newImportableExportableColumn(String headerName, + ValueGetter<E, T> valueGetter, + ValueFormatter<T> valueFormatter, + ValueParser<T> valueParser, + ValueSetter<E, T> valueSetter, + boolean ignored) { + return new Column<E, T>(headerName, + valueGetter, + valueFormatter, + valueParser, + valueSetter, + ignored + ); + } + + public static <E, T> Column<E, T> newImportableExportableColumn(String headerName, + ValueGetterSetter<E, T> valueGetterSetter, + ValueParserFormatter<T> valueParserFormatter, + boolean ignored) { + return newImportableExportableColumn(headerName, + valueGetterSetter, + valueParserFormatter, + valueParserFormatter, + valueGetterSetter, + ignored + ); + } + + protected String headerName; + + protected boolean mandatory = true; + + protected boolean ignored; + + protected ValueParser<T> valueParser; + + protected ValueFormatter<T> valueFormatter; + + protected ValueGetter<E, T> valueGetter; + + protected ValueSetter<E, T> valueSetter; + + protected Column(String headerName, + ValueGetter<E, T> valueGetter, + ValueFormatter<T> valueFormatter, + ValueParser<T> valueParser, + ValueSetter<E, T> valueSetter, + boolean ignored) { + this.headerName = headerName; + this.valueGetter = valueGetter; + this.valueFormatter = valueFormatter; + this.valueSetter = valueSetter; + this.valueParser = valueParser; + this.ignored = ignored; + mandatory = !ignored; + } + + @Override + public String getHeaderName() { + return headerName; + } + + @Override + public boolean isMandatory() { + return mandatory; + } + + @Override + public boolean isIgnored() { + return ignored; + } + + @Override + public String formatValue(T value) { + if (valueFormatter == null) { + throw new UnsupportedOperationException("no formatter provided for " + this); + } else { + return valueFormatter.format(value); + } + } + + @Override + public T parseValue(String value) throws ParseException { + if (valueParser == null) { + throw new UnsupportedOperationException("no parser provided for " + this); + } else { + return valueParser.parse(value); + } + } + + @Override + public T getValue(E object) throws Exception { + if (valueGetter == null) { + throw new UnsupportedOperationException("no getter provided for " + this); + } else { + return valueGetter.get(object); + } + } + + @Override + public void setValue(E object, T value) throws Exception { + if (!isIgnored()) { + if (valueSetter == null) { + throw new UnsupportedOperationException("no setter provided for " + this); + } else { + valueSetter.set(object, value); + } + } + } + + @Override + public String toString() { + return "{" + + "headerName='" + headerName + '\'' + + ", mandatory=" + mandatory + + ", ignored=" + ignored + + '}'; + } +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Column.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Common.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Common.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Common.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,296 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +import org.apache.commons.beanutils.BeanUtilsBean; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.lang3.StringUtils; +import org.nuiton.util.StringUtil; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +/** + * TODO + * + * @author bleny <leny@codelutin.com> + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + */ +public class Common { + + public static class StringValueParser implements ValueParserFormatter<String> { + @Override + public String parse(String value) { + return value; + } + + @Override + public String format(String value) { + return value == null ? "" : value; + } + } + + public static final ValueParserFormatter<String> STRING = new StringValueParser(); + + public static class BeanProperty<E, T> implements ValueGetterSetter<E, T> { + + protected String propertyName; + + BeanProperty(String propertyName) { + this.propertyName = propertyName; + } + + @Override + public void set(E bean, T value) throws Exception { + BeanUtilsBean.getInstance().getPropertyUtils().setProperty(bean, propertyName, value); + } + + @Override + public T get(E object) throws Exception { + T value = (T) PropertyUtils.getProperty(object, propertyName); + return value; + } + } + + public static class DateValue implements ValueParserFormatter<Date> { + + protected DateFormat dateFormat; + + public DateValue(String dateFormatPattern) { + this.dateFormat = new SimpleDateFormat(dateFormatPattern); + } + + @Override + public Date parse(String value) throws ParseException { + Date date = null; + if (StringUtils.isNotBlank(value)) { + date = dateFormat.parse(value); + } + return date; + } + + @Override + public String format(Date date) { + String value = ""; + if (date != null) { + value = dateFormat.format(date); + } + return value; + } + } + + public static class ToStringParserFormatter<E> implements ValueParserFormatter<E> { + + protected Map<E, String> toStrings = new HashMap<E, String>(); + + protected Map<String, E> fromString = new HashMap<String, E>(); + + public ToStringParserFormatter(List<E> values) { + this(values, null); + } + + public ToStringParserFormatter(E[] values) { + computeToStrings(values, null); + } + + public ToStringParserFormatter(List<E> values, StringUtil.ToString<E> toString) { + computeToStrings(values, toString); + } + + /** fill toStrings and fromString */ + protected void computeToStrings(E[] values, StringUtil.ToString<E> toString) { + List<E> valuesAsList = new LinkedList<E>(); + Collections.addAll(valuesAsList, values); + computeToStrings(valuesAsList, toString); + } + + /** fill toStrings and fromString */ + protected void computeToStrings(List<E> values, StringUtil.ToString<E> toString) { + for (E value : values) { + String valueToString; + if (toString == null) { + valueToString = value.toString(); + } else { + valueToString = toString.toString(value); + } + toStrings.put(value, valueToString); + fromString.put(valueToString, value); + } + } + + @Override + public String format(E value) { + String valueAsString = toStrings.get(value); + if (valueAsString == null) { + throw new IllegalArgumentException(); + } + return valueAsString; + } + + @Override + public E parse(String valueAsString) throws ParseException { + E value = fromString.get(valueAsString); + if (value == null) { + throw new IllegalArgumentException("Unaple to parse value '" + valueAsString + + "'. Possible values are " + fromString.keySet().toString()); + } + return value; + } + } + + public static class BooleanParserFormatter implements + ValueParserFormatter<Boolean> { + protected Boolean defaultValue; + + protected Boolean nullAllowed; + + public BooleanParserFormatter(Boolean defaultValue, + boolean nullAllowed) { + this.defaultValue = defaultValue; + this.nullAllowed = nullAllowed; + } + + @Override + public String format(Boolean bool) { + String value; + if (bool == null) { + if (nullAllowed) { + value = "?"; + } else { + throw new IllegalArgumentException(); + } + } else if (bool) { + value = "Y"; + } else { + value = "N"; + } + return value; + } + + @Override + public Boolean parse(String value) throws ParseException { + Boolean result; + if (StringUtils.isBlank(value)) { + result = defaultValue; + } else if ("?".equals(value)) { + result = null; + } else if ("Y".equals(value)) { + result = true; + } else if ("N".equals(value)) { + result = false; + } else { + result = Boolean.parseBoolean(value); + } + + if (result == null && !nullAllowed) { + throw new IllegalArgumentException(); + } + return result; + } + } + + public static final ValueParserFormatter<Boolean> BOOLEAN = + new BooleanParserFormatter(null, true); + + public static final ValueParserFormatter<Date> DAY = + new DateValue("dd/MM/yyyy"); + + public static final ValueParserFormatter<Date> DAY_TIME = + new DateValue("dd/MM/yyyy HH:mm"); + + public static final ValueParserFormatter<Date> DAY_TIME_SECOND = + new DateValue("dd/MM/yyyy HH:mm:ss"); + + /** A week in a given year, ie "1/2011" until "52/2011" */ + public static final ValueParserFormatter<Date> WEEK = + new DateValue("w/yyyy"); + + public static class ValueSaver<E, T> implements ValueGetterSetter<E, T> { + + protected T value; + + @Override + public T get(E object) throws Exception { + return value; + } + + @Override + public void set(E object, T value) throws Exception { + this.value = value; + } + } + + public static class IntegerParserFormatter implements ValueParserFormatter<Integer> { + @Override + public String format(Integer value) { + String str = ""; + if (value != null) { + str = String.valueOf(value); + } + return str; + } + + @Override + public Integer parse(String value) throws ParseException { + Integer integer = null; + if (StringUtils.isNotBlank(value)) { + integer = Integer.valueOf(value); + } + return integer; + } + } + + public static ValueParserFormatter<Integer> INTEGER = new IntegerParserFormatter(); + + public static class DoubleParserFormatter implements ValueParserFormatter<Double> { + @Override + public String format(Double value) { + String str = ""; + if (value != null) { + str = String.valueOf(value); + } + return str; + } + + @Override + public Double parse(String value) throws ParseException { + Double doubleValue = null; + if (StringUtils.isNotBlank(value)) { + doubleValue = Double.valueOf(value); + } + return doubleValue; + } + } + + public static ValueParserFormatter<Double> DOUBLE = new DoubleParserFormatter(); +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Common.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Export.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Export.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Export.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,101 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.StringUtil; + +import java.io.InputStream; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +/** + * TODO + * + * @author bleny <leny@codelutin.com> + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + */ +public class Export<E> { + + /** Logger. */ + private static final Log log = LogFactory.getLog(Export.class); + + protected ExportModel<E> model; + + protected Collection<E> data; + + public Export(ExportModel<E> exportModel, Collection<E> data) { + model = exportModel; + this.data = data; + } + + public InputStream startExport() throws Exception { + String separator = String.valueOf(model.getSeparator()); + StringBuilder csv = new StringBuilder(); + + // add headers + List<String> headerNames = new LinkedList<String>(); + for (ExportableColumn<E, ?> column : model.getColumnsForExport()) { + headerNames.add(column.getHeaderName()); + } + String headersLine = StringUtil.join(headerNames, separator, true); + csv.append(headersLine).append("\n"); + + if (log.isDebugEnabled()) { + log.debug("headers for export are '" + headersLine + "'"); + log.debug("will export " + data.size() + " lines"); + } + + for (E object : data) { + for (ExportableColumn<E, Object> column : model.getColumnsForExport()) { + Object value = column.getValue(object); + String formattedValue = column.formatValue(value); + if (formattedValue == null) { + formattedValue = ""; + if (log.isWarnEnabled()) { + log.warn("column for header " + column.getHeaderName() + + " returned a null value." + column.toString()); + } + } + boolean valueNeedQuotes = formattedValue.contains(separator) + || formattedValue.contains("\n") + || formattedValue.contains(";") + || formattedValue.contains(","); + if (valueNeedQuotes) { + // escape '"' char to prevent + formattedValue = formattedValue.replaceAll("\"", "\"\""); + formattedValue = "\"" + formattedValue + "\""; + } + csv.append(formattedValue).append(separator); + } + csv.append("\n"); + } + return IOUtils.toInputStream(csv); + } +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Export.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ExportModel.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ExportModel.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ExportModel.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,42 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +import java.util.Collection; + +/** + * TODO + * + * @author bleny <leny@codelutin.com> + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + */ +public interface ExportModel<E> { + + char getSeparator(); + + Collection<ExportableColumn<E, Object>> getColumnsForExport(); + +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ExportModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ExportableColumn.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ExportableColumn.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ExportableColumn.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,42 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +/** + * TODO + * + * @author bleny <leny@codelutin.com> + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + */ +public interface ExportableColumn<E, T> { + + String getHeaderName(); + + T getValue(E object) throws Exception; + + String formatValue(T value); + +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ExportableColumn.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Import.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Import.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Import.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,319 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +import com.csvreader.CsvReader; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.StringUtil; +import org.nuiton.util.TimeLog; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Set; + +import static org.nuiton.i18n.I18n._; + +/** + * TODO + * + * @author bleny <leny@codelutin.com> + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + */ +public class Import<E> { + + /** Logger. */ + private static final Log log = LogFactory.getLog(Import.class); + + private static final TimeLog timeLog = + new TimeLog(Import.class + "TimeLog"); + + protected ImportModel<E> model; + + protected CsvReader reader; + + /** save once done to prevent multiple headers read leading to consider first lines as headers */ + protected ValidationResult csvValidationResult; + + protected List<ImportableColumn<E, Object>> getNonIgnoredHeaders() { + List<ImportableColumn<E, Object>> nonIgnoredHeaders = new ArrayList<ImportableColumn<E, Object>>(); + for (ImportableColumn<E, Object> field : model.getColumnsForImport()) { + if (!field.isIgnored()) { + nonIgnoredHeaders.add(field); + } + } + return nonIgnoredHeaders; + } + + protected List<ImportableColumn<E, ?>> getAllMandatoryHeaders() { + List<ImportableColumn<E, ?>> allMandatoryHeaders = new ArrayList<ImportableColumn<E, ?>>(); + for (ImportableColumn<E, ?> field : model.getColumnsForImport()) { + if (field.isMandatory()) { + allMandatoryHeaders.add(field); + } + } + return allMandatoryHeaders; + } + + public Import(ImportModel<E> model, InputStream inputStream) { + if (inputStream == null) { + throw new NullPointerException("inputStream is null"); + } + this.model = model; + reader = new CsvReader(inputStream, model.getSeparator(), Charset.forName("UTF-8")); + reader.setTrimWhitespace(true); + } + + public Import(ImportModel<E> model, Reader reader) { + if (reader == null) { + throw new NullPointerException("reader is null"); + } + this.model = model; + this.reader = new CsvReader(reader, model.getSeparator()); + this.reader.setTrimWhitespace(true); + } + + protected boolean validateModel() { + Set<String> headerNames = new HashSet<String>(); + for (ImportableColumn<E, ?> importableColumn : model.getColumnsForImport()) { + String headerName = importableColumn.getHeaderName(); + boolean alreadyUsed = !headerNames.add(headerName); + if (alreadyUsed) { + throw new IllegalArgumentException("model contains multiple columnsForImport named '" + headerName + "'"); + } + } + return true; + } + + public ValidationResult validateCsv() throws IOException { + + if (csvValidationResult == null) { + + boolean canReadHeaders = reader.readHeaders(); + if (!canReadHeaders) { + throw new IOException("can't read headers"); + } + + if (log.isTraceEnabled()) { + log.trace("headers of the CSV file are : " + Arrays.toString(reader.getHeaders())); + } + + model.pushCsvHeaderNames(Arrays.asList(reader.getHeaders())); + + validateModel(); + + csvValidationResult = new ValidationResult(); + csvValidationResult.setSuccess(true); + + List<String> csvHeaders = new ArrayList<String>(); + Collections.addAll(csvHeaders, reader.getHeaders()); + + for (ImportableColumn<E, ?> field : model.getColumnsForImport()) { + csvHeaders.remove(field.getHeaderName()); + } + + if (!csvHeaders.isEmpty()) { + csvValidationResult.setSuccess(false); + List<String> validHeaderNames = new LinkedList<String>(); + for (ImportableColumn<E, ?> importableColumn : model.getColumnsForImport()) { + validHeaderNames.add(importableColumn.getHeaderName()); + } + String validationMessage = _( + "csv.import.error.unrecognizedHeaders", + StringUtil.join(csvHeaders, ", ", true), + StringUtil.join(validHeaderNames, ", ", true)); + csvValidationResult.setMessage(validationMessage); + } + + csvHeaders = new ArrayList<String>(); + Collections.addAll(csvHeaders, reader.getHeaders()); + + List<String> mandatoryHeadersNames = new ArrayList<String>(); + for (ImportableColumn<E, ?> field : getAllMandatoryHeaders()) { + mandatoryHeadersNames.add(field.getHeaderName()); + } + mandatoryHeadersNames.removeAll(csvHeaders); + + if (!mandatoryHeadersNames.isEmpty()) { + csvValidationResult.setSuccess(false); + String validationMessage = _( + "csv.import.error.missingMandatoryHeaders", + StringUtil.join(mandatoryHeadersNames, ", ", true)); + csvValidationResult.setMessage(validationMessage); + } + } + + return csvValidationResult; + } + + public Iterator<E> startImport() throws IOException { + + long startValidateCSV = TimeLog.getTime(); + + ValidationResult validationResult = validateCsv(); + + if (!validationResult.isSuccess()) { + throw new IOException(validationResult.getMessage()); + } + + timeLog.log(startValidateCSV, "validate CSV", "done"); + + readFirstLine(); + + Iterator<E> result = new Iterator<E>() { + + boolean hasNext = true; + + int lineNumber; + + E lastElement; + + @Override + public boolean hasNext() { + return hasNext; + } + + @Override + public E next() throws NoSuchElementException { + + if (!hasNext) { + throw new NoSuchElementException(); + } + + lineNumber += 1; + + long time = TimeLog.getTime(); + + E element = startImportLine(); + + time = timeLog.log(time, "newEmptyInstance"); + + try { + for (ImportableColumn<E, Object> field : getNonIgnoredHeaders()) { + + time = timeLog.log(time, "readValue", "read value for field " + field.getHeaderName()); + String value; + try { + value = reader.get(field.getHeaderName()); + } catch (IOException e) { + reader.close(); + throw new RuntimeException(_("csv.import.error.unableToReadField", field.getHeaderName(), lineNumber), e); + } + time = timeLog.log(time, "readValue", "end read"); + + // contravariance ftw + Object parsedValue; + try { + parsedValue = field.parseValue(value); + } catch (Exception e) { + String message = _("csv.import.error.unableToParseValue", value, field.getHeaderName(), lineNumber) + + "\n" + e.getMessage(); + throw new RuntimeException(message, e); + } + + time = timeLog.log(time, "parseValue"); + + try { + field.setValue(element, parsedValue); + } catch (Exception e) { + String message = _("csv.import.error.unableToSetValue", + parsedValue, + element.toString(), + lineNumber, field.getHeaderName()); + if (log.isErrorEnabled()) { + log.error(message); + } + throw new RuntimeException(message, e); + } + + time = timeLog.log(time, "setValue"); + } + } finally { + endImportLine(element); + } + + lastElement = element; + + try { + hasNext = reader.readRecord(); + } catch (IOException e) { + reader.close(); + throw new RuntimeException(_("csv.import.error.unableToReadLine", lineNumber + 1), e); + } + + if (log.isTraceEnabled()) { + log.trace(timeLog.getCallCount().toString()); + } + + return lastElement; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + + return result; + } + + public E startImportLine() { + E element = model.newEmptyInstance(); + return element; + } + + public void endImportLine(E element) { + // by default do nothing + } + + protected void readFirstLine() { + try { + boolean emptyFile = !reader.readRecord(); + + if (emptyFile) { + throw new IllegalArgumentException("CSV file has no line"); + } + } catch (IOException e) { + reader.close(); + throw new RuntimeException(_("csv.import.error.unableToReadLine", 1), e); + } + } + + public void stopImport() { + reader.close(); + } + +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/Import.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportExportModel.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportExportModel.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportExportModel.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,35 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +/** + * TODO + * + * @author bleny <leny@codelutin.com> + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + */ +public interface ImportExportModel<E> extends ImportModel<E>, ExportModel<E> { +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportExportModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportModel.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportModel.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportModel.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,46 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +import java.util.Collection; +import java.util.List; + +/** + * TODO + * + * @author bleny <leny@codelutin.com> + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + */ +public interface ImportModel<E> { + + char getSeparator(); + + void pushCsvHeaderNames(List<String> headerNames); + + E newEmptyInstance(); + + Collection<ImportableColumn<E, Object>> getColumnsForImport(); +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportableColumn.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportableColumn.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportableColumn.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,46 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +import java.text.ParseException; + +/** + * TODO + * + * @author bleny <leny@codelutin.com> + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + */ +public interface ImportableColumn<E, T> { + String getHeaderName(); + + boolean isMandatory(); + + boolean isIgnored(); + + T parseValue(String value) throws ParseException; + + void setValue(E object, T value) throws Exception; +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportableColumn.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportableExportableColumn.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportableExportableColumn.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportableExportableColumn.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,28 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +public interface ImportableExportableColumn<E, T> extends ImportableColumn<E, T>, ExportableColumn<E, T> { +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ImportableExportableColumn.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ModelBuilder.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ModelBuilder.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ModelBuilder.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,111 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +import java.util.Collection; +import java.util.LinkedList; + +/** + * TODO + * + * @author bleny <leny@codelutin.com> + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + */ +public class ModelBuilder<E> { + + protected Collection<ImportableColumn<E, ?>> columnsForImport = new LinkedList<ImportableColumn<E, ?>>(); + + protected Collection<ExportableColumn<E, ?>> columnsForExport = new LinkedList<ExportableColumn<E, ?>>(); + + public <T> ImportableColumn<E, T> newIgnoredColumn(String headerName) { + Column<E, T> newColumn = Column.newImportableColumn(headerName, null, null, true); + columnsForImport.add(newColumn); + return newColumn; + } + + public ImportableColumn<E, String> newMandatoryColumn(String headerName, String propertyName) { + return newMandatoryColumn(headerName, Common.STRING, propertyName); + } + + public <T> ImportableColumn<E, T> newMandatoryColumn(String headerName, ValueParser<T> valueParser, String propertyName) { + return newMandatoryColumn(headerName, valueParser, new Common.BeanProperty<E, T>(propertyName)); + } + + public ImportableColumn<E, String> newMandatoryColumn(String headerName, ValueSetter<E, String> valueSetter) { + return newMandatoryColumn(headerName, Common.STRING, valueSetter); + } + + public <T> ImportableColumn<E, T> newMandatoryColumn(String headerName, ValueParser<T> valueParser, ValueSetter<E, T> valueSetter) { + Column<E, T> newColumn = Column.newImportableColumn(headerName, valueParser, valueSetter, false); + columnsForImport.add(newColumn); + return newColumn; + } + + public ExportableColumn<E, String> newColumnForExport(String headerName, String propertyName) { + return newColumnForExport(headerName, propertyName, Common.STRING); + } + + public ExportableColumn<E, String> newColumnForExport(String headerName, ValueGetter<E, String> valueGetter) { + return newColumnForExport(headerName, valueGetter, Common.STRING); + } + + public <T> ExportableColumn<E, T> newColumnForExport(String headerName, String propertyName, ValueFormatter<T> valueFormatter) { + return newColumnForExport(headerName, new Common.BeanProperty<E, T>(propertyName), valueFormatter); + } + + public <T> ExportableColumn<E, T> newColumnForExport(String headerName, ValueGetter<E, T> valueGetter, ValueFormatter<T> valueFormatter) { + ExportableColumn<E, T> newColumn = Column.newExportableColumn(headerName, valueGetter, valueFormatter, false); + columnsForExport.add(newColumn); + return newColumn; + } + + public ImportableExportableColumn<E, String> newColumnForImportExport(String headerName, String propertyName) { + return newColumnForImportExport(headerName, propertyName, Common.STRING); + } + + public ImportableExportableColumn<E, String> newColumnForImportExport(String headerName, ValueGetterSetter<E, String> valueGetterSetter) { + return newColumnForImportExport(headerName, valueGetterSetter, Common.STRING); + } + + public <T> ImportableExportableColumn<E, T> newColumnForImportExport(String headerName, String propertyName, ValueParserFormatter<T> valueParserFormatter) { + return newColumnForImportExport(headerName, new Common.BeanProperty<E, T>(propertyName), valueParserFormatter); + } + + public <T> ImportableExportableColumn<E, T> newColumnForImportExport(String headerName, ValueGetterSetter<E, T> valueGetterSetter, ValueParserFormatter<T> valueParserFormatter) { + ImportableExportableColumn<E, T> newColumn = Column.newImportableExportableColumn(headerName, valueGetterSetter, valueParserFormatter, false); + columnsForImport.add(newColumn); + columnsForExport.add(newColumn); + return newColumn; + } + + public Collection<ImportableColumn<E, ?>> getColumnsForImport() { + return columnsForImport; + } + + public Collection<ExportableColumn<E, ?>> getColumnsForExport() { + return columnsForExport; + } +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ModelBuilder.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValidationResult.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValidationResult.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValidationResult.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,110 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +import org.apache.commons.lang3.builder.ToStringBuilder; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.Serializable; + +/** + * TODO + * + * @author bleny <leny@codelutin.com> + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + */ +public class ValidationResult implements Serializable { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_SUCCESS = "success"; + + public static final String PROPERTY_MESSAGE = "message"; + + protected boolean success; + + protected String message; + + protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); + + public boolean getSuccess() { + return success; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + boolean oldValue = getSuccess(); + this.success = success; + firePropertyChange(PROPERTY_SUCCESS, oldValue, success); + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + String oldValue = getMessage(); + this.message = message; + firePropertyChange(PROPERTY_MESSAGE, oldValue, message); + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + pcs.addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcs.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + pcs.removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + pcs.removePropertyChangeListener(propertyName, listener); + } + + @Override + public String toString() { + String toString = ToStringBuilder.reflectionToString(this); + return toString; + } + + protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { + pcs.firePropertyChange(propertyName, oldValue, newValue); + } + + + protected void firePropertyChange(String propertyName, Object newValue) { + firePropertyChange(propertyName, null, newValue); + } + + +} //ValidationResult Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValidationResult.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueFormatter.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueFormatter.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueFormatter.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,38 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +/** + * TODO + * + * @author bleny <leny@codelutin.com> + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + */ +public interface ValueFormatter<T> { + + String format(T value); + +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueFormatter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueGetter.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueGetter.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueGetter.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,38 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +/** + * TODO + * + * @author bleny <leny@codelutin.com> + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + */ +public interface ValueGetter<E, T> { + + T get(E object) throws Exception; + +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueGetter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueGetterSetter.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueGetterSetter.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueGetterSetter.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,35 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +/** + * TODO + * + * @author bleny <leny@codelutin.com> + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + */ +public interface ValueGetterSetter<E, T> extends ValueGetter<E, T>, ValueSetter<E, T> { +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueGetterSetter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueParser.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueParser.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueParser.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,33 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +import java.text.ParseException; + +public interface ValueParser<T> { + + T parse(String value) throws ParseException; + +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueParser.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueParserFormatter.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueParserFormatter.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueParserFormatter.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,28 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +public interface ValueParserFormatter<T> extends ValueParser<T>, ValueFormatter<T> { +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueParserFormatter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueSetter.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueSetter.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueSetter.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,31 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.util.csv; + +public interface ValueSetter<E, T> { + + void set(E object, T value) throws Exception; + +} Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/ValueSetter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/package-info.java =================================================================== --- trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/package-info.java (rev 0) +++ trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/package-info.java 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,32 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2011 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +/** + * This package contains a framework to import and export data from a + * csv file using a model which permits us to validate what to do. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.4 + */ +package org.nuiton.util.csv; \ No newline at end of file Property changes on: trunk/nuiton-csv/src/main/java/org/nuiton/util/csv/package-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-csv/src/main/resources/i18n/nuiton-csv_en_GB.properties =================================================================== --- trunk/nuiton-csv/src/main/resources/i18n/nuiton-csv_en_GB.properties (rev 0) +++ trunk/nuiton-csv/src/main/resources/i18n/nuiton-csv_en_GB.properties 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,4 @@ +csv.import.error.unableToParseValue=Unable to parse value '%s' (column '%s', line %s) +csv.import.error.unableToReadField=Unable to read value of column '%s' at line %s +csv.import.error.unableToReadLine=Unable to read line %s +csv.import.error.unableToSetValue=Unable to set value '%s' (entity '%s', line %s, column '%s') Added: trunk/nuiton-csv/src/main/resources/i18n/nuiton-csv_es_ES.properties =================================================================== --- trunk/nuiton-csv/src/main/resources/i18n/nuiton-csv_es_ES.properties (rev 0) +++ trunk/nuiton-csv/src/main/resources/i18n/nuiton-csv_es_ES.properties 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,4 @@ +csv.import.error.unableToParseValue=Unable to parse value '%s' (column '%s', line %s) +csv.import.error.unableToReadField=Unable to read value of column '%s' at line %s +csv.import.error.unableToReadLine=Unable to read line %s +csv.import.error.unableToSetValue=Unable to set value '%s' (entity '%s', line %s, column '%s') Added: trunk/nuiton-csv/src/main/resources/i18n/nuiton-csv_fr_FR.properties =================================================================== --- trunk/nuiton-csv/src/main/resources/i18n/nuiton-csv_fr_FR.properties (rev 0) +++ trunk/nuiton-csv/src/main/resources/i18n/nuiton-csv_fr_FR.properties 2011-11-22 11:29:24 UTC (rev 2230) @@ -0,0 +1,4 @@ +csv.import.error.unableToParseValue=Erreur lors de l'interprétation de la valeur '%s' (colonne '%s', ligne %s) +csv.import.error.unableToReadField=Impossible de lire la colonne '%s' à la ligne %s +csv.import.error.unableToReadLine=Impossible de lire la ligne %s +csv.import.error.unableToSetValue=Impossible d'enregistrer la valeur '%s' (entité '%s', ligne %s, column '%s') Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2011-11-18 11:28:09 UTC (rev 2229) +++ trunk/pom.xml 2011-11-22 11:29:24 UTC (rev 2230) @@ -2,8 +2,6 @@ <!-- #%L Nuiton Utils - $Id$ - $HeadURL$ %% Copyright (C) 2004 - 2010 CodeLutin, Tony Chemit %% @@ -41,6 +39,7 @@ <modules> <module>nuiton-utils</module> + <module>nuiton-csv</module> <module>nuiton-validator</module> <module>nuiton-profiling</module> </modules> @@ -55,6 +54,12 @@ <version>${nuitonI18nVersion}</version> </dependency> + <dependency> + <groupId>net.sourceforge.javacsv</groupId> + <artifactId>javacsv</artifactId> + <version>2.0</version> + </dependency> + <!-- xworks dependencies --> <dependency>