Package nexj.core.util

Examples of nexj.core.util.StringTable


            return (StringTable)obj;
         }
      }

      StringTable stringTable = null;
      int i = sLocale.lastIndexOf('_');

      if (i > 0)
      {
         stringTable = getStringTable(sLocale.substring(0, i));
      }
      else if (!sLocale.equals(DEFAULT_LOCALE))
      {
         stringTable = getStringTable(DEFAULT_LOCALE);
      }

      InputStream in = null;
      Properties properties = new Properties();
      URL sysURL = null;

      // Load the system string table

      try
      {
         sysURL = SystemResources.find("client." + sLocale + ".strings");

         if (sysURL != null)
         {
            in = URLUtil.openStream(sysURL);
            properties.load(in);
         }
      }
      catch (Exception e)
      {
         if (in != null)
         {
            throw new MetadataException("err.meta.stringTableLoad", new Object[]{sysURL.toString()}, e);
         }
      }
      finally
      {
         IOUtil.close(in);
         in = null;
      }

      try
      {
         sysURL = SystemResources.find("server." + sLocale + ".strings");

         if (sysURL != null)
         {
            in = URLUtil.openStream(sysURL);
            properties.load(in);
         }
      }
      catch (Exception e)
      {
         if (in != null)
         {
            throw new MetadataException("err.meta.stringTableLoad", new Object[]{sysURL.toString()}, e);
         }
      }
      finally
      {
         IOUtil.close(in);
         in = null;
      }

      try
      {
         sysURL = SystemResources.find(sLocale + ".strings");

         if (sysURL != null)
         {
            in = URLUtil.openStream(sysURL);
            properties.load(in);
         }
      }
      catch (Exception e)
      {
         if (in != null)
         {
            throw new MetadataException("err.meta.stringTableLoad", new Object[]{sysURL.toString()}, e);
         }
      }
      finally
      {
         IOUtil.close(in);
         in = null;
      }

      // Overwrite the system string table with the repository string table

      Lookup map = (Lookup)m_stringMap.get(sLocale);
      String sResName = null;

      if (map != null)
      {
         try
         {
            for (Iterator itr = map.iterator(); itr.hasNext();)
            {
               sResName = (String)itr.next();
               in = getHelper().getResourceAsStream(sResName);
               properties.load(in);
               in.close();
               in = null;
            }
         }
         catch (IOException e)
         {
            throw new MetadataException("err.meta.stringTableLoad", new Object[]{sResName}, e);
         }
         finally
         {
            IOUtil.close(in);
         }
      }

      if (!properties.isEmpty())
      {
         stringTable = new StringTable(properties, stringTable, LocaleUtil.parse(sLocale));
      }

      synchronized (m_stringMetaMap)
      {
         Object oldMap = m_stringMetaMap.put(sLocale, stringTable);
View Full Code Here

TOP

Related Classes of nexj.core.util.StringTable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.