Back to index

wims  3.65+svn20090927
ResourcesManager.java
Go to the documentation of this file.
00001 /*
00002 $Id: ResourcesManager.java,v 1.2 2003/02/18 11:48:48 sander Exp $
00003 */
00004 
00005 
00006 package fr.ove.utils;
00007 
00008 import java.net.*;
00009 import java.util.*;
00010 
00020 public class ResourcesManager implements java.io.Serializable {
00021     private ResourceBundle resources;
00022     
00029     public ResourcesManager(String resourcesName) {
00030         try {
00031             //resources = ResourceBundle.getBundle(resourcesName, Locale.getDefault());
00032             resources = ResourceBundle.getBundle(resourcesName);
00033         } 
00034             catch (MissingResourceException mre) {
00035                 System.err.println(resourcesName+".properties not found");
00036                 System.exit(1);
00037         }
00038     }
00039 
00043     public String getResourceString(String prop) {
00044         String str;
00045         try {
00046             str = resources.getString(prop);
00047         } 
00048         catch (MissingResourceException mre) {
00049             str = null;
00050         }
00051 
00052         return str;
00053     }
00054 
00058     public String [] getResourceStrings(String prop) {
00059         return tokenize(getResourceString (prop));
00060     }
00061 
00068     private String[] tokenize(String input) {
00069         if (input != null) {
00070             Vector v = new Vector();
00071             StringTokenizer t = new StringTokenizer (input, ":");
00072             String cmd[];
00073 
00074             while (t.hasMoreTokens())
00075                 v.addElement(t.nextToken());
00076                 
00077             cmd = new String[v.size()];
00078             for (int i = 0; i < cmd.length; i++)
00079                 cmd[i] = (String) v.elementAt(i);
00080 
00081             return cmd;
00082         }
00083         else
00084             return new String [0];
00085     }
00086 }