コード例 #1
0
 public static void loadFromText(String text) {
   try {
     if (singleton == null) {
       // default behavior is to create a singleton for
       // an in memory dbserver
       useDBServer();
     }
     singleton.loadFromText(text);
   } catch (Exception e) {
     ExceptionWindow.getExceptionWindow(e);
   }
 }
コード例 #2
0
 public static void createEmpty() {
   try {
     if (singleton == null) {
       // default behavior is to create a singleton for
       // an in memory dbserver
       useDBServer();
     }
     singleton.createEmpty();
   } catch (Exception e) {
     ExceptionWindow.getExceptionWindow(e);
   }
 }
コード例 #3
0
 public static StorageListener useDBServer(String dbName) {
   // assumed persistent
   if (singleton != null) {
     return (singleton);
   }
   try {
     singleton = (StorageListener) DBServer.init(dbName);
   } catch (Exception e) {
     ExceptionWindow.getExceptionWindow(e);
   }
   return (singleton);
 }
コード例 #4
0
 public static StorageListener useDBServer() {
   // assume in memory with some initial state
   if (singleton != null) {
     return (singleton);
   }
   try {
     singleton = (StorageListener) DBServer.initInMemory();
   } catch (Exception e) {
     ExceptionWindow.getExceptionWindow(e);
   }
   return (singleton);
 }
コード例 #5
0
ファイル: Colors.java プロジェクト: carvalhomb/tsmells
  public static Color getColor(String name, Color def) {
    if (name == null) {
      // System.out.println("illegal color: " + name);
      // Thread.dumpStack();
      return (def);
    }
    name = name.toLowerCase();
    Color nc = (Color) colors.get(name);
    if (nc == null) {
      StringTokenizer st = new StringTokenizer(name, ", ");
      // System.out.println(st.countTokens();

      if ((st.countTokens() < 3) || (st.countTokens() > 4)) {
        // System.out.println("illegal color");
        nc = def;
      } else {
        try {
          int r = Integer.parseInt(st.nextToken());
          int g = Integer.parseInt(st.nextToken());
          int b = Integer.parseInt(st.nextToken());
          if (st.countTokens() == 0) {
            nc = new GuessColor(r, g, b);
          } else {
            int a = Integer.parseInt(st.nextToken());
            nc = new GuessColor(r, g, b, a);
          }
          colors.put(name, nc);
        } catch (Exception e) {
          ExceptionWindow.getExceptionWindow(e);
          StatusBar.setErrorStatus("Invalid color, using default");
          nc = def;
        }
      }
    }
    return (nc);
  }