Changeset 3002
- Timestamp:
- Dec 5, 2006, 12:44:29 PM (16 years ago)
- Location:
- branches/tab2mage_ebi/src
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/tab2mage_ebi/src/core/net/sf/basedb/util/Values.java
r2981 r3002 25 25 26 26 import java.text.SimpleDateFormat; 27 import java.util.Arrays; 27 28 import java.util.Date; 29 import java.util.List; 28 30 import java.util.regex.Pattern; 29 31 import java.util.regex.Matcher; 32 import java.util.regex.PatternSyntaxException; 30 33 import java.util.Collection; 31 34 35 import net.sf.basedb.core.BaseException; 32 36 import net.sf.basedb.util.formatter.Formatter; 33 37 … … 826 830 } 827 831 832 /** 833 * Convert a string value with a delimeter into a list 834 * @param values, the values to convert 835 * @param delimeter, the delimeter in the string 836 * @return the list of string values 837 */ 838 public static final List<String> getList(String values, String delimeter) 839 { 840 List<String> value = null; 841 String[] result; 842 if (values != null ) 843 { 844 try 845 { 846 result =values.split(delimeter); 847 value= Arrays.asList(result); 848 } 849 catch(PatternSyntaxException pse) 850 { 851 new BaseException(pse.getMessage()); 852 } 853 } 854 return value; 855 } 856 857 /** 858 * Convert a string value with a delimeter into a list 859 * @param values, the values to convert 860 * @param delimeter, the delimeter in the string 861 * @return the list of string values 862 */ 863 public static final String getStringRemoveSpace(String values, String delimeter) 864 { 865 String value =""; 866 List<String> val; 867 String[] result; 868 if (values != null ) 869 { 870 try 871 { 872 result =values.split(delimeter); 873 val= Arrays.asList(result); 874 for (String v : val) 875 { 876 value= value.concat(v); 877 } 878 } 879 catch(PatternSyntaxException pse) 880 { 881 new BaseException(pse.getMessage()); 882 } 883 } 884 return value; 885 } 886 /** 887 This methods handle null values and change them into an empty string 888 @param obj, the value to convert into an empty string 889 @return an empty string 890 */ 891 public static final Object getEmptyStringIfNull (Object obj) 892 { 893 String empty=""; 894 if (obj == null){ 895 obj=empty; 896 } 897 return obj; 898 } 828 899 } 829 900
Note: See TracChangeset
for help on using the changeset viewer.