1 package fr.paris.lutece.plugins.documentimport.util;
2
3 import fr.paris.lutece.portal.service.util.AppLogService;
4
5 public final class DocumentimportUtils {
6
7 public static final String EMPTY_STRING = "";
8
9
10 public static final String PARAMETER_ID_TYPE_DOCUMENT = "id_type_document";
11
12
13 private static final String REGEX_ID = "^[\\d]+$";
14
15
16
17
18
19
20
21 public static int convertStringToInt( String strParameter )
22 {
23 int nIdParameter = -1;
24
25 try
26 {
27 if ( strParameter != null )
28 {
29 String strTrimedParameter = strParameter.trim( );
30
31 if ( strTrimedParameter.matches( REGEX_ID ) )
32 {
33 nIdParameter = Integer.parseInt( strTrimedParameter );
34 }
35 }
36 }
37 catch ( NumberFormatException ne )
38 {
39 AppLogService.error( ne );
40 }
41
42 return nIdParameter;
43 }
44
45 }