Exemplo n.º 1
0
 /** figures out where the database should be at */
 private static String determineDatabaseLocation(
     final IWindowUtils windowUtils, final ITextConfigFileManager textfileManager) {
   // look for text config file
   final Box<File> configFile = textfileManager.getConfigFileBasedOnOS();
   String databasePath = null;
   // use it to load the db
   if (configFile.hasContent() && configFile.getContent().exists()) {
     final Properties properties = new Properties();
     try {
       properties.load(new FileInputStream(configFile.getContent()));
       databasePath = properties.getProperty(TextConfigFileManager.DATABASE_PROPERTY_IN_CONFIG);
       LOG.debug("Database location was set to " + databasePath);
     } catch (final FileNotFoundException e) {
       // code should proceed, a new file will be chosen
     } catch (final IOException e) {
       // likewise above
     }
   }
   if (StringUtils.isEmpty(databasePath)) {
     databasePath = ApprenticeConfiguration.getDefaultDatabasePath();
     if (!new File(databasePath).exists()) {
       databasePath = getDatabaseLocationWhenExpectedFileWasNotFound(databasePath, windowUtils);
     }
   }
   return databasePath;
 }
Exemplo n.º 2
0
 // @SuppressWarnings("unchecked")
 @Override
 public boolean equals(final Object other) {
   if (other instanceof Box) {
     @SuppressWarnings("rawtypes")
     final Box o = (Box) other;
     if (hasContent() && o.hasContent()) {
       return getContent().equals(o.getContent());
     } else {
       return isEmpty && o.isEmpty;
     }
   } else {
     return false;
   }
 }