Package pivot.util

Examples of pivot.util.Resources


        super.tearDown();
    };

    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

     * @throws Exception
     */
    public void testRead_GB_en_Locale() throws Exception {
        assertEquals("Default locale should be en_GB", "en_GB", Locale
                .getDefault().toString());
        Resources res = new Resources("resources.test3");
        assertResources(res, "XSGML",
                "How Do, Youth, Standard Generalized Markup Language");

    }
View Full Code Here

     * @throws Exception
     */
    public void testRead_GB_en_LocaleExtraOverride() throws Exception {
        assertEquals("Default locale should be en_GB", "en_GB", Locale
                .getDefault().toString());
        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", (Locale) null);
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {

        }
    }
View Full Code Here

        }
    }

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

    public void startup(Display display, Dictionary<String, String> properties)
        throws Exception {
        // Set the locale
        String language = properties.get(LANGUAGE_PROPERTY_NAME);
        locale = (language == null) ? Locale.getDefault() : new Locale(language);
        resources = new Resources(getClass().getName(), locale, "UTF8");

        // Load the application's UI
        WTKXSerializer wtkxSerializer = new WTKXSerializer(resources);
        Component content =
            (Component)wtkxSerializer.readObject("pivot/tutorials/stocktracker/stocktracker.wtkx");
View Full Code Here

                            if (localName.equals(INCLUDE_TAG)) {
                                // The element represents an include
                                String src = null;
                                String namespace = 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_NAMESPACE_ATTRIBUTE)) {
                                            namespace = 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

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.