Java Code Examples for org.apache.xml.utils.res.XResourceBundleBase

Following code examples demonstrate how to use org.apache.xml.utils.res.XResourceBundleBasefrom android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.apache.xml.utils.res.XResourceBundleBaseand various code implementation of this class.

  
  public String createMessage(String bundleName, int errorCode, Object args[])
          throws Exception
  {

    boolean throwex = false;
    int majorCode;
    int minorCode;
    String fmsg = null;
    XResourceBundleBase aResourceBundle = null;

    aResourceBundle = (XResourceBundleBase) loadResourceBundle(bundleName);

    String msgKey = aResourceBundle.getMessageKey(errorCode);
    String msg = null;

    if (msgKey != null)
      msg = aResourceBundle.getString(msgKey);

    if (msg == null)
    {
      msg = aResourceBundle.getString(BAD_CODE);
      throwex = true;
    }

    if (args != null)
    {
      try
      {

        int n = args.length;

        for (int i = 0; i < n; i++)
        {
          if (null == args[i])
            args[i] = "";
        }

        fmsg = java.text.MessageFormat.format(msg, args);
      }
      catch (Exception e)
      {
        fmsg = aResourceBundle.getString(FORMAT_FAILED);
        fmsg += " " + msg;
      }
    }
    else
      fmsg = msg;

    if (throwex)
    {
      throw new RuntimeException(fmsg);
    }

    return fmsg;
  } 


  
  public Locale getLocale()
  {
    return fLocale;
  } 

      }
      catch (Exception e)
      {
        fmsg = fResourceBundle.getString(XPATHErrorResources.FORMAT_FAILED);
        fmsg += " " + msg;
      } 

Advertisement
Javadoc
This is an interface for error messages. This class is misnamed, and should be called XalanResourceB

undle, or some such. @xsl.usage internal

Read More
Related Classes
Advertisement