Changeset 3002


Ignore:
Timestamp:
Dec 5, 2006, 12:44:29 PM (16 years ago)
Author:
dominic
Message:
 
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  
    2525
    2626import java.text.SimpleDateFormat;
     27import java.util.Arrays;
    2728import java.util.Date;
     29import java.util.List;
    2830import java.util.regex.Pattern;
    2931import java.util.regex.Matcher;
     32import java.util.regex.PatternSyntaxException;
    3033import java.util.Collection;
    3134
     35import net.sf.basedb.core.BaseException;
    3236import net.sf.basedb.util.formatter.Formatter;
    3337
     
    826830  }
    827831 
     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  }
    828899}
    829900
Note: See TracChangeset for help on using the changeset viewer.