public static void main(String argv[]) {
    RTConfig.setCommandLineArgs(argv);

    long now = DateTime.getCurrentTimeSec();
    long sts = now - DateTime.DaySeconds(3);
    long ets = now;

    GoogleChartTemperature gct = new GoogleChartTemperature();
    try {

      gct.setSize(700, 400);
      gct.setTitle(Color.black, 16, "Temperature");
      gct.setTemperatureRange(1, F2C(0.0), F2C(130.0), 10);
      gct.setDateRange(new DateTime(sts), new DateTime(ets), 8);
      gct.setDateFormat("MM/dd");
      gct.setTimeFormat("HH:mm:ss");

      int setCount = 3;
      int tempCount = 15;
      gct._addRandomSampleData(setCount, tempCount);
      System.out.println(gct.toString());

    } catch (Throwable th) {
      Print.logException("Error", th);
      System.exit(1);
    }
  }
Esempio n. 2
0
 public String toString() {
   String locStr = RTConfig.getString(RTKey.SESSION_LOCALE, null);
   if (StringTools.isBlank(locStr)) {
     return this.getDefault();
   } else {
     Locale loc = I18N.getLocale(locStr);
     return this.toString(loc);
   }
 }
Esempio n. 3
0
 /** ** Gets the scrambled Base64 alphabet ** @return The scrambled Base64 alphabet */
 private static char[] getBase64Alphabet() {
   if (Base64Alphabet == null) {
     BigInteger seed = RTConfig.getBigInteger(PROP_uriArgScrambleSeed, DefaultScrambleSeed);
     Base64Alphabet = Base64.shuffleAlphabet(seed);
     for (int i = 0; i < Base64Alphabet.length; i++) {
       if (Base64Alphabet[i] == '+') {
         Base64Alphabet[i] = '-';
       } else if (Base64Alphabet[i] == '/') {
         Base64Alphabet[i] = '_';
       }
     }
     // Print.logInfo("Base64 Alpha ["+seed+"]: "+StringTools.toStringValue(Base64Alphabet));
   }
   return Base64Alphabet;
 };
Esempio n. 4
0
  /** ** Main entry point for testing/debugging ** @param argv Comand-line arguments */
  public static void main(String argv[]) {
    RTConfig.setCommandLineArgs(argv);

    /* decode URI argument strings */
    if (RTConfig.hasProperty(ARG_DECODE)) {
      String a = RTConfig.getString(ARG_DECODE, "");
      String s = URIArg.decodeArg(new StringBuffer(), a).toString();
      Print.sysPrintln("ASCII: " + s);
      System.exit(0);
    }

    /* encode Base64 strings */
    if (RTConfig.hasProperty(ARG_ENCODE)) {
      String s = RTConfig.getString(ARG_ENCODE, "");
      String a = URIArg.encodeArg(new StringBuffer(), s).toString();
      Print.sysPrintln("Args: " + a);
      System.exit(0);
    }

    /* RTP decode */
    if (RTConfig.hasProperty(ARG_RTPDEC)) {
      URIArg rtpUrl = new URIArg(RTConfig.getString(ARG_RTPDEC, ""));
      URIArg decUrl = rtpUrl.rtpDecode("rtp");
      Print.sysPrintln("URL: " + decUrl.toString());
      System.exit(0);
    }

    /* RTP encode */
    if (RTConfig.hasProperty(ARG_RTPENC)) {
      URIArg decUrl = new URIArg(RTConfig.getString(ARG_RTPENC, ""));
      URIArg rtpUrl = decUrl.rtpEncode("rtp");
      Print.sysPrintln("URL: " + rtpUrl.toString());
      System.exit(0);
    }

    /* no options */
    usage();
  }
Esempio n. 5
0
 /**
  * ** Gets the Localized value for the specified key. The default String text is returned ** if
  * the specified key does not exist ** @param key The LocalStrings key ** @param dft The default
  * String text to return if the LocalStrings key does not exist ** @return The Localized String
  * text
  */
 public String getString(String key, String dft) {
   if (!StringTools.isBlank(key) && (this.resBundle != null)) {
     RTProperties cfgProps = RTConfig.getConfigFileProperties();
     if (!cfgProps.hasProperty(key) || cfgProps.getBoolean(key, true)) {
       try {
         String s = this.resBundle.getString(key);
         if (s != null) {
           return I18N.decodeNewLine(s);
         }
       } catch (Throwable th) {
         // Print.logException("",th);
         // MissingResourceException - if no object for the given key can be found
         // ClassCastException - if the object found for the given key is not a string
       }
     }
   }
   return I18N.decodeNewLine(dft);
 }
Esempio n. 6
0
 /**
  * ** Gets the Java Locale instance based on the specified locale name ** @param loc The name of
  * the Locale ** @param dft The default Locale returned ** @return The Java Locale instance
  */
 public static Locale getLocale(String loc, Locale dft) {
   String locale = !StringTools.isBlank(loc) ? loc : RTConfig.getString(RTKey.LOCALE, "");
   if (StringTools.isBlank(locale)) {
     return dft;
   } else {
     int p = locale.indexOf("_");
     try {
       if (p < 0) {
         String language = locale;
         return new Locale(language);
       } else {
         String language = locale.substring(0, p);
         String country = locale.substring(p + 1);
         return new Locale(language, country);
       }
     } catch (Throwable th) {
       return dft;
     }
   }
 }
Esempio n. 7
0
  /** ** Debug/Testing entry point ** @param argv The command-line args */
  public static void main(String argv[]) {
    RTConfig.setCommandLineArgs(argv);

    if (RTConfig.hasProperty(ARG_PACKAGE)) {
      String pkg = RTConfig.getString(ARG_PACKAGE, "org.opengts.util");
      String loc = RTConfig.getString(ARG_LOCALE, "en");
      String key = RTConfig.getString(ARG_KEY, "");
      Locale locale = I18N.getLocale(loc);
      Print.sysPrintln("Package: " + pkg);
      Print.sysPrintln("Locale : " + locale + " [" + loc + "]");
      Print.sysPrintln("Key    : " + key);
      I18N i18n = I18N.getI18N(pkg, locale);
      if (i18n != null) {
        Print.sysPrintln("String : " + i18n.getString(key, "Undefined"));
      } else {
        Print.sysPrintln("Package resource not found");
      }
      System.exit(0);
    }

    if (RTConfig.hasProperty("test")) {
      I18N i18n = getI18N(I18N.class, null);
      i18n.printKeyValues();
      String m3 =
          i18n.getString(
              "m.m3",
              "{0}",
              new Object() {
                public String toString() {
                  return mainStr;
                }
              });
      String m2 = i18n.getString("m.m2", "How Now Brown {0}", m3);
      String m1 = i18n.getString("m.m1", "Message: \\n{0}", m2);
      Print.sysPrintln(m1);
      mainStr = "Horse";
      Print.sysPrintln(m1);
    }
  }