r2256 - in trunk: nuiton-csv/src nuiton-csv/src/site nuiton-csv/src/site/apt src/site/apt
Author: tchemit Date: 2011-12-14 08:38:25 +0100 (Wed, 14 Dec 2011) New Revision: 2256 Url: http://nuiton.org/repositories/revision/nuiton-utils/2256 Log: begin of doc for nuiton-csv Added: trunk/nuiton-csv/src/site/ trunk/nuiton-csv/src/site/apt/ trunk/nuiton-csv/src/site/apt/index.apt trunk/nuiton-csv/src/site/site_fr.xml Modified: trunk/src/site/apt/index.apt Added: trunk/nuiton-csv/src/site/apt/index.apt =================================================================== --- trunk/nuiton-csv/src/site/apt/index.apt (rev 0) +++ trunk/nuiton-csv/src/site/apt/index.apt 2011-12-14 07:38:25 UTC (rev 2256) @@ -0,0 +1,147 @@ +~~~ +~~ #%L +~~ Nuiton Utils :: Nuiton Csv +~~ +~~ $Id$ +~~ $HeadURL$ +~~ %% +~~ Copyright (C) 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% +~~~ + ---- + Nuiton csv + ---- + ---- + 2011-12-14 + ---- + +Présentation + + nuiton-csv définit une api simple d'import-export au format csv. Cette api + permet de construire un modèle d'import (et/ou d'export) où les différentes + préocupations sont bien séparées. + + Pour un import, et pour chaque ligne à importer, on a trois choses à faire : + + - lire la donnée depuis la source d'entrée + + - convertir la donnée en objet + + - persister la donnée convertie dans un objet + + La classe <<org.nuiton.util.csv.Import>> permet simplement d'effectuer des + imports, une fois le modèle crée. + + Pour un export et pour chaque objet à persister dans le fichier csv, on a + aussi trois choses : + + - lire la donnée depuis l'objet à persister + + - convertir la donnée au format texte + + - persister la donnée convertie dans le flux de sortie + + La classe <<org.nuiton.util.csv.Export>> permet simplement d'effectuer un + export, une fois le modèle d'export crée et les données à persister récupérées. + +Api + +* org.nuiton.util.csv.ValueFormatter + + A faire. + +* org.nuiton.util.csv.ValueParser + + A faire. + +* org.nuiton.util.csv.ValueParserFormatter + + A faire. + +* org.nuiton.util.csv.ImportModel + + A faire. + +* org.nuiton.util.csv.ExportModel + + A faire. + +* org.nuiton.util.csv.ImportExportModel + + A faire. + +* org.nuiton.util.csv.ModelBuilder + + A faire. + +* org.nuiton.util.csv.Import + + A faire. + +* org.nuiton.util.csv.Export + + A faire. + +Exemple + +* Construire un modèle d'import/export + +-------------------------------------------------------------------------------- +A faire... +-------------------------------------------------------------------------------- + +* Importer des données + +-------------------------------------------------------------------------------- + +// création du modèle d'import csv +ImportModel<E> csvModel = null; + +// creation d'un importer à partir d'un modèle et d'un reader sur fichier csv +Import<E> importer = Import.newImport(csvModel, reader); + +try { + + // parcours des objets crées à partir de chaque ligne du fichier csv + for (E entity : importer) { + + // A vous :) + + } +} finally { + + // fermeture de l'importer (ne ferme pas le flux d'entrée) + importer.close(); +} +-------------------------------------------------------------------------------- + +* Exporter des données + +-------------------------------------------------------------------------------- + +// création du modèle d'export csv +ExportModel<E> csvModel = null; + +// les données à exporter +Iterable<E> datas = null; + +// création d'un exporter +Export<E> exporter = Export.newExport(csvModel, datas); + +// lancement de l'export vers le fichier +exporter.exportToFile(new File("output.csv")); +-------------------------------------------------------------------------------- Property changes on: trunk/nuiton-csv/src/site/apt/index.apt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/nuiton-csv/src/site/site_fr.xml =================================================================== --- trunk/nuiton-csv/src/site/site_fr.xml (rev 0) +++ trunk/nuiton-csv/src/site/site_fr.xml 2011-12-14 07:38:25 UTC (rev 2256) @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Nuiton Utils :: Nuiton Csv + + $Id$ + $HeadURL$ + %% + Copyright (C) 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% + --> + + + +<project name="${project.name}"> + + <bannerLeft> + <name>${project.name}</name> + <href>index.html</href> + </bannerLeft> + + <poweredBy> + <logo href="http://maven.apache.org" name="Maven" + img="images/logos/maven-feather.png"/> + </poweredBy> + + <body> + + <breadcrumbs> + <item name="${project.name}" href="http://maven-site.nuiton.org/nuiton-utils/nuiton-csv/index.html"/> + </breadcrumbs> + + <menu ref="modules"/> + + <menu name="Utilisateur"> + <item name="Accueil" href="index.html"/> + </menu> + + <menu ref="reports"/> + + </body> +</project> Property changes on: trunk/nuiton-csv/src/site/site_fr.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/site/apt/index.apt =================================================================== --- trunk/src/site/apt/index.apt 2011-12-11 18:07:30 UTC (rev 2255) +++ trunk/src/site/apt/index.apt 2011-12-14 07:38:25 UTC (rev 2256) @@ -63,3 +63,9 @@ permettant nottament de préciser des scopes (info, erreur, warning, ...) {{{./nuiton-validator}Plus d'infos}} + +Librairie Nuiton-csv + + Cette librairie propose une Api simple d'import export au format csv. + + {{{./nuiton-csv}Plus d'infos}}
participants (1)
-
tchemit@users.nuiton.org