Kenmegne
7 days ago 23a46b4be35277e06ec89f48730eeb694e686be8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.megatim.fdxcommons.core.impl.tools;
 
import com.megatim.fdxcommons.model.enumeration.TypeDonnee;
import com.megatim.fdxcommons.model.integration.ColumnDefinition;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 *
 * @author ASUS
 */
public class CommonUtilities {
 
    /**
     * Méthode qui récupère l'encodage d'un fichier
     *
     * @param file : Fichier dont on veut connaître l'encodage
     * @return : retourne l'encodage le plus probable
     * @throws FileNotFoundException
     * @throws IOException
     */
    public static Charset getCharset(File file) throws FileNotFoundException, IOException {
        return StandardCharsets.UTF_8;
    }
 
    public static Map<String, ColumnDefinition> columnDefinitionsToMap(List<ColumnDefinition> columnDefinitions) {
        Map<String, ColumnDefinition> columnDefinitionsMap = new HashMap<>();
        columnDefinitions.stream().forEach(c -> columnDefinitionsMap.put(c.getName(), c));
 
        return columnDefinitionsMap;
    }
 
    public static Class<?> fullQualifiedNameTypeFromTypeDonnee(TypeDonnee typeDonnee) {
        switch (typeDonnee) {
            case NUMERIQUE:
                return java.lang.Long.class;
            case DATE:
                return java.time.LocalDateTime.class;
            case DECIMAL:
                return java.math.BigDecimal.class;
            default:
                return java.lang.String.class;
        }
    }
 
}