Search in sources :

Example 61 with MissingResourceException

use of java.util.MissingResourceException in project jdk8u_jdk by JetBrains.

the class DateFormatProviderImpl method getInstance.

private DateFormat getInstance(int dateStyle, int timeStyle, Locale locale) {
    if (locale == null) {
        throw new NullPointerException();
    }
    SimpleDateFormat sdf = new SimpleDateFormat("", locale);
    Calendar cal = sdf.getCalendar();
    try {
        String pattern = LocaleProviderAdapter.forType(type).getLocaleResources(locale).getDateTimePattern(timeStyle, dateStyle, cal);
        sdf.applyPattern(pattern);
    } catch (MissingResourceException mre) {
        // Specify the fallback pattern
        sdf.applyPattern("M/d/yy h:mm a");
    }
    return sdf;
}
Also used : Calendar(java.util.Calendar) MissingResourceException(java.util.MissingResourceException) SimpleDateFormat(java.text.SimpleDateFormat)

Example 62 with MissingResourceException

use of java.util.MissingResourceException in project jdk8u_jdk by JetBrains.

the class RuleBasedBreakIterator method readFile.

protected byte[] readFile(final String datafile) throws IOException, MissingResourceException {
    BufferedInputStream is;
    try {
        is = AccessController.doPrivileged(new PrivilegedExceptionAction<BufferedInputStream>() {

            @Override
            public BufferedInputStream run() throws Exception {
                return new BufferedInputStream(getClass().getResourceAsStream("/sun/text/resources/" + datafile));
            }
        });
    } catch (PrivilegedActionException e) {
        throw new InternalError(e.toString(), e);
    }
    int offset = 0;
    /* First, read magic, version, and header_info. */
    int len = LABEL_LENGTH + 5;
    byte[] buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong header length", datafile, "");
    }
    /* Validate the magic number. */
    for (int i = 0; i < LABEL_LENGTH; i++, offset++) {
        if (buf[offset] != LABEL[offset]) {
            throw new MissingResourceException("Wrong magic number", datafile, "");
        }
    }
    /* Validate the version number. */
    if (buf[offset] != supportedVersion) {
        throw new MissingResourceException("Unsupported version(" + buf[offset] + ")", datafile, "");
    }
    /* Read data: totalDataSize + 8(for checksum) */
    len = getInt(buf, ++offset);
    buf = new byte[len];
    if (is.read(buf) != len) {
        throw new MissingResourceException("Wrong data length", datafile, "");
    }
    is.close();
    return buf;
}
Also used : BufferedInputStream(java.io.BufferedInputStream) PrivilegedActionException(java.security.PrivilegedActionException) MissingResourceException(java.util.MissingResourceException) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction)

Example 63 with MissingResourceException

use of java.util.MissingResourceException in project jdk8u_jdk by JetBrains.

the class CodePointIM method main.

// Actually, the main method is not required for InputMethod.
// The following method is added just to tell users that their use is
// not correct and encourage their reading README.txt.
public static void main(String[] args) {
    try {
        ResourceBundle resource = ResourceBundle.getBundle("resources.codepoint", Locale.getDefault());
        System.err.println(resource.getString("warning"));
    } catch (MissingResourceException e) {
        System.err.println(e.toString());
    }
    System.exit(1);
}
Also used : MissingResourceException(java.util.MissingResourceException) ResourceBundle(java.util.ResourceBundle)

Example 64 with MissingResourceException

use of java.util.MissingResourceException in project jdk8u_jdk by JetBrains.

the class ImageWriter method processWarningOccurred.

/**
     * Broadcasts a localized warning message to all registered
     * <code>IIOWriteWarningListener</code>s by calling their
     * <code>warningOccurred</code> method with a string taken
     * from a <code>ResourceBundle</code>.  Subclasses may use this
     * method as a convenience.
     *
     * @param imageIndex the index of the image on which the warning
     * occurred.
     * @param baseName the base name of a set of
     * <code>ResourceBundle</code>s containing localized warning
     * messages.
     * @param keyword the keyword used to index the warning message
     * within the set of <code>ResourceBundle</code>s.
     *
     * @exception IllegalArgumentException if <code>baseName</code>
     * is <code>null</code>.
     * @exception IllegalArgumentException if <code>keyword</code>
     * is <code>null</code>.
     * @exception IllegalArgumentException if no appropriate
     * <code>ResourceBundle</code> may be located.
     * @exception IllegalArgumentException if the named resource is
     * not found in the located <code>ResourceBundle</code>.
     * @exception IllegalArgumentException if the object retrieved
     * from the <code>ResourceBundle</code> is not a
     * <code>String</code>.
     */
