Home | History | Annotate | Download | only in test
      1 /* GENERATED SOURCE. DO NOT MODIFY. */
      2 /**
      3  *******************************************************************************
      4  * Copyright (C) 2003-2011, International Business Machines Corporation and
      5  * others. All Rights Reserved.
      6  *******************************************************************************
      7  */
      8 package android.icu.dev.test;
      9 
     10 import java.util.Calendar;
     11 import java.util.Date;
     12 import java.util.GregorianCalendar;
     13 
     14 import android.icu.util.VersionInfo;
     15 
     16 public abstract class AbstractTestLog implements TestLog {
     17     /**
     18      * Returns true if ICU_Version < major.minor.
     19      */
     20     static public boolean isICUVersionBefore(int major, int minor) {
     21         return isICUVersionBefore(major, minor, 0);
     22     }
     23 
     24     /**
     25      * Returns true if ICU_Version < major.minor.milli.
     26      */
     27     static public boolean isICUVersionBefore(int major, int minor, int milli) {
     28         return VersionInfo.ICU_VERSION.compareTo(VersionInfo.getInstance(major, minor, milli)) < 0;
     29     }
     30 
     31     /**
     32      * Returns true if ICU_Version >= major.minor.
     33      */
     34     static public boolean isICUVersionAtLeast(int major, int minor) {
     35         return isICUVersionAtLeast(major, minor, 0);
     36     }
     37 
     38     /**
     39      * Returns true if ICU_Version >= major.minor.milli.
     40      */
     41     static public boolean isICUVersionAtLeast(int major, int minor, int milli) {
     42         return !isICUVersionBefore(major, minor, milli);
     43     }
     44 
     45     /**
     46      * Add a message.
     47      */
     48     public final void log(String message) {
     49         msg(message, LOG, true, false);
     50     }
     51 
     52     /**
     53      * Add a message and newline.
     54      */
     55     public final void logln(String message) {
     56         msg(message, LOG, true, true);
     57     }
     58 
     59     /**
     60      * Report an error.
     61      */
     62     public final void err(String message) {
     63         msg(message, ERR, true, false);
     64     }
     65 
     66     /**
     67      * Report an error and newline.
     68      */
     69     public final void errln(String message) {
     70         msg(message, ERR, true, true);
     71     }
     72 
     73     /**
     74      * Report a warning (generally missing tests or data).
     75      */
     76     public final void warn(String message) {
     77         msg(message, WARN, true, false);
     78     }
     79 
     80     /**
     81      * Report a warning (generally missing tests or data) and newline.
     82      */
     83     public final void warnln(String message) {
     84         msg(message, WARN, true, true);
     85     }
     86 
     87     /**
     88      * Vector for logging.  Callers can force the logging system to
     89      * not increment the error or warning level by passing false for incCount.
     90      *
     91      * @param message the message to output.
     92      * @param level the message level, either LOG, WARN, or ERR.
     93      * @param incCount if true, increments the warning or error count
     94      * @param newln if true, forces a newline after the message
     95      */
     96     public abstract void msg(String message, int level, boolean incCount, boolean newln);
     97 
     98     /**
     99      * Not sure if this class is useful.  This lets you log without first testing
    100      * if logging is enabled.  The Delegating log will either silently ignore the
    101      * message, if the delegate is null, or forward it to the delegate.
    102      */
    103     public static final class DelegatingLog extends AbstractTestLog {
    104         private TestLog delegate;
    105 
    106         public DelegatingLog(TestLog delegate) {
    107             this.delegate = delegate;
    108         }
    109 
    110         public void msg(String message, int level, boolean incCount, boolean newln) {
    111             if (delegate != null) {
    112                 delegate.msg(message, level, incCount, newln);
    113             }
    114         }
    115     }
    116     public boolean isDateAtLeast(int year, int month, int day){
    117         Date now = new Date();
    118         Calendar c = new GregorianCalendar(year, month, day);
    119         Date dt = c.getTime();
    120         if(now.compareTo(dt)>=0){
    121             return true;
    122         }
    123         return false;
    124     }
    125 }
    126