From: Christian G. [M. Mitch] <mas...@us...> - 2002-01-20 13:09:37
|
Update of /cvsroot/jprojecttimer/jprojecttimer/de/cgarbs/util In directory usw-pr-cvs1:/tmp/cvs-serv9463/util Added Files: Makefile Resource.java Log Message: Moved de.cgarbs.apps.jprojecttimer.Resource to de.cgarbs.util.Resource --- NEW FILE: Makefile --- # $Id: Makefile,v 1.1 2002/01/20 13:09:34 mastermitch Exp $ # these classes are built in this directory CLASSES=Resource.class # # # # # # # # # # # # # # # # # # # # # # ifeq (0, ${MAKELEVEL}) MAKECLASSPATH=./:${CLASSPATH} else MAKECLASSPATH:=../${MAKECLASSPATH} endif export MAKECLASSPATH JFLAGS=-classpath $(MAKECLASSPATH) .SUFFIXES: .java .class .java.class: javac $(JFLAGS) $*.java all: $(CLASSES) for DIR in `find . -maxdepth 1 -mindepth 1 -type d`; do \ test $$DIR != ./CVS && test -d $$DIR && cd $$DIR && $(MAKE) all; \ done;true clean: for DIR in `find . -maxdepth 1 -mindepth 1 -type d`; do \ test $$DIR != ./CVS && test -d $$DIR && cd $$DIR && $(MAKE) clean; \ done;true rm -f *~ rm -f *.class rm -f *.BAK rm -f *.jar atonce: for DIR in `find . -maxdepth 1 -mindepth 1 -type d`; do \ test $$DIR != ./CVS && test -d $$DIR && cd $$DIR && $(MAKE) atonce; \ done;true -javac $(JFLAGS) *.java --- NEW FILE: Resource.java --- /* * $Id: Resource.java,v 1.1 2002/01/20 13:09:34 mastermitch Exp $ * * 2001,2002 (C) by Christian Garbs <mi...@cg...> * * Licensed under GNU GPL (see COPYING for details) * */ package de.cgarbs.util; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; public class Resource { static String resourceFile = "NO RESOURCE FILE GIVEN!"; static Locale currentLocale; static ResourceBundle messages; public static void setResourceFile(String resourceFile) { Resource.resourceFile = resourceFile; } public static void setLocale(Locale newLocale) { currentLocale = newLocale; System.err.println("Current locale is: " + currentLocale); } public static String get(String key) { if (messages == null) { if (currentLocale == null) { setLocale(Locale.getDefault()); } try { messages = ResourceBundle.getBundle(resourceFile, currentLocale); System.err.println("Resource file maintained by: " + Resource.get("MAINTAINER")); } catch ( MissingResourceException e ) { System.err.println(e); System.err.println("No resource file found. This is bad!"); System.exit(1); } } try { return messages.getString(key); } catch (MissingResourceException e) { System.err.println(e); return "???"; } } } |