Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
scrutaridata:exportapi:java [2010/02/11 18:01] – vincent | scrutaridata:exportapi:java [2016/09/22 14:06] (Version actuelle) – vincent | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== Implémentation de l'API en JAVA ====== | ====== Implémentation de l'API en JAVA ====== | ||
- | L' | + | L' |
* Fichier JAR : [[http:// | * Fichier JAR : [[http:// | ||
- | * Sources : [[http:// | + | * Sources : [[http:// |
* JavaDoc : [[http:// | * JavaDoc : [[http:// | ||
+ | |||
+ | |||
+ | Les sources sont accessibles avec Git via https:// | ||
+ | |||
+ | Un autre accès avec Subversion : | ||
+ | |||
+ | svn co http:// | ||
===== Utilisation de l' | ===== Utilisation de l' | ||
Ligne 13: | Ligne 20: | ||
<code java> | <code java> | ||
- | public static net.scrutari.dataexport.api.ScrutariDataExport | + | ScrutariDataExport |
</ | </ | ||
+ | Cette méthode prend comme argument : | ||
+ | |||
+ | * Appendable appendable : instance de l' | ||
+ | * int indentLength : indique s'il faut indenter le code XML pour le rendre plus lisible, cette valeur peut être supérieure à zéro si le code est inclus dans un code XML plus large. Pour n' | ||
+ | * boolean includeXMLDeclaration : indique s'il faut rajouter la déclaration XML (''<? | ||
+ | |||
+ | La méthode renvoie une instance de l' | ||
+ | |||
+ | ===== Exemple d' | ||
+ | |||
+ | L' | ||
+ | |||
+ | <code java> | ||
+ | import net.scrutari.dataexport.*; | ||
+ | import net.scrutari.dataexport.api.*; | ||
+ | import java.io.*; | ||
+ | |||
+ | public class ScrutariDataExportExample { | ||
+ | |||
+ | public static void main(String[] args) throws IOException { | ||
+ | /* Ouverture d'un fichier en écriture */ | ||
+ | File file = new File(" | ||
+ | BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), | ||
+ | |||
+ | /*Création d'une instance de ScrutariDataExport */ | ||
+ | ScrutariDataExport scrutariDataExport = ScrutariDataExportFactory.newInstance(bufferedWriter, | ||
+ | |||
+ | /*Début de l' | ||
+ | BaseMetadataExport baseMetadataExport = scrutariDataExport.startExport(); | ||
+ | |||
+ | / | ||
+ | baseMetadataExport.setAuthority(" | ||
+ | baseMetadataExport.setBaseName(" | ||
+ | baseMetadataExport.setBaseIcon(" | ||
+ | baseMetadataExport.setIntitule(BaseMetadataExport.INTITULE_SHORT, | ||
+ | baseMetadataExport.setIntitule(BaseMetadataExport.INTITULE_SHORT, | ||
+ | baseMetadataExport.setIntitule(BaseMetadataExport.INTITULE_LONG, | ||
+ | baseMetadataExport.setIntitule(BaseMetadataExport.INTITULE_LONG, | ||
+ | baseMetadataExport.addLangUI(" | ||
+ | baseMetadataExport.addLangUI(" | ||
+ | |||
+ | /*Insertion d'un corpus avec de nom « fiches » */ | ||
+ | CorpusMetadataExport corpusMetadataExport = scrutariDataExport.newCorpus(" | ||
+ | |||
+ | / | ||
+ | corpusMetadataExport.setCorpusType(" | ||
+ | corpusMetadataExport.setIntitule(CorpusMetadataExport.INTITULE_CORPUS, | ||
+ | corpusMetadataExport.setIntitule(CorpusMetadataExport.INTITULE_FICHE, | ||
+ | |||
+ | /* Définition de deux champs complémentaires */ | ||
+ | int numero1 = corpusMetadataExport.addComplement(); | ||
+ | corpusMetadataExport.setComplementIntitule(numero1," | ||
+ | corpusMetadataExport.setComplementIntitule(numero1," | ||
+ | int numero2 = corpusMetadataExport.addComplement(); | ||
+ | corpusMetadataExport.setComplementIntitule(numero2," | ||
+ | |||
+ | |||
+ | /* Premier exemple d'une fiche*/ | ||
+ | FicheExport ficheExport = scrutariDataExport.newFiche(" | ||
+ | ficheExport.setTitre(" | ||
+ | ficheExport.setFicheType(" | ||
+ | ficheExport.setDate(" | ||
+ | ficheExport.addComplement(2," | ||
+ | ficheExport.setFicheIcon(" | ||
+ | |||
+ | /* Second exemple de fiche, on réutilise le pointeur ficheExport */ | ||
+ | ficheExport = scrutariDataExport.newFiche(" | ||
+ | ficheExport.setSoustitre(" | ||
+ | ficheExport.setTitre(" | ||
+ | ficheExport.setDate(" | ||
+ | ficheExport.setLang(" | ||
+ | ficheExport.setHref(" | ||
+ | ficheExport.addComplement(2," | ||
+ | ficheExport.addComplement(1," | ||
+ | |||
+ | /* Exemple d' | ||
+ | * même s'il ne s'agit du mot-clé ou de la fiche en cours ou que le thésaurus ou le corpus | ||
+ | * n'ont pas encore été définis. */ | ||
+ | scrutariDataExport.addIndexation(" | ||
+ | |||
+ | /* Insertion d'un thésaurus de nom « motscles » */ | ||
+ | ThesaurusMetadataExport thesaurusMetadataExport = scrutariDataExport.newThesaurus(" | ||
+ | |||
+ | /* Définition des métadonnées du thésaurus */ | ||
+ | thesaurusMetadataExport.setIntitule(ThesaurusMetadataExport.INTITULE_THESAURUS," | ||
+ | thesaurusMetadataExport.setIntitule(ThesaurusMetadataExport.INTITULE_THESAURUS," | ||
+ | |||
+ | /* Exemple d' | ||
+ | MotcleExport motcleExport = scrutariDataExport.newMotcle(" | ||
+ | motcleExport.setLibelle(" | ||
+ | |||
+ | /* Autre exemple d' | ||
+ | scrutariDataExport.addIndexation(" | ||
+ | |||
+ | /* L' | ||
+ | * toujours sur le premier mot-clé */ | ||
+ | motcleExport.setLibelle(" | ||
+ | |||
+ | /* Fin de l' | ||
+ | scrutariDataExport.endExport(); | ||
+ | |||
+ | /* Fermeture du fichier */ | ||
+ | bufferedWriter.close(); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ | ||