view software/mpdl-services/mpiwg-mpdl-xml/src/de/mpg/mpiwg/berlin/mpdl/xml/general/Constants.java @ 18:dc5e9fcb3fdc

Erstellung
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Wed, 09 Nov 2011 15:27:46 +0100
parents
children
line wrap: on
line source

package de.mpg.mpiwg.berlin.mpdl.xml.general;

import java.net.URL;
import java.util.Properties;

import de.mpg.mpiwg.berlin.mpdl.util.Util;

public class Constants {
  public static String DEFAULT_LANGUAGE = "en";
  private static Constants instance;
  private Properties properties;

  public static Constants getInstance() {
    if (instance == null) {
      instance = new Constants();
      instance.init();
    }
    return instance;
  }
  
  private void init() {
    URL url = Constants.class.getClassLoader().getResource("constants.properties"); 
    if (url != null) {
      String propertiesFileName = url.toString().substring(5);
      properties = (new Util()).getProperties(propertiesFileName);
    }
  }
  
  public String getDocumentDir() {
    if (properties != null)
      return properties.getProperty("docDir");
    else 
      return "no properties file";
  }
}