protected void processWarningOccurred(int imageIndex, String baseName, String keyword) {
    if (warningListeners == null) {
        return;
    }
    if (baseName == null) {
        throw new IllegalArgumentException("baseName == null!");
    }
    if (keyword == null) {
        throw new IllegalArgumentException("keyword == null!");
    }
    int numListeners = warningListeners.size();
    for (int i = 0; i < numListeners; i++) {
        IIOWriteWarningListener listener = (IIOWriteWarningListener) warningListeners.get(i);
        Locale locale = (Locale) warningLocales.get(i);
        if (locale == null) {
            locale = Locale.getDefault();
        }
        /**
             * If an applet supplies an implementation of ImageWriter and
             * resource bundles, then the resource bundle will need to be
             * accessed via the applet class loader. So first try the context
             * class loader to locate the resource bundle.
             * If that throws MissingResourceException, then try the
             * system class loader.
             */
        ClassLoader loader = (ClassLoader) java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {

            public Object run() {
                return Thread.currentThread().getContextClassLoader();
            }
        });
        ResourceBundle bundle = null;
        try {
            bundle = ResourceBundle.getBundle(baseName, locale, loader);
        } catch (MissingResourceException mre) {
            try {
                bundle = ResourceBundle.getBundle(baseName, locale);
            } catch (MissingResourceException mre1) {
                throw new IllegalArgumentException("Bundle not found!");
            }
        }
        String warning = null;
        try {
            warning = bundle.getString(keyword);
        } catch (ClassCastException cce) {
            throw new IllegalArgumentException("Resource is not a String!");
        } catch (MissingResourceException mre) {
            throw new IllegalArgumentException("Resource is missing!");
        }
        listener.warningOccurred(this, imageIndex, warning);
    }
}
Also used : Locale(java.util.Locale) MissingResourceException(java.util.MissingResourceException) IIOWriteWarningListener(javax.imageio.event.IIOWriteWarningListener) ResourceBundle(java.util.ResourceBundle)

Example 65 with MissingResourceException

use of java.util.MissingResourceException in project uPortal by Jasig.

the class XmlChannelPublishingDefinitionDao method loadChannelPublishingDefinition.

private PortletPublishingDefinition loadChannelPublishingDefinition(int channelTypeId) {
    // if the CPD is not already in the cache, determine the CPD URI
    final String cpdUri;
    if (channelTypeId >= 0) {
        final IPortletType type = this.portletTypeRegistry.getPortletType(channelTypeId);
        if (type == null) {
            throw new IllegalArgumentException("No ChannelType registered with id: " + channelTypeId);
        }
        cpdUri = type.getCpdUri();
    } else {
        throw new IllegalArgumentException("No ChannelType registered with id: " + channelTypeId);
    }
    // read and parse the CPD
    final PortletPublishingDefinition def;
    final Resource cpdResource = this.resourceLoader.getResource("classpath:" + cpdUri);
    if (!cpdResource.exists()) {
        throw new MissingResourceException("Failed to find CPD '" + cpdUri + "' for channel type " + channelTypeId, this.getClass().getName(), cpdUri);
    }
    final InputStream cpdStream;
    try {
        cpdStream = cpdResource.getInputStream();
    } catch (IOException e) {
        throw new MissingResourceException("Failed to load CPD '" + cpdUri + "' for channel type " + channelTypeId, this.getClass().getName(), cpdUri);
    }
    try {
        def = (PortletPublishingDefinition) this.unmarshaller.unmarshal(cpdStream);
        final List<Step> sharedParameters = this.getSharedParameters();
        def.getSteps().addAll(sharedParameters);
        // add the CPD to the cache and return it
        this.cpdCache.put(channelTypeId, def);
        return def;
    } catch (JAXBException e) {
    } finally {
        IOUtils.closeQuietly(cpdStream);
    }
    return null;
}
Also used : IPortletType(org.apereo.portal.portlet.om.IPortletType) InputStream(java.io.InputStream) MissingResourceException(java.util.MissingResourceException) JAXBException(javax.xml.bind.JAXBException) Resource(org.springframework.core.io.Resource) PortletPublishingDefinition(org.apereo.portal.portletpublishing.xml.PortletPublishingDefinition) IOException(java.io.IOException) Step(org.apereo.portal.portletpublishing.xml.Step)

Aggregations

MissingResourceException (java.util.MissingResourceException)151 ResourceBundle (java.util.ResourceBundle)77 Locale (java.util.Locale)66 ArrayList (java.util.ArrayList)10 IOException (java.io.IOException)8 MessageFormat (java.text.MessageFormat)8 File (java.io.File)7 HashMap (java.util.HashMap)7 Map (java.util.Map)7 SMSException (com.sun.identity.sm.SMSException)6 PropertyResourceBundle (java.util.PropertyResourceBundle)6 Secure.getString (android.provider.Settings.Secure.getString)5 SSOException (com.iplanet.sso.SSOException)5 InputStream (java.io.InputStream)4 ISResourceBundle (com.sun.identity.common.ISResourceBundle)3 Enumeration (java.util.Enumeration)3 Iterator (java.util.Iterator)3 List (java.util.List)3 Set (java.util.Set)3 AttributeSchema (com.sun.identity.sm.AttributeSchema)2