commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hus...@apache.org
Subject cvs commit: jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/text ConvertUtils.java
Date Thu, 02 Jan 2003 19:46:26 GMT
husted      2003/01/02 11:46:26

  Modified:    scaffold/src/java/org/apache/commons/scaffold/text
                        ConvertUtils.java
  Log:
  + Update JavaDocs.
  
  Revision  Changes    Path
  1.8       +121 -7    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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ConvertUtils.java	21 Nov 2002 02:07:01 -0000	1.7
  +++ ConvertUtils.java	2 Jan 2003 19:46:26 -0000	1.8
  @@ -43,19 +43,28 @@
   */
   
   
  +    /**
  +     * This is an all-static utility class.
  +     * A private constructor prevents inadvertent instantiation.
  +     */
  +    private ConvertUtils() { 
  +        ; // empty 
  +    }
  +
  +
   // ---------------------------------------------------- Text Separators
   
       /**
        * An empty string.
        */
  -    public static String EMPTY_STRING = "";
  +    public static String STRING_EMPTY = "";
   
   
       /**
        * An empty string.
  -     * @deprecated Use EMPTY_STRING
  +     * @deprecated Use STRING_EMPTY
        */
  -    public static String STRING_EMPTY = EMPTY_STRING;
  +    public static String EMPTY_STRING = STRING_EMPTY;
   
   
       /**
  @@ -225,7 +234,7 @@
        * @deprecated Use blank instead.
        */
       public static boolean blank(String s) {
  -        return ((null==s) || (EMPTY_STRING.equals(s.trim())));
  +        return ((null==s) || (STRING_EMPTY.equals(s.trim())));
       }
   
   
  @@ -245,7 +254,16 @@
       public static boolean blankValue(String s) {
           if (null==s) return true;
           String _s = s.trim();
  -        return ((EMPTY_STRING.equals(_s)) || (STRING_ZERO.equals(_s)));
  +        return ((STRING_EMPTY.equals(_s)) || (STRING_ZERO.equals(_s)));
  +    }
  +
  +
  +    /**
  +     * Return a trimmed or empty string (but not null).
  +     */
  +    public static String toTrimOrEmpty(String string) {
  +        if (null==string) return STRING_EMPTY; 
  +        return string.trim();
       }
   
   
  @@ -366,6 +384,18 @@
   
   
       /**
  +     * An Double 0.
  +     */
  +    public static Double DOUBLE_ZERO = new Double(0);
  +
  +
  +    /**
  +     * An Double 1.
  +     */
  +    public static Double DOUBLE_ONE = new Double((double) 1.0);
  +
  +
  +    /**
        * An Integer 0.
        */
       public static Integer INTEGER_ZERO = new Integer(0);
  @@ -753,6 +783,38 @@
   
   // ---------------------------------------------------------- Timestamp
   
  +    /**
  +     * Date separator ["-"].
  +     */
  +    public static final String DATE_SEPARATOR = "-";
  +
  +
  +    /**
  +     * Time separator [":"].
  +     */
  +    public static final String TIME_SEPARATOR = ":";
  +
  +
  +    /**
  +     * Date Time separator [" "].
  +     */
  +    public static final String DATE_TIME_SEPARATOR = STRING_SPACE;
  +
  +
  +    /**
  +     * String to prepend to time [HH:MM:SS.d] 
  +     * to create a Timestamp escape string ["0002-11-30"].
  +     */
  +    public static final String TIMESTAMP_DATE_ZERO = "0002-11-30";
  +
  +
  +    /**
  +     * String to append to date [YEAR-MM-DD] 
  +     * to create a Timestamp escape string [" 00:00:00.0"].
  +     * Note: includes leading space.
  +     */
  +    public static final String TIMESTAMP_TIME_ZERO = " 00:00:00.0";
  +    
   
       /**
        * Escape string representing
  @@ -762,6 +824,13 @@
   
   
       /**
  +     * Timestamp representing ""November 30, 0002 00:00:00".
  +     */
  +    public static Timestamp ZERO_TIMESTAMP = new Timestamp((long) 00000000000000);
  +
  +
  +
  +    /**
        * Escape string to create Timestamp representing
        * "January 1, 1970 00:00:00".
        */
  @@ -788,7 +857,13 @@
        * Timestamp representing "January 1, 1970 00:00:00".
        */
       public static Timestamp NULL_TIMESTAMP = new Timestamp(NULL_TIME);
  -
  +    
  +    
  +    
  +    /**
  +     * Timestamp representing "December 31, 2029, 23:59:59.9"
  +     */
  +    public static Timestamp MAX_TIMESTAMP = Timestamp.valueOf("2029-12-31 23:59:59.999");
   
   
       /**
  @@ -886,6 +961,30 @@
   
   
       /**
  +     * Return a Timestamp based on the parameters.
  +     * Any nulls or conversion error returns null.
  +     * @param year The year
  +     * @param month The month
  +     * @param day The day   
  +     * @returns Timestamp for year-month-day
  +     */    
  +    public static Timestamp toTimestamp(String year, String month, String day) {
  +        
  +        if ((null==year) || (null==month) || (null==day)) return null;
  +        
  +        StringBuffer sb = new StringBuffer();
  +        // YEAR-MM-DD 00:00:00.0
  +        sb.append(year);   sb.append(DATE_SEPARATOR); 
  +        sb.append(month);  sb.append(DATE_SEPARATOR); 
  +        sb.append(day); 
  +        
  +        sb.append(TIMESTAMP_TIME_ZERO);
  +        
  +        return toTimestamp(sb.toString());        
  +    }
  +
  +
  +    /**
        * Return String value representing Timestamp.
        * Null returns null.
        * @param Timestamp
  @@ -896,6 +995,21 @@
           else
               return timestamp.toString();
       }
  +
  +
  +// ----------------------------------------------------------- Internet
  +
  +
  +    /**
  +     * Return the integer value of an IP address in dotted octet form, 
  +     * like that returned by request.getRemotehost).
  +     * :FIXME: Needs to be implemented; just returns zero.
  +     * @param Timestamp
  +     */
  +    public static Integer ipNode(String ipAddress) { 
  +        return INTEGER_ZERO;
  +    }
  +
   
   }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message