husted      2002/11/20 18:07:01

  Modified:    scaffold/src/java/org/apache/commons/scaffold/text
                        ConvertUtils.java
  Log:
  + ConvertUtils: Add and refactor some Timestamp methods.
  + ConvertUtils: Add tokenTo* methods.
  
  Revision  Changes    Path
  1.7       +59 -1     
jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/text/ConvertUtils.java
  
  Index: ConvertUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/text/ConvertUtils.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ConvertUtils.java 13 Nov 2002 19:15:30 -0000      1.6
  +++ ConvertUtils.java 21 Nov 2002 02:07:01 -0000      1.7
  @@ -10,10 +10,12 @@
   
   import java.util.Date;
   import java.util.Iterator;
  +import java.util.List;
   import java.util.Locale;
   import java.util.Map;
   import java.util.Map.Entry;
   import java.util.Set;
  +import java.util.StringTokenizer;
   
   import java.sql.Timestamp;
   
  @@ -138,6 +140,55 @@
               UNIT_SEPARATOR
           };
   
  +// --------------------------------------------------------- Tokenizers
  +
  +
  +    /**
  +     * Return array of tokens,
  +     * using the result of <code>getTokeSep()</code> as the
  +     * separator.
  +     * Blanks are trimmed from tokens.
  +     *
  +     * @param parameter The string to tokenize into an array
  +     */
  +    public static String[] tokensToArray(String tokens, String separator) {
  +
  +        StringTokenizer tokenizer =
  +            new StringTokenizer(tokens,separator);
  +        int i = 0;
  +        String[] array = new String[tokenizer.countTokens()];
  +        while (tokenizer.hasMoreTokens()) {
  +            String token = tokenizer.nextToken().trim();
  +            if ((token==null) || (token.length()==0)) continue;
  +            array[i++] = token;
  +        }
  +        return array;
  +        
  +    } // end tokensToArray
  +    
  +
  +    /**
  +     * Return list of tokens,
  +     * using the result of <code>getTokeSep()</code> as the
  +     * separator.
  +     * Blanks are trimmed from tokens.
  +     *
  +     * @param parameter The string to tokenize into an array
  +     */
  +    public static List tokensToList(String tokens, String separator) {
  +
  +        StringTokenizer tokenizer =
  +            new StringTokenizer(tokens,separator);
  +        List list = new java.util.ArrayList(tokenizer.countTokens());
  +        while (tokenizer.hasMoreTokens()) {
  +            String token = tokenizer.nextToken().trim();
  +            if ((token==null) || (token.length()==0)) continue;
  +            list.add(token);
  +        }
  +        return list;
  +        
  +    } // end tokensToList
  +    
   
   // ------------------------------------------------------- Text Methods
   
  @@ -701,6 +752,13 @@
   
   
   // ---------------------------------------------------------- Timestamp
  +
  +
  +    /**
  +     * Escape string representing
  +     * "November 30, 0002 00:00:00".
  +     */    
  +     public static String ZERO_TIMESTAMP_DISPLAY = "2-11-30 00:00:00";
   
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to