Package pivot.util

Examples of pivot.util.Resources


public class ResourcesTest extends TestCase {

    public void testReadDefaultLocale() throws Exception {

        Resources res = new Resources("resources.test1");
        assertResources(res, "SGML", "Standard Generalized Markup Language");
    }
View Full Code Here


     * The resource overrides the term for the country.
     *
     * @throws Exception
     */
    public void testRead_GB_Locale() throws Exception {
        Resources res = new Resources("resources.test2");
        assertResources(res, "SGML",
                "How Do, Youth, Standard Generalized Markup Language");

    }
View Full Code Here

     * language.
     *
     * @throws Exception
     */
    public void testRead_GB_en_Locale() throws Exception {
        Resources res = new Resources("resources.test3");
        assertResources(res, "XSGML",
                "How Do, Youth, Standard Generalized Markup Language");

    }
View Full Code Here

     * The resource overrides the term and the acronym for the country.
     *
     * @throws Exception
     */
    public void testRead_GB_en_LocaleExtraOverride() throws Exception {
        Resources res = new Resources("resources.test6");
        assertResources(res, "XSGML",
                "eXtra Standard Generalized Markup Language");

    }
View Full Code Here

    }

    public void testSerialisationException() throws Exception {

        try {
            new Resources("resources.test4");
            fail("Expected SerialisationException");
        } catch (SerializationException e) {
        }

    }
View Full Code Here

    public void testMissingResource() throws Exception {

        // resource doesn't exist...
        try {
            new Resources("resources.test5");
            fail("Expected IllegalArgumentException");
        } catch (MissingResourceException e) {
        }

    }
View Full Code Here

    }

    public void testNullLocale() throws Exception {
        // resource exists, but locale is null
        try {
            new Resources("resources.test1");
            fail("Expected NullPointerException");
        } catch (NullPointerException e) {
        }
    }
View Full Code Here

        }
    }

    public void testNullBaseName() throws Exception {
        try {
            new Resources(null);
            fail("Expected NullPointerException");
        } catch (NullPointerException e) {
        }
    }
View Full Code Here

                            }

                            if (localName.equals(INCLUDE_TAG)) {
                                // The element represents an include
                                String src = null;
                                Resources includeResources = resources;

                                ArrayList<Attribute> attributes = new ArrayList<Attribute>();

                                for (int i = 0, n = reader.getAttributeCount(); i < n; i++) {
                                    String attributeNamespaceURI = reader.getAttributeNamespace(i);
                                    if (attributeNamespaceURI == null) {
                                        attributeNamespaceURI = reader.getNamespaceURI("");
                                    }

                                    String attributePrefix = reader.getAttributePrefix(i);
                                    String attributeLocalName = reader.getAttributeLocalName(i);
                                    String attributeValue = reader.getAttributeValue(i);

                                    if (attributePrefix != null
                                        && attributePrefix.equals(WTKX_PREFIX)) {
                                        if (attributeLocalName.equals(ID_ATTRIBUTE)) {
                                            id = attributeValue;
                                        }
                                    } else {
                                        if (attributeLocalName.equals(INCLUDE_SRC_ATTRIBUTE)) {
                                            src = attributeValue;
                                        } else if (attributeLocalName.equals(INCLUDE_RESOURCES_ATTRIBUTE)) {
                                            includeResources = new Resources(attributeValue);
                                        } else {
                                            attributes.add(new Attribute(attributeNamespaceURI,
                                                attributePrefix, attributeLocalName, attributeValue));
                                        }
                                    }
View Full Code Here

                        if ((fieldModifiers & Modifier.PRIVATE) > 0) {
                            privateFieldNames.add(fieldName);
                        }

                        // Get the name of the resource file to use
                        Resources resources = null;
                        boolean defaultResources = false;

                        String baseName = loadAnnotation.resources();
                        if (baseName.equals("\0")) {
                            baseName = type.getName();
                            defaultResources = true;
                        }

                        // Get the resource locale
                        Locale locale;
                        String language = loadAnnotation.locale();
                        if (language.equals("\0")) {
                            locale = Locale.getDefault();
                        } else {
                            locale = new Locale(language);
                        }

                        // Attmpt to load the resources
                        try {
                            resources = new Resources(baseName, locale, "UTF8");
                        } catch(IOException exception) {
                            throw new BindException(exception);
                        } catch(SerializationException exception) {
                            throw new BindException(exception);
                        } catch(MissingResourceException exception) {
View Full Code Here

TOP

Related Classes of pivot.util.Resources

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.