1 package fr.paris.lutece.plugins.crm.util;
2
3 import fr.paris.lutece.portal.service.util.AppLogService;
4 import fr.paris.lutece.util.xml.XmlUtil;
5
6 public class CrmUtils
7 {
8
9 public static final int CONSTANT_ID_NULL = -1;
10
11 private static final String REGEX_ID = "^[\\d]+$";
12
13
14
15
16
17
18
19
20 public static int convertStringToInt( String strParameter )
21 {
22 int nIdParameter = -1;
23
24 try
25 {
26 if ( ( strParameter != null ) && strParameter.matches( REGEX_ID ) )
27 {
28 nIdParameter = Integer.parseInt( strParameter );
29 }
30 }
31 catch( NumberFormatException ne )
32 {
33 AppLogService.error( ne );
34 }
35
36 return nIdParameter;
37 }
38
39
40
41
42
43
44
45
46
47
48
49 public static void addElementHtml( StringBuffer strXmlBuffer, String strTag, String strValue )
50 {
51 if ( strValue != null )
52 {
53 XmlUtil.addElementHtml( strXmlBuffer, strTag, strValue );
54 }
55 else
56 {
57 XmlUtil.addEmptyElement( strXmlBuffer, strTag, null );
58 }
59 }
60
61 }