1 4 5 9 10 package org.openlaszlo.utils; 11 12 import java.util.Enumeration ; 13 import java.util.Properties ; 14 import java.util.Date ; 15 import java.util.GregorianCalendar ; 16 import java.util.Calendar ; 17 18 21 public class LZUtils 22 { 23 29 static public int getInt(Object o) 30 { 31 if (o == null) 32 return 0; 33 34 if (! o.getClass().getName().equals("java.lang.Integer")) 35 return 0; 36 37 return ((Integer )o).intValue(); 38 } 39 40 41 47 static public String getStr(Object o) 48 { 49 return getStr(o, true); 50 } 51 52 53 62 static public String getStr(Object o, boolean isNullOk) 63 { 64 if (o == null) 65 return (isNullOk?null:""); 66 67 if (! o.getClass().getName().equals("java.lang.String")) 68 return (isNullOk?null:""); 69 70 return (String )o; 71 } 72 73 74 79 static public int parseInt(String s) 80 { 81 int n = 0; 82 try { 83 n = Integer.parseInt(s); 84 } catch (Exception e) { 85 } 87 return n; 88 } 89 90 98 static public Properties expandProperties(Properties p) 99 throws Exception 100 { 101 Properties _p = new Properties (); 102 Enumeration keys = p.keys(); 103 while (keys.hasMoreElements()) { 104 String k = (String )keys.nextElement(); 105 String v = (String )p.getProperty(k); 106 _p.setProperty(k, StringUtils.expandPropertyValues(v)); 107 } 108 return _p; 109 } 110 } 111 | Popular Tags